From ec986651dbd9dffee6650f5b411cd4f807b03e59 Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Fri, 25 Nov 2022 11:03:33 +0100 Subject: [PATCH] bugfix(nvs_flash): fixed wrong error check after open_nvs_handle Closes https://github.com/espressif/esp-idf/issues/10240 --- components/nvs_flash/include/nvs_handle.hpp | 2 +- .../storage/nvs_rw_value_cxx/main/nvs_value_example_main.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/components/nvs_flash/include/nvs_handle.hpp b/components/nvs_flash/include/nvs_handle.hpp index 287866fad6..b09d013d22 100644 --- a/components/nvs_flash/include/nvs_handle.hpp +++ b/components/nvs_flash/include/nvs_handle.hpp @@ -224,7 +224,7 @@ protected: * - ESP_ERR_NVS_INVALID_NAME if namespace name doesn't satisfy constraints * - other error codes from the underlying storage driver * - * @return shared pointer of an nvs handle on success, an empty shared pointer otherwise + * @return unique pointer of an nvs handle on success, an empty unique pointer otherwise */ std::unique_ptr open_nvs_handle_from_partition(const char *partition_name, const char *ns_name, diff --git a/examples/storage/nvs_rw_value_cxx/main/nvs_value_example_main.cpp b/examples/storage/nvs_rw_value_cxx/main/nvs_value_example_main.cpp index 04c4858560..e1bd1d0842 100644 --- a/examples/storage/nvs_rw_value_cxx/main/nvs_value_example_main.cpp +++ b/examples/storage/nvs_rw_value_cxx/main/nvs_value_example_main.cpp @@ -33,9 +33,8 @@ extern "C" void app_main(void) // Open printf("\n"); printf("Opening Non-Volatile Storage (NVS) handle... "); - esp_err_t result; // Handle will automatically close when going out of scope or when it's reset. - std::shared_ptr handle = nvs::open_nvs_handle("storage", NVS_READWRITE, &result); + std::unique_ptr handle = nvs::open_nvs_handle("storage", NVS_READWRITE, &err); if (err != ESP_OK) { printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err)); } else {