Let's be a bit more consistant with error reporting and having "NO ERROR" reported when a function do not fail.
This commit is contained in:
parent
95c214043e
commit
9189728205
13
miniffs.c
13
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user