components/nvs: clear handles list on init, fix returning *length in nvs_get_{str,blob}

pull/2/merge
Ivan Grokhotkov 2016-08-22 11:58:13 +08:00
rodzic 35d50643bc
commit 7447d08605
1 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -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;
}