From d2cae60cff3c9612440302fe0a8f6d05b911ed41 Mon Sep 17 00:00:00 2001 From: guoweilkd <1274132245@qq.com> Date: Thu, 12 Oct 2023 10:41:47 +0800 Subject: [PATCH 1/2] fix db_lock()/db_unlock() not calling in pairs --- src/fdb_kvdb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/fdb_kvdb.c b/src/fdb_kvdb.c index 7905fda..5507b23 100644 --- a/src/fdb_kvdb.c +++ b/src/fdb_kvdb.c @@ -1597,8 +1597,7 @@ static fdb_err_t _fdb_kv_load(fdb_kvdb_t db) /* check all sector header */ sector_iterator(db, §or, FDB_SECTOR_STORE_UNUSED, &check_failed_count, db, check_sec_hdr_cb, false); if (db->parent.not_formatable && check_failed_count > 0) { - result = FDB_READ_ERR; - goto __exit; + return FDB_READ_ERR; } /* all sector header check failed */ if (check_failed_count == SECTOR_NUM) { @@ -1621,7 +1620,6 @@ static fdb_err_t _fdb_kv_load(fdb_kvdb_t db) db->in_recovery_check = false; -__exit: /* unlock the KV cache */ db_unlock(db); From 4aa2dbc6a4fdb8d81cde9eed435567f3ed2d556d Mon Sep 17 00:00:00 2001 From: guoweilkd <1274132245@qq.com> Date: Thu, 12 Oct 2023 11:01:02 +0800 Subject: [PATCH 2/2] fix FDB_ALIGN macro expansion errors --- inc/fdb_low_lvl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/fdb_low_lvl.h b/inc/fdb_low_lvl.h index b2cdd0d..888fe89 100644 --- a/inc/fdb_low_lvl.h +++ b/inc/fdb_low_lvl.h @@ -29,9 +29,9 @@ /* Return the most contiguous size aligned at specified width. RT_ALIGN(13, 4) * would return 16. */ -#define FDB_ALIGN(size, align) ((size + align - 1) - ((size + align -1) % align)) +#define FDB_ALIGN(size, align) (((size) + (align) - 1) - (((size) + (align) -1) % (align))) /* align by write granularity */ -#define FDB_WG_ALIGN(size) (FDB_ALIGN(size, (FDB_WRITE_GRAN + 7)/8)) +#define FDB_WG_ALIGN(size) (FDB_ALIGN(size, ((FDB_WRITE_GRAN + 7)/8))) /** * Return the down number of aligned at specified width. RT_ALIGN_DOWN(13, 4) * would return 12.