[fdb] fix comparison of integer expressions of different signedness (#226)

This commit is contained in:
benpicco 2023-08-08 04:34:54 +02:00 committed by GitHub
parent cc1c6f4d9f
commit 07dcd7f035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -81,7 +81,8 @@ fdb_err_t _fdb_file_read(fdb_db_t db, uint32_t addr, void *buf, size_t size)
if (fd > 0) {
/* get the offset address is relative to the start of the current file */
addr = addr % db->sec_size;
if ((lseek(fd, addr, SEEK_SET) != addr) || (read(fd, buf, size) != size))
if ((lseek(fd, addr, SEEK_SET) != (int32_t)addr)
|| (read(fd, buf, size) != (ssize_t)size))
result = FDB_READ_ERR;
} else {
result = FDB_READ_ERR;
@ -96,7 +97,8 @@ fdb_err_t _fdb_file_write(fdb_db_t db, uint32_t addr, const void *buf, size_t si
if (fd > 0) {
/* get the offset address is relative to the start of the current file */
addr = addr % db->sec_size;
if ((lseek(fd, addr, SEEK_SET) != addr) || (write(fd, buf, size) != size))
if ((lseek(fd, addr, SEEK_SET) != (int32_t)addr)
|| (write(fd, buf, size) != (ssize_t)size))
result = FDB_WRITE_ERR;
if(sync) {
fsync(fd);