@@ -17,10 +17,9 @@ namespace
1717template <class T > bool LoadDataToObject (Nrf::PersistentStorageNode *node, T &data)
1818{
1919 size_t readSize = 0 ;
20+ const Nrf::PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureLoad (node, &data, sizeof (T), readSize);
2021
21- bool result = Nrf::GetPersistentStorage ().NonSecureLoad (node, &data, sizeof (T), readSize);
22-
23- return result;
22+ return status == Nrf::PSErrorCode::Success ? sizeof (T) == readSize : false ;
2423}
2524
2625Nrf::PersistentStorageNode CreateIndexNode (uint8_t bridgedDeviceIndex, Nrf::PersistentStorageNode *parent)
@@ -47,8 +46,8 @@ template <> bool BridgeStorageManager::LoadBridgedDevice(BridgedDeviceV1 &device
4746 const uint8_t mandatoryItemsSize =
4847 sizeof (device.mEndpointId ) + sizeof (device.mDeviceType ) + sizeof (device.mNodeLabelLength );
4948
50- if (! Nrf::GetPersistentStorage ().NonSecureLoad (&id, buffer, sizeof (BridgedDeviceV1) + kMaxUserDataSize ,
51- readSize)) {
49+ if (Nrf::GetPersistentStorage ().NonSecureLoad (&id, buffer, sizeof (BridgedDeviceV1) + kMaxUserDataSize ,
50+ readSize) != PSErrorCode::Success ) {
5251 return false ;
5352 }
5453
@@ -114,8 +113,8 @@ template <> bool BridgeStorageManager::LoadBridgedDevice(BridgedDeviceV2 &device
114113 const uint8_t mandatoryItemsSize =
115114 sizeof (device.mEndpointId ) + sizeof (device.mDeviceType ) + sizeof (device.mUniqueIDLength );
116115
117- if (! Nrf::GetPersistentStorage ().NonSecureLoad (&id, buffer, sizeof (BridgedDeviceV2) + kMaxUserDataSize ,
118- readSize)) {
116+ if (Nrf::GetPersistentStorage ().NonSecureLoad (&id, buffer, sizeof (BridgedDeviceV2) + kMaxUserDataSize ,
117+ readSize) != PSErrorCode::Success ) {
119118 return false ;
120119 }
121120
@@ -189,10 +188,10 @@ template <> bool BridgeStorageManager::LoadBridgedDevice(BridgedDeviceV2 &device
189188
190189bool BridgeStorageManager::Init ()
191190{
192- bool result = Nrf::GetPersistentStorage ().NonSecureInit ();
191+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureInit ();
193192
194- if (!result ) {
195- return result ;
193+ if (status != PSErrorCode::Success ) {
194+ return false ;
196195 }
197196
198197 /* Perform data migration from previous data structure versions if needed. */
@@ -361,7 +360,10 @@ bool BridgeStorageManager::MigrateData()
361360
362361bool BridgeStorageManager::StoreBridgedDevicesCount (uint8_t count)
363362{
364- return Nrf::GetPersistentStorage ().NonSecureStore (&mBridgedDevicesCount , &count, sizeof (count));
363+ const PSErrorCode status =
364+ Nrf::GetPersistentStorage ().NonSecureStore (&mBridgedDevicesCount , &count, sizeof (count));
365+
366+ return status == PSErrorCode::Success;
365367}
366368
367369bool BridgeStorageManager::LoadBridgedDevicesCount (uint8_t &count)
@@ -375,7 +377,9 @@ bool BridgeStorageManager::StoreBridgedDevicesIndexes(uint8_t *indexes, uint8_t
375377 return false ;
376378 }
377379
378- return Nrf::GetPersistentStorage ().NonSecureStore (&mBridgedDevicesIndexes , indexes, count);
380+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureStore (&mBridgedDevicesIndexes , indexes, count);
381+
382+ return status == PSErrorCode::Success;
379383}
380384
381385bool BridgeStorageManager::LoadBridgedDevicesIndexes (uint8_t *indexes, uint8_t maxCount, size_t &count)
@@ -384,7 +388,10 @@ bool BridgeStorageManager::LoadBridgedDevicesIndexes(uint8_t *indexes, uint8_t m
384388 return false ;
385389 }
386390
387- return Nrf::GetPersistentStorage ().NonSecureLoad (&mBridgedDevicesIndexes , indexes, maxCount, count);
391+ const PSErrorCode status =
392+ Nrf::GetPersistentStorage ().NonSecureLoad (&mBridgedDevicesIndexes , indexes, maxCount, count);
393+
394+ return status == PSErrorCode::Success;
388395}
389396
390397#ifdef CONFIG_BRIDGE_MIGRATE_PRE_2_7_0
@@ -398,23 +405,26 @@ bool BridgeStorageManager::LoadBridgedDeviceEndpointId(uint16_t &endpointId, uin
398405bool BridgeStorageManager::RemoveBridgedDeviceEndpointId (uint8_t bridgedDeviceIndex)
399406{
400407 Nrf::PersistentStorageNode id = CreateIndexNode (bridgedDeviceIndex, &mBridgedDeviceEndpointId );
408+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureRemove (&id);
401409
402- return Nrf::GetPersistentStorage (). NonSecureRemove (&id) ;
410+ return status == PSErrorCode::Success ;
403411}
404412
405413bool BridgeStorageManager::LoadBridgedDeviceNodeLabel (char *label, size_t labelMaxLength, size_t &labelLength,
406414 uint8_t bridgedDeviceIndex)
407415{
408416 Nrf::PersistentStorageNode id = CreateIndexNode (bridgedDeviceIndex, &mBridgedDeviceNodeLabel );
417+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureLoad (&id, label, labelMaxLength, labelLength);
409418
410- return Nrf::GetPersistentStorage (). NonSecureLoad (&id, label, labelMaxLength, labelLength) ;
419+ return status == PSErrorCode::Success ;
411420}
412421
413422bool BridgeStorageManager::RemoveBridgedDeviceNodeLabel (uint8_t bridgedDeviceIndex)
414423{
415424 Nrf::PersistentStorageNode id = CreateIndexNode (bridgedDeviceIndex, &mBridgedDeviceNodeLabel );
425+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureRemove (&id);
416426
417- return Nrf::GetPersistentStorage (). NonSecureRemove (&id) ;
427+ return status == PSErrorCode::Success ;
418428}
419429
420430bool BridgeStorageManager::LoadBridgedDeviceType (uint16_t &deviceType, uint8_t bridgedDeviceIndex)
@@ -427,8 +437,9 @@ bool BridgeStorageManager::LoadBridgedDeviceType(uint16_t &deviceType, uint8_t b
427437bool BridgeStorageManager::RemoveBridgedDeviceType (uint8_t bridgedDeviceIndex)
428438{
429439 Nrf::PersistentStorageNode id = CreateIndexNode (bridgedDeviceIndex, &mBridgedDeviceType );
440+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureRemove (&id);
430441
431- return Nrf::GetPersistentStorage (). NonSecureRemove (&id) ;
442+ return status == PSErrorCode::Success ;
432443}
433444#endif
434445
@@ -464,14 +475,17 @@ bool BridgeStorageManager::StoreBridgedDevice(BridgedDevice &device, uint8_t ind
464475 counter += device.mUserDataSize ;
465476 }
466477
467- return Nrf::GetPersistentStorage ().NonSecureStore (&id, buffer, counter);
478+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureStore (&id, buffer, counter);
479+
480+ return status == PSErrorCode::Success;
468481}
469482
470483bool BridgeStorageManager::RemoveBridgedDevice (uint8_t index)
471484{
472485 Nrf::PersistentStorageNode id = CreateIndexNode (index, &mBridgedDevice );
486+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureRemove (&id);
473487
474- return Nrf::GetPersistentStorage (). NonSecureRemove (&id) ;
488+ return status == PSErrorCode::Success ;
475489}
476490
477491#ifdef CONFIG_BRIDGE_MIGRATE_PRE_2_7_0
@@ -486,8 +500,9 @@ bool BridgeStorageManager::LoadBtAddress(bt_addr_le_t &addr, uint8_t bridgedDevi
486500bool BridgeStorageManager::RemoveBtAddress (uint8_t bridgedDeviceIndex)
487501{
488502 Nrf::PersistentStorageNode id = CreateIndexNode (bridgedDeviceIndex, &mBtAddress );
503+ const PSErrorCode status = Nrf::GetPersistentStorage ().NonSecureRemove (&id);
489504
490- return Nrf::GetPersistentStorage (). NonSecureRemove (&id) ;
505+ return status == PSErrorCode::Success ;
491506}
492507#endif
493508#endif
0 commit comments