diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-10-22 00:09:43 +1030 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-10-22 00:09:43 +1030 |
commit | b77f41d58b05101e02d8ac0e54cb0e30807d89c2 (patch) | |
tree | 9ec20b8f8959ddd0e9338cd5d71e4a31b61fbc41 /lib/tdb/common/tdb.c | |
parent | 703004340c3e0f43f741bd368d2525cfd187d590 (diff) | |
download | samba-b77f41d58b05101e02d8ac0e54cb0e30807d89c2.tar.gz samba-b77f41d58b05101e02d8ac0e54cb0e30807d89c2.tar.bz2 samba-b77f41d58b05101e02d8ac0e54cb0e30807d89c2.zip |
lib/tdb: wean off TDB_ERRCODE.
It was a regrettable hack which I used to reduce line count in tdb; in fact it caused confusion as can be seen in this patch.
In particular, ecode now needs to be set before TDB_LOG anyway, and having it exposed in
the header is useless (the struct tdb_context isn't defined, so it's doubly useless).
Also, we should never set errno, as io.c was doing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb/common/tdb.c')
-rw-r--r-- | lib/tdb/common/tdb.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c index 7acc111cd8..7ee0bb7300 100644 --- a/lib/tdb/common/tdb.c +++ b/lib/tdb/common/tdb.c @@ -98,12 +98,14 @@ static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, } /* detect tight infinite loop */ if (rec_ptr == r->next) { + tdb->ecode = TDB_ERR_CORRUPT; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_find: loop detected.\n")); - return TDB_ERRCODE(TDB_ERR_CORRUPT, 0); + return 0; } rec_ptr = r->next; } - return TDB_ERRCODE(TDB_ERR_NOEXIST, 0); + tdb->ecode = TDB_ERR_NOEXIST; + return 0; } /* As tdb_find, but if you succeed, keep the lock */ @@ -216,7 +218,8 @@ int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key, if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec))) { tdb_trace_1rec_ret(tdb, "tdb_parse_record", key, -1); - return TDB_ERRCODE(TDB_ERR_NOEXIST, 0); + tdb->ecode = TDB_ERR_NOEXIST; + return 0; } tdb_trace_1rec_ret(tdb, "tdb_parse_record", key, 0); |