diff options
author | Michael Adam <obnox@samba.org> | 2011-10-06 20:34:55 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-10-11 14:17:58 +0200 |
commit | 603c3e1bcb7b4106afe4aefdfed43e7832ede956 (patch) | |
tree | 3bbd74811e5a62786975aada7399931db36d1549 /source3/lib/dbwrap | |
parent | ce8626cbbe99b26f4e39ace87221792b468b9c93 (diff) | |
download | samba-603c3e1bcb7b4106afe4aefdfed43e7832ede956.tar.gz samba-603c3e1bcb7b4106afe4aefdfed43e7832ede956.tar.bz2 samba-603c3e1bcb7b4106afe4aefdfed43e7832ede956.zip |
s3:dbwrap: convert dbwrap_fetch_int32() to NTSTATUS return code
Return the int32 value retrieved from the db by reference.
Before this, return value "-1" was used as a error indication,
but it could also be a valid value from the database.
Diffstat (limited to 'source3/lib/dbwrap')
-rw-r--r-- | source3/lib/dbwrap/dbwrap.h | 3 | ||||
-rw-r--r-- | source3/lib/dbwrap/dbwrap_util.c | 16 |
2 files changed, 12 insertions, 7 deletions
diff --git a/source3/lib/dbwrap/dbwrap.h b/source3/lib/dbwrap/dbwrap.h index 13565f8b33..a549c84d8e 100644 --- a/source3/lib/dbwrap/dbwrap.h +++ b/source3/lib/dbwrap/dbwrap.h @@ -70,7 +70,8 @@ NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, NTSTATUS dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, const char *key, TDB_DATA *value); -int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr); +NTSTATUS dbwrap_fetch_int32(struct db_context *db, const char *keystr, + int32_t *result); int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v); bool dbwrap_fetch_uint32(struct db_context *db, const char *keystr, uint32_t *val); diff --git a/source3/lib/dbwrap/dbwrap_util.c b/source3/lib/dbwrap/dbwrap_util.c index 59985479af..5c3940e97b 100644 --- a/source3/lib/dbwrap/dbwrap_util.c +++ b/source3/lib/dbwrap/dbwrap_util.c @@ -26,25 +26,29 @@ #include "dbwrap.h" #include "util_tdb.h" -int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr) +NTSTATUS dbwrap_fetch_int32(struct db_context *db, const char *keystr, + int32_t *result) { TDB_DATA dbuf; - int32 ret; NTSTATUS status; + if (result == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + status = dbwrap_fetch_bystring(db, NULL, keystr, &dbuf); if (!NT_STATUS_IS_OK(status)) { - return -1; + return status; } if ((dbuf.dptr == NULL) || (dbuf.dsize != sizeof(int32_t))) { TALLOC_FREE(dbuf.dptr); - return -1; + return NT_STATUS_NOT_FOUND; } - ret = IVAL(dbuf.dptr, 0); + *result = IVAL(dbuf.dptr, 0); TALLOC_FREE(dbuf.dptr); - return ret; + return NT_STATUS_OK; } int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v) |