From 9189728205f56662cc3f94b6daa6ec03b82aded2 Mon Sep 17 00:00:00 2001 From: Godzil Date: Fri, 27 May 2022 11:20:39 +0100 Subject: [PATCH] Let's be a bit more consistant with error reporting and having "NO ERROR" reported when a function do not fail. --- miniffs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/miniffs.c b/miniffs.c index cd4a261..931ac39 100644 --- a/miniffs.c +++ b/miniffs.c @@ -34,6 +34,7 @@ file_t *miniffs_open(miniffs_t *fs, const char *filename) } ret->offset = 0; + miniffs_seterror(MINIFFS_NOERROR); goto exit; free_and_exit: @@ -52,11 +53,16 @@ int miniffs_close(file_t *file) file->fent = NULL; free(file); + + miniffs_seterror(MINIFFS_NOERROR); } void *miniffs_map(file_t *file) { miniffs_t *fs = (miniffs_t *)file->private_data; + + miniffs_seterror(MINIFFS_NOERROR); + return miniffs_getfileaddr(fs, file->fent); } @@ -73,6 +79,10 @@ uint8_t miniffs_read(file_t *file) miniffs_seterror(MINIFFS_END_OF_FILE); file->offset = file->fent->size - 1; } + else + { + miniffs_seterror(MINIFFS_NOERROR); + } return ret; } @@ -97,6 +107,7 @@ int miniffs_read_blocks(void *ptr, size_t size, size_t nmemb, file_t *file) } } file->offset = fileOffset; + miniffs_seterror(MINIFFS_NOERROR); return blockCount; } @@ -118,10 +129,12 @@ int miniffs_seek(file_t *file, size_t offset, int whence) file->offset = file->fent->size - offset; break; } + miniffs_seterror(MINIFFS_NOERROR); } size_t miniffs_tell(file_t *file) { + miniffs_seterror(MINIFFS_NOERROR); return file->offset; }