]> granicus.if.org Git - esp-idf/commitdiff
components/nvs: clear handles list on init, fix returning *length in nvs_get_{str...
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 22 Aug 2016 03:58:13 +0000 (11:58 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Tue, 23 Aug 2016 04:08:00 +0000 (12:08 +0800)
components/nvs_flash/src/nvs_api.cpp

index 041dc9e46ec482a4d2d9ddc97d73c807d7351e23..f9292e680ebc5c0b817f19363c5890122ec7bda7 100644 (file)
@@ -56,6 +56,7 @@ extern "C" esp_err_t nvs_flash_init(uint32_t baseSector, uint32_t sectorCount)
     Lock::init();
     Lock lock;
     NVS_DEBUGV("%s %d %d\r\n", __func__, baseSector, sectorCount);
+    s_nvs_handles.clear();
     return s_nvs_storage.init(baseSector, sectorCount);
 }
 
@@ -260,12 +261,15 @@ static esp_err_t nvs_get_str_or_blob(nvs_handle handle, nvs::ItemType type, cons
         return err;
     }
 
-    if (length != nullptr && out_value == nullptr) {
+    if (length == nullptr) {
+        return ESP_ERR_NVS_INVALID_LENGTH;
+    }
+    else if (out_value == nullptr) {
         *length = dataSize;
         return ESP_OK;
     }
-
-    if (length == nullptr || *length < dataSize) {
+    else if (*length < dataSize) {
+        *length = dataSize;
         return ESP_ERR_NVS_INVALID_LENGTH;
     }