From 760520564c641776448034b444fbdb05f29ee847 Mon Sep 17 00:00:00 2001 From: _VIFEXTech Date: Mon, 1 Jan 2024 18:25:13 +0800 Subject: [PATCH] [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 --- src/fdb_kvdb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fdb_kvdb.c b/src/fdb_kvdb.c index 505ba7b..384d016 100644 --- a/src/fdb_kvdb.c +++ b/src/fdb_kvdb.c @@ -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;