From dacb0535464acd51f85182c5038efdc590cad394 Mon Sep 17 00:00:00 2001 From: Simon Werner Date: Tue, 27 Jun 2017 11:58:49 +1200 Subject: [PATCH 1/2] ESP_ERR_NVS_VALUE_TOO_LONG had conflicting value. `ESP_ERR_NVS_VALUE_TOO_LONG` had conflicting value, its original value was `0x0c`, which is the same as `ESP_ERR_NVS_INVALID_LENGTH` --- components/nvs_flash/include/nvs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/nvs_flash/include/nvs.h b/components/nvs_flash/include/nvs.h index d127e8f404..5b469f764a 100644 --- a/components/nvs_flash/include/nvs.h +++ b/components/nvs_flash/include/nvs.h @@ -42,7 +42,7 @@ typedef uint32_t nvs_handle; #define ESP_ERR_NVS_INVALID_STATE (ESP_ERR_NVS_BASE + 0x0b) /*!< NVS is in an inconsistent state due to a previous error. Call nvs_flash_init and nvs_open again, then retry. */ #define ESP_ERR_NVS_INVALID_LENGTH (ESP_ERR_NVS_BASE + 0x0c) /*!< String or blob length is not sufficient to store data */ #define ESP_ERR_NVS_NO_FREE_PAGES (ESP_ERR_NVS_BASE + 0x0d) /*!< NVS partition doesn't contain any empty pages. This may happen if NVS partition was truncated. Erase the whole partition and call nvs_flash_init again. */ -#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0c) /*!< String or blob length is longer than supported by the implementation */ +#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< String or blob length is longer than supported by the implementation */ /** * @brief Mode of opening the non-volatile storage From f04512369113a857d213d644d5dc8cfbe46c8690 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 27 Jun 2017 11:28:37 +0800 Subject: [PATCH 2/2] nvs: add test for ESP_ERR_NVS_INVALID_LENGTH --- components/nvs_flash/test_nvs_host/test_nvs.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/nvs_flash/test_nvs_host/test_nvs.cpp b/components/nvs_flash/test_nvs_host/test_nvs.cpp index ce5c864303..22d4c3b70b 100644 --- a/components/nvs_flash/test_nvs_host/test_nvs.cpp +++ b/components/nvs_flash/test_nvs_host/test_nvs.cpp @@ -522,6 +522,14 @@ TEST_CASE("nvs api tests", "[nvs]") char buf[strlen(str) + 1]; size_t buf_len = sizeof(buf); + size_t buf_len_needed; + TEST_ESP_OK(nvs_get_str(handle_2, "key", NULL, &buf_len_needed)); + CHECK(buf_len_needed == buf_len); + + size_t buf_len_short = buf_len - 1; + TEST_ESP_ERR(ESP_ERR_NVS_INVALID_LENGTH, nvs_get_str(handle_2, "key", buf, &buf_len_short)); + CHECK(buf_len_short == buf_len); + TEST_ESP_OK(nvs_get_str(handle_2, "key", buf, &buf_len)); CHECK(0 == strcmp(buf, str));