nvs_entry_find, nvs_entry_next don't return proper error codes for differentiating between not found and internal errors (IDFGH-6149) #7826
Labels
Resolution: Done
Issue is done internally
Status: Resolved
Issue is done internally
Type: Feature Request
Feature request for IDF
Is your feature request related to a problem? Please describe.
The nvs iteration API looks very different from the rest of the nvs API. After reading #129, I now understand that this API was added later, so probably that's the reason it looks so different. The new API doesn't operate on handles and doesn't return proper error codes for the various situations when not a valid iterator could be returned.
The issue with this new API is that
NULL
is returned regardless of the error. According to the documentation, an iterator will be returned if there is a matching entry, andNULL
if no entry satisfying criteria was found. But this is kind of a lie. In case, e.g. amalloc
operation failed due to out of memory, flash read failed etc.,NULL
will be returned as well. This makes it impossible to differentiate when there actually are no entries found, and when some internal operation failed for other reasons. In case of out of memory, I as an application developer would try to free some other application memory and then try the nvs operation again, but now this is not possible.Describe the solution you'd like
A different API with proper error codes so I can know for sure if no entries exist or some other error occurred. Proposedly, the API should also use
nvs_handle_t
instead of taking namespace as a string to be consistent with the rest of the API. The user probably wants to have such an opened handle anyway to later read the values being iterating over.The text was updated successfully, but these errors were encountered: