Kaynağa Gözat

bugfix(nvs_flash): fixed wrong error check after open_nvs_handle

Closes https://github.com/espressif/esp-idf/issues/10240
Jakob Hasse 3 yıl önce
ebeveyn
işleme
ec986651db

+ 1 - 1
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<NVSHandle> open_nvs_handle_from_partition(const char *partition_name,
         const char *ns_name,

+ 1 - 2
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<nvs::NVSHandle> handle = nvs::open_nvs_handle("storage", NVS_READWRITE, &result);
+    std::unique_ptr<nvs::NVSHandle> 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 {