1
0
mirror of https://github.com/armink/FlashDB.git synced 2025-01-16 20:12:52 +08:00

[fdb] Fixed a bug with reversed arguments to the fwrite and fread functions for LIBC mode. (#333)

This commit is contained in:
MGlolenstine 2024-12-25 02:30:34 +01:00 committed by GitHub
parent 89bd19ac3c
commit cf47f490bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -263,7 +263,7 @@ fdb_err_t _fdb_file_read(fdb_db_t db, uint32_t addr, void *buf, size_t size)
FILE *fp = open_db_file(db, addr, false);
if (fp) {
addr = addr % db->sec_size;
if ((fseek(fp, addr, SEEK_SET) != 0) || (fread(buf, size, 1, fp) != size))
if ((fseek(fp, addr, SEEK_SET) != 0) || (fread(buf, size, 1, fp) != 1))
result = FDB_READ_ERR;
} else {
result = FDB_READ_ERR;
@ -277,7 +277,7 @@ fdb_err_t _fdb_file_write(fdb_db_t db, uint32_t addr, const void *buf, size_t si
FILE *fp = open_db_file(db, addr, false);
if (fp) {
addr = addr % db->sec_size;
if ((fseek(fp, addr, SEEK_SET) != 0) || (fwrite(buf, size, 1, fp) != size))
if ((fseek(fp, addr, SEEK_SET) != 0) || (fwrite(buf, size, 1, fp) != 1))
result = FDB_READ_ERR;
if(sync) {
fflush(fp);
@ -285,7 +285,6 @@ fdb_err_t _fdb_file_write(fdb_db_t db, uint32_t addr, const void *buf, size_t si
} else {
result = FDB_READ_ERR;
}
return result;
}