Skip to content

Commit 300c3e7

Browse files
author
Janne Kiiskila
committed
NVStore.cpp compiler warning removal (os_ret)
One gets this compiler warning from nvstore.cpp: ``` Compile [ 48.6%]: nvstore.cpp [Warning] nvstore.cpp@814,9: variable 'os_ret' set but not used [-Wunused-but-set-variable] ``` Turns out it's caused by the fact that the variable is only used with MBED_ASSERTs, which get optimized out or not, depending on your build profile. In reality we do not need a separate variable for that in my opinion though, so we can just use the ret-variable instead and drop the os_ret variable completely and thus avoid this compiler warning.
1 parent 46603f8 commit 300c3e7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

features/storage/nvstore/source/nvstore.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,6 @@ int NVStore::init()
811811
uint32_t free_space_offset_of_area[NVSTORE_NUM_AREAS];
812812
uint32_t init_attempts_val;
813813
uint32_t next_offset;
814-
int os_ret;
815814
int ret = NVSTORE_SUCCESS;
816815
int valid;
817816
uint16_t key;
@@ -869,8 +868,8 @@ int NVStore::init()
869868

870869
// Find start of empty space at the end of the area. This serves for both
871870
// knowing whether the area is empty and for the record traversal at the end.
872-
os_ret = calc_empty_space(area, free_space_offset_of_area[area]);
873-
MBED_ASSERT(!os_ret);
871+
ret = calc_empty_space(area, free_space_offset_of_area[area]);
872+
MBED_ASSERT(!ret);
874873

875874
if (!free_space_offset_of_area[area]) {
876875
area_state[area] = NVSTORE_AREA_STATE_EMPTY;
@@ -891,8 +890,8 @@ int NVStore::init()
891890

892891
// We have a non valid master record, in a non-empty area. Just erase the area.
893892
if ((!valid) || (key != master_record_key)) {
894-
os_ret = flash_erase_area(area);
895-
MBED_ASSERT(!os_ret);
893+
ret = flash_erase_area(area);
894+
MBED_ASSERT(!ret);
896895
area_state[area] = NVSTORE_AREA_STATE_EMPTY;
897896
continue;
898897
}
@@ -939,8 +938,8 @@ int NVStore::init()
939938
_active_area = 1;
940939
}
941940
_active_area_version = versions[_active_area];
942-
os_ret = flash_erase_area(1 - _active_area);
943-
MBED_ASSERT(!os_ret);
941+
ret = flash_erase_area(1 - _active_area);
942+
MBED_ASSERT(!ret);
944943
}
945944

946945
// Traverse area until reaching the empty space at the end or until reaching a faulty record

0 commit comments

Comments
 (0)