Detecting errors in the storage API

I’ve got a subtle question: is it necessary to call storage_file_get_error after calling storage_file_read if the number of bytes read is exactly bytes_to_read?

More concretely, storage code in the firmware is typically of the form:

storage_SOME_METHOD(...);
if (storage_file_get_error(file) != FSE_OK) {...}

Is storage_file_get_error(file) guaranteed to return FSE_OK if w.l.o.g storage_file_read returns what was passed as bytes_to_read, or is it still possible that there was an error?

1 Like