bugfix(nvs_flash): fixed wrong error check after open_nvs_handle

Closes https://github.com/espressif/esp-idf/issues/10240
This commit is contained in:
Jakob Hasse 2022-11-25 11:03:33 +01:00
parent 367abc1591
commit ec986651db
2 changed files with 2 additions and 3 deletions

View File

@ -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,

View File

@ -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 {