From: Rusty Russell Date: Thu, 23 Dec 2010 02:14:25 +0000 (+1030) Subject: tdb: fix uncoalesced record count in tdb_summary. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=72d5504f02dbcb20b3df262834ee422be3405412 tdb: fix uncoalesced record count in tdb_summary. One free record is not "uncoalesced". --- diff --git a/ccan/tdb/summary.c b/ccan/tdb/summary.c index cb6dd6ee..277ab4cb 100644 --- a/ccan/tdb/summary.c +++ b/ccan/tdb/summary.c @@ -102,6 +102,9 @@ char *tdb_summary(struct tdb_context *tdb, enum tdb_summary_flags flags) tally_add(data, rec.data_len); tally_add(extra, rec.rec_len - (rec.key_len + rec.data_len)); + if (unc > 1) + tally_add(uncoal, unc - 1); + unc = 0; break; case TDB_FREE_MAGIC: tally_add(freet, rec.rec_len); @@ -122,15 +125,9 @@ char *tdb_summary(struct tdb_context *tdb, enum tdb_summary_flags flags) rec.magic, off)); goto unlock; } - - if (unc && - (rec.magic == TDB_MAGIC || rec.magic == TDB_DEAD_MAGIC)) { - tally_add(uncoal, unc); - unc = 0; - } } - if (unc) - tally_add(uncoal, unc); + if (unc > 1) + tally_add(uncoal, unc - 1); for (off = 0; off < tdb->header.hash_size; off++) tally_add(hash, get_hash_length(tdb, off));