X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Fsummary.c;h=61d7689749caa6a37b8883439d4ba7c4bcbc524a;hb=3d917ba6dffe2029608a3d4c870dfdb4033ca4c9;hp=182738c41f59129e53a59da2c881d8badd703198;hpb=587982955ca9c61363d6e3004622ee97eda80e4b;p=ccan diff --git a/ccan/tdb2/summary.c b/ccan/tdb2/summary.c index 182738c4..61d76897 100644 --- a/ccan/tdb2/summary.c +++ b/ccan/tdb2/summary.c @@ -26,8 +26,10 @@ static int count_hash(struct tdb_context *tdb, unsigned int i, count = 0; h = tdb_access_read(tdb, hash_off, sizeof(*h) << bits, true); - if (!h) + if (TDB_PTR_IS_ERR(h)) { + tdb->ecode = TDB_PTR_ERR(h); return -1; + } for (i = 0; i < (1 << bits); i++) count += (h[i] != 0); @@ -58,8 +60,10 @@ static bool summarize(struct tdb_context *tdb, } *p; /* We might not be able to get the whole thing. */ p = tdb_access_read(tdb, off, sizeof(p->f), true); - if (!p) + if (TDB_PTR_IS_ERR(p)) { + tdb->ecode = TDB_PTR_ERR(p); return false; + } if (p->r.magic == TDB_RECOVERY_INVALID_MAGIC || p->r.magic == TDB_RECOVERY_MAGIC) { if (unc) { @@ -152,13 +156,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; }