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/open.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/open.c')
-rw-r--r-- | lib/tdb2/open.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/tdb2/open.c b/lib/tdb2/open.c index 46e22a324c..18e4cd8bb0 100644 --- a/lib/tdb2/open.c +++ b/lib/tdb2/open.c @@ -706,7 +706,7 @@ finished: berr = tdb_needs_recovery(tdb); if (unlikely(berr != false)) { if (berr < 0) { - ecode = berr; + ecode = TDB_OFF_TO_ERR(berr); goto fail; } ecode = tdb_lock_and_recover(tdb); @@ -727,18 +727,18 @@ finished: fail: /* Map ecode to some logical errno. */ - switch (ecode) { - case TDB_ERR_CORRUPT: - case TDB_ERR_IO: + switch (TDB_ERR_TO_OFF(ecode)) { + case TDB_ERR_TO_OFF(TDB_ERR_CORRUPT): + case TDB_ERR_TO_OFF(TDB_ERR_IO): saved_errno = EIO; break; - case TDB_ERR_LOCK: + case TDB_ERR_TO_OFF(TDB_ERR_LOCK): saved_errno = EWOULDBLOCK; break; - case TDB_ERR_OOM: + case TDB_ERR_TO_OFF(TDB_ERR_OOM): saved_errno = ENOMEM; break; - case TDB_ERR_EINVAL: + case TDB_ERR_TO_OFF(TDB_ERR_EINVAL): saved_errno = EINVAL; break; default: |