diff options
author | Michael Adam <obnox@samba.org> | 2011-11-11 00:49:11 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-11-29 18:20:06 +0100 |
commit | efb993b686e397e06ba647089535c92ec08c4345 (patch) | |
tree | 470e5e6cd40991409f66e8ddcdac88cfce68fceb /source3/lib/dbwrap/dbwrap.c | |
parent | 819ca3b697e1b396b83308341cf81c19362c2626 (diff) | |
download | samba-efb993b686e397e06ba647089535c92ec08c4345.tar.gz samba-efb993b686e397e06ba647089535c92ec08c4345.tar.bz2 samba-efb993b686e397e06ba647089535c92ec08c4345.zip |
s3:dbwrap: turn the fetch dbwrap method to NTSTATUS return code.
This implement more correct NTSTATUS handling inside the backends.
This ensures that data.dptr != NULL if return code is NT_STATUS_OK.
Diffstat (limited to 'source3/lib/dbwrap/dbwrap.c')
-rw-r--r-- | source3/lib/dbwrap/dbwrap.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/source3/lib/dbwrap/dbwrap.c b/source3/lib/dbwrap/dbwrap.c index 38404a876c..cdc46c328f 100644 --- a/source3/lib/dbwrap/dbwrap.c +++ b/source3/lib/dbwrap/dbwrap.c @@ -28,19 +28,20 @@ * Fall back using fetch_locked if no genuine fetch operation is provided */ -int dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, - TDB_DATA key, TDB_DATA *data) +NTSTATUS dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, + TDB_DATA key, TDB_DATA *data) { struct db_record *rec; - if (!(rec = db->fetch_locked(db, mem_ctx, key))) { - return -1; + rec = db->fetch_locked(db, mem_ctx, key); + if (rec == NULL) { + return NT_STATUS_UNSUCCESSFUL; } data->dsize = rec->value.dsize; data->dptr = talloc_move(mem_ctx, &rec->value.dptr); TALLOC_FREE(rec); - return 0; + return NT_STATUS_OK; } /* @@ -65,9 +66,10 @@ int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key, { TDB_DATA data; int res; + NTSTATUS status; - res = db->fetch(db, talloc_tos(), key, &data); - if (res != 0) { + status = db->fetch(db, talloc_tos(), key, &data); + if (!NT_STATUS_IS_OK(status)) { return -1; } @@ -137,11 +139,7 @@ NTSTATUS dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - if (db->fetch(db, mem_ctx, key, value) != 0) { - return NT_STATUS_NOT_FOUND; - } - - return NT_STATUS_OK; + return db->fetch(db, mem_ctx, key, value); } bool dbwrap_exists(struct db_context *db, TDB_DATA key) |