mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
nvs: nvs_get_stats fixed test, improved comment
This commit is contained in:
parent
ac6c03fad1
commit
3ffb8f8ffd
@ -235,6 +235,7 @@ esp_err_t PageManager::fillStats(nvs_stats_t& nvsStats)
|
||||
nvsStats.free_entries += mFreePageList.size() * Page::ENTRY_COUNT;
|
||||
|
||||
// calculate available entries from free entries by applying reserved page size
|
||||
// avoid overflow of size_t declared available_entries in case of free_entries being too low
|
||||
nvsStats.available_entries = (nvsStats.free_entries >= Page::ENTRY_COUNT) ? nvsStats.free_entries - Page::ENTRY_COUNT : 0;
|
||||
|
||||
return err;
|
||||
|
@ -314,7 +314,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
|
||||
TEST_ASSERT_TRUE(stat1.total_entries == stat2.total_entries);
|
||||
TEST_ASSERT_TRUE(stat1.used_entries == 7);
|
||||
|
||||
TEST_ASSERT_TRUE(stat1.total_entries == (stat1.used_entries + stat1.free_entries + 126)); // one Page::ENTRY_COUNT is reserved
|
||||
TEST_ASSERT_TRUE(stat1.total_entries == (stat1.used_entries + stat1.free_entries));
|
||||
|
||||
// amount valid pair in namespace 2
|
||||
size_t h2_count_entries;
|
||||
|
Loading…
Reference in New Issue
Block a user