Skip to content

Commit

Permalink
[fdb] Fixed a bug with reversed arguments to the fwrite and fread fun…
Browse files Browse the repository at this point in the history
…ctions for LIBC mode. (#333)
  • Loading branch information
MGlolenstine authored Dec 25, 2024
1 parent 89bd19a commit cf47f49
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/fdb_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -277,15 +277,14 @@ 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);
}
} else {
result = FDB_READ_ERR;
}

return result;
}

Expand Down

0 comments on commit cf47f49

Please sign in to comment.