[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:
_VIFEXTech 2024-01-01 18:25:13 +08:00 committed by GitHub
parent 0594fdc957
commit 760520564c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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;