diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 08:13:27 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 08:13:27 +0930 |
commit | 2237daed7e4c6c38241bc07383ed1a421abe8d6c (patch) | |
tree | 11495936fbf2306d4e443bdf529ed71ff8e9f23a /lib/tdb2/check.c | |
parent | 45467c0118da0c1d4e5644f4570f10aafe37a8a7 (diff) | |
download | samba-2237daed7e4c6c38241bc07383ed1a421abe8d6c.tar.gz samba-2237daed7e4c6c38241bc07383ed1a421abe8d6c.tar.bz2 samba-2237daed7e4c6c38241bc07383ed1a421abe8d6c.zip |
tdb2: add error conversion functions.
This clarifies the code a little, but also provides a more explicit
mechanism which can be used to debug error handling (by introducing
tdb_err_t and making it a pointer type).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit afa6d57b7d93fe4675a952f556eb462951baa257)
Diffstat (limited to 'lib/tdb2/check.c')
-rw-r--r-- | lib/tdb2/check.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/tdb2/check.c b/lib/tdb2/check.c index b3874c6d27..8a89422b48 100644 --- a/lib/tdb2/check.c +++ b/lib/tdb2/check.c @@ -148,7 +148,7 @@ static enum TDB_ERROR check_hash_chain(struct tdb_context *tdb, off = tdb_read_off(tdb, off + offsetof(struct tdb_chain, next)); if (TDB_OFF_IS_ERR(off)) { - return off; + return TDB_OFF_TO_ERR(off); } if (off == 0) return TDB_SUCCESS; @@ -534,7 +534,7 @@ static enum TDB_ERROR 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 (TDB_OFF_IS_ERR(off)) { - return off; + return TDB_OFF_TO_ERR(off); } if (!first) { off &= TDB_OFF_MASK; @@ -589,7 +589,7 @@ tdb_off_t dead_space(struct tdb_context *tdb, tdb_off_t off) char c; ecode = tdb->tdb2.io->tread(tdb, off, &c, 1); if (ecode != TDB_SUCCESS) { - return ecode; + return TDB_ERR_TO_OFF(ecode); } if (c != 0 && c != 0x43) break; @@ -634,7 +634,7 @@ static enum TDB_ERROR check_linear(struct tdb_context *tdb, } else { len = dead_space(tdb, off); if (TDB_OFF_IS_ERR(len)) { - return len; + return TDB_OFF_TO_ERR(len); } if (len < sizeof(rec.r)) { return tdb_logerr(tdb, TDB_ERR_CORRUPT, @@ -811,7 +811,7 @@ enum TDB_ERROR tdb_check_(struct tdb_context *tdb, for (ft = first_ftable(tdb); ft; ft = next_ftable(tdb, ft)) { if (TDB_OFF_IS_ERR(ft)) { - ecode = ft; + ecode = TDB_OFF_TO_ERR(ft); goto out; } ecode = check_free_table(tdb, ft, num_ftables, fr, num_free, |