From 07dcd7f03539d028720a16e286ef65a57be33627 Mon Sep 17 00:00:00 2001 From: benpicco Date: Tue, 8 Aug 2023 04:34:54 +0200 Subject: [PATCH] [fdb] fix comparison of integer expressions of different signedness (#226) --- src/fdb_file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fdb_file.c b/src/fdb_file.c index 94551c9..c5e4472 100644 --- a/src/fdb_file.c +++ b/src/fdb_file.c @@ -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);