summaryrefslogtreecommitdiff
path: root/source3/lib/dbwrap
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-10-06 21:07:27 +0200
committerMichael Adam <obnox@samba.org>2011-10-11 14:17:58 +0200
commit658f72128ff6950c6a03994198b4464a273fb300 (patch)
tree121d3cdd05b0cf84ef0eb2361c4aff21d24f5b46 /source3/lib/dbwrap
parent603c3e1bcb7b4106afe4aefdfed43e7832ede956 (diff)
downloadsamba-658f72128ff6950c6a03994198b4464a273fb300.tar.gz
samba-658f72128ff6950c6a03994198b4464a273fb300.tar.bz2
samba-658f72128ff6950c6a03994198b4464a273fb300.zip
s3:dbwrap: change dbwrap_fetch_uint32() to NTSTATUS return type (instead of bool)
for consistency and better error propagation
Diffstat (limited to 'source3/lib/dbwrap')
-rw-r--r--source3/lib/dbwrap/dbwrap.h4
-rw-r--r--source3/lib/dbwrap/dbwrap_util.c14
2 files changed, 11 insertions, 7 deletions
diff --git a/source3/lib/dbwrap/dbwrap.h b/source3/lib/dbwrap/dbwrap.h
index a549c84d8e..423791660c 100644
--- a/source3/lib/dbwrap/dbwrap.h
+++ b/source3/lib/dbwrap/dbwrap.h
@@ -73,8 +73,8 @@ NTSTATUS dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx,
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);
+NTSTATUS dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
+ uint32_t *val);
int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v);
NTSTATUS dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
uint32_t *oldval, uint32_t change_val);
diff --git a/source3/lib/dbwrap/dbwrap_util.c b/source3/lib/dbwrap/dbwrap_util.c
index 5c3940e97b..bd29460f49 100644
--- a/source3/lib/dbwrap/dbwrap_util.c
+++ b/source3/lib/dbwrap/dbwrap_util.c
@@ -72,25 +72,29 @@ int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v)
return NT_STATUS_IS_OK(status) ? 0 : -1;
}
-bool dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
- uint32_t *val)
+NTSTATUS dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
+ uint32_t *val)
{
TDB_DATA dbuf;
NTSTATUS status;
+ if (val == NULL) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
status = dbwrap_fetch_bystring(db, NULL, keystr, &dbuf);
if (!NT_STATUS_IS_OK(status)) {
- return false;
+ return status;
}
if ((dbuf.dptr == NULL) || (dbuf.dsize != sizeof(uint32_t))) {
TALLOC_FREE(dbuf.dptr);
- return false;
+ return NT_STATUS_NOT_FOUND;
}
*val = IVAL(dbuf.dptr, 0);
TALLOC_FREE(dbuf.dptr);
- return true;
+ return NT_STATUS_OK;
}
int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v)