Skip to content

Commit

Permalink
[fdb_kvdb] fix runtime error (#271)
Browse files Browse the repository at this point in the history
```bash
FlashDB/src/fdb_kvdb.c:288:83: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
```

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>
  • Loading branch information
FASTSHIFT authored Jan 1, 2024
1 parent 0594fdc commit 7605205
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fdb_kvdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ static uint32_t find_next_kv_addr(fdb_kvdb_t db, uint32_t start, uint32_t end)
return FAILED_ADDR;
for (i = 0; i < sizeof(buf) - sizeof(uint32_t) && start + i < end; i++) {
#ifndef FDB_BIG_ENDIAN /* Little Endian Order */
magic = buf[i] + (buf[i + 1] << 8) + (buf[i + 2] << 16) + (buf[i + 3] << 24);
magic = buf[i] + ((uint32_t)buf[i + 1] << 8) + ((uint32_t)buf[i + 2] << 16) + ((uint32_t)buf[i + 3] << 24);
#else /* Big Endian Order */
magic = buf[i + 3] + (buf[i + 2] << 8) + (buf[i + 1] << 16) + (buf[i] << 24);
magic = buf[i + 3] + ((uint32_t)buf[i + 2] << 8) + ((uint32_t)buf[i + 1] << 16) + ((uint32_t)buf[i] << 24);
#endif
if (magic == KV_MAGIC_WORD && (start + i - KV_MAGIC_OFFSET) >= start_bak) {
return start + i - KV_MAGIC_OFFSET;
Expand Down

0 comments on commit 7605205

Please sign in to comment.