From fb9d7a447182e50385ea53aa6aad9aecce8ee7e2 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Wed, 26 Jul 2017 16:20:40 +0300 Subject: [PATCH] mdbx: refine freelist_list() to avoid coverity warnings. Change-Id: I38eee44e4ca926e7d11ef5e3f7f3ce2e92f71259 --- src/mdbx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mdbx.c b/src/mdbx.c index 4cb59f50..eacd0187 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -3066,7 +3066,10 @@ again_on_freelist_change: /* LY: note that freeDB cleanup is not needed. */ ++cleanup_reclaimed_pos; } + mdbx_tassert(txn, txn->mt_lifo_reclaimed != NULL); head_id = txn->mt_lifo_reclaimed[refill_reclaimed_pos]; + } else { + mdbx_tassert(txn, txn->mt_lifo_reclaimed == NULL); } /* (Re)write {key = head_id, IDL length = head_room} */ @@ -3132,18 +3135,23 @@ again_on_freelist_change: size_t rpl_left = env->me_reclaimed_pglist[0]; pgno_t *rpl_end = env->me_reclaimed_pglist + rpl_left; - if (!lifo) { + if (txn->mt_lifo_reclaimed == 0) { + mdbx_tassert(txn, lifo == 0); rc = mdbx_cursor_first(&mc, &key, &data); if (unlikely(rc)) goto bailout; + } else { + mdbx_tassert(txn, lifo != 0); } while (1) { txnid_t id; - if (!lifo) { + if (txn->mt_lifo_reclaimed == 0) { + mdbx_tassert(txn, lifo == 0); id = *(txnid_t *)key.iov_base; mdbx_tassert(txn, id <= env->me_last_reclaimed); } else { + mdbx_tassert(txn, lifo != 0); mdbx_tassert(txn, refill_reclaimed_pos > 0 && refill_reclaimed_pos <= txn->mt_lifo_reclaimed[0]);