X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fsummary.c;h=d279131d3eec65561a9e86c3bb6e80412e7aef9b;hp=bb9f5cb54eb5fd3e5dc8fb6257899546e046823b;hb=850c5cfed46cd4f38df79783791969c7b30ad9da;hpb=5eaf46e9a0d38c371b50d5dd3a433fc721c1c4dc diff --git a/ccan/tdb2/summary.c b/ccan/tdb2/summary.c index bb9f5cb5..d279131d 100644 --- a/ccan/tdb2/summary.c +++ b/ccan/tdb2/summary.c @@ -1,7 +1,7 @@ - /* + /* Trivial Database 2: human-readable summary code Copyright (C) Rusty Russell 2010 - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -152,13 +152,19 @@ char *tdb_summary(struct tdb_context *tdb, enum tdb_summary_flags flags) *buckets, *chains; char *hashesg, *freeg, *keysg, *datag, *extrag, *uncoalg, *bucketsg; char *ret = NULL; + enum TDB_ERROR ecode; hashesg = freeg = keysg = datag = extrag = uncoalg = bucketsg = NULL; - if (tdb_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false) != 0) + ecode = tdb_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false); + if (ecode != TDB_SUCCESS) { + tdb->ecode = ecode; return NULL; + } - if (tdb_lock_expand(tdb, F_RDLCK) != 0) { + ecode = tdb_lock_expand(tdb, F_RDLCK); + if (ecode != TDB_SUCCESS) { + tdb->ecode = ecode; tdb_allrecord_unlock(tdb, F_RDLCK); return NULL; } @@ -175,7 +181,7 @@ char *tdb_summary(struct tdb_context *tdb, enum tdb_summary_flags flags) chains = tally_new(HISTO_HEIGHT); if (!ftables || !hashes || !freet || !keys || !data || !extra || !uncoal || !buckets || !chains) { - tdb_logerr(tdb, TDB_ERR_OOM, TDB_DEBUG_ERROR, + tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR, "tdb_summary: failed to allocate tally structures"); goto unlock; }