X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fcheck.c;h=d4f1d343bf0268546aca47d72158bd6bab3b83eb;hp=2b7576e6a27b65d07da9cad0a64e199c165a92a6;hb=3835bb95d716cb6448913792b0d8d539877d93e9;hpb=7d6312518bd3a8e4cbad69b1f6b1800f7bcdf68c diff --git a/ccan/tdb2/check.c b/ccan/tdb2/check.c index 2b7576e6..d4f1d343 100644 --- a/ccan/tdb2/check.c +++ b/ccan/tdb2/check.c @@ -136,8 +136,10 @@ static bool check_hash_chain(struct tdb_context *tdb, return false; off = tdb_read_off(tdb, off + offsetof(struct tdb_chain, next)); - if (off == TDB_OFF_ERR) + if (TDB_OFF_IS_ERR(off)) { + tdb->ecode = off; return false; + } if (off == 0) return true; (*num_found)++; @@ -237,8 +239,10 @@ static bool check_hash_tree(struct tdb_context *tdb, sizeof(tdb_off_t) << (group_bits + TDB_HASH_GROUP_BITS), true); - if (!hash) + if (TDB_PTR_IS_ERR(hash)) { + tdb->ecode = TDB_PTR_ERR(hash); return false; + } for (g = 0; g < (1 << group_bits); g++) { const tdb_off_t *group = hash + (g << TDB_HASH_GROUP_BITS); @@ -389,8 +393,10 @@ static bool check_hash_tree(struct tdb_context *tdb, off + sizeof(rec), key.dsize + data.dsize, false); - if (!key.dptr) + if (TDB_PTR_IS_ERR(key.dptr)) { + tdb->ecode = TDB_PTR_ERR(key.dptr); goto fail; + } data.dptr = key.dptr + key.dsize; if (check(key, data, private_data) != 0) goto fail; @@ -508,8 +514,10 @@ static bool check_free_table(struct tdb_context *tdb, h = bucket_off(ftable_off, i); for (off = tdb_read_off(tdb, h); off; off = f.next) { - if (off == TDB_OFF_ERR) + if (TDB_OFF_IS_ERR(off)) { + tdb->ecode = off; return false; + } ecode = tdb_read_convert(tdb, off, &f, sizeof(f)); if (ecode != TDB_SUCCESS) { tdb->ecode = ecode; @@ -721,7 +729,7 @@ int tdb_check(struct tdb_context *tdb, enum TDB_ERROR ecode; ecode = tdb_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false); - if (ecpde != TDB_SUCCESS) { + if (ecode != TDB_SUCCESS) { tdb->ecode = ecode; return -1; } @@ -741,8 +749,10 @@ int tdb_check(struct tdb_context *tdb, goto fail; for (ft = first_ftable(tdb); ft; ft = next_ftable(tdb, ft)) { - if (ft == TDB_OFF_ERR) + if (TDB_OFF_IS_ERR(ft)) { + tdb->ecode = ft; goto fail; + } if (!check_free_table(tdb, ft, num_ftables, fr, num_free, &num_found)) goto fail;