X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fcheck.c;h=d4f1d343bf0268546aca47d72158bd6bab3b83eb;hp=1b3516720d13c95708e6dce8ece152ab9833372d;hb=323a9473c0aef80b8e18ef0c53529c8dfc29ec45;hpb=1d4d21dfb5ac43274afc125f132d196ce07f3177 diff --git a/ccan/tdb2/check.c b/ccan/tdb2/check.c index 1b351672..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)++; @@ -512,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; @@ -725,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; } @@ -745,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;