[fdb_kvdb] fix runtime error (#271)
```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>
This commit is contained in:
parent
0594fdc957
commit
760520564c
|
@ -292,9 +292,9 @@ static uint32_t find_next_kv_addr(fdb_kvdb_t db, uint32_t start, uint32_t end)
|
||||||
return FAILED_ADDR;
|
return FAILED_ADDR;
|
||||||
for (i = 0; i < sizeof(buf) - sizeof(uint32_t) && start + i < end; i++) {
|
for (i = 0; i < sizeof(buf) - sizeof(uint32_t) && start + i < end; i++) {
|
||||||
#ifndef FDB_BIG_ENDIAN /* Little Endian Order */
|
#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 */
|
#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
|
#endif
|
||||||
if (magic == KV_MAGIC_WORD && (start + i - KV_MAGIC_OFFSET) >= start_bak) {
|
if (magic == KV_MAGIC_WORD && (start + i - KV_MAGIC_OFFSET) >= start_bak) {
|
||||||
return start + i - KV_MAGIC_OFFSET;
|
return start + i - KV_MAGIC_OFFSET;
|
||||||
|
|
Loading…
Reference in New Issue