mirror of
https://github.com/armink/FlashDB.git
synced 2025-01-29 04:32:53 +08:00
[fdb] fix comparison of integer expressions of different signedness (#226)
This commit is contained in:
parent
cc1c6f4d9f
commit
07dcd7f035
@ -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) {
|
if (fd > 0) {
|
||||||
/* get the offset address is relative to the start of the current file */
|
/* get the offset address is relative to the start of the current file */
|
||||||
addr = addr % db->sec_size;
|
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;
|
result = FDB_READ_ERR;
|
||||||
} else {
|
} else {
|
||||||
result = FDB_READ_ERR;
|
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) {
|
if (fd > 0) {
|
||||||
/* get the offset address is relative to the start of the current file */
|
/* get the offset address is relative to the start of the current file */
|
||||||
addr = addr % db->sec_size;
|
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;
|
result = FDB_WRITE_ERR;
|
||||||
if(sync) {
|
if(sync) {
|
||||||
fsync(fd);
|
fsync(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user