diff options
author | Michael Adam <obnox@samba.org> | 2011-10-06 21:24:07 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-10-11 14:17:58 +0200 |
commit | c9bc1e492404077c6b40b5cefe33e859503a4227 (patch) | |
tree | 8a38bfafafe0af9f8ee912ac87d53e62c4e2134d /source3/lib | |
parent | 658f72128ff6950c6a03994198b4464a273fb300 (diff) | |
download | samba-c9bc1e492404077c6b40b5cefe33e859503a4227.tar.gz samba-c9bc1e492404077c6b40b5cefe33e859503a4227.tar.bz2 samba-c9bc1e492404077c6b40b5cefe33e859503a4227.zip |
s3:dbwrap: change dbwrap_store_int32() to NTSTATUS return type
for consistency and better error propagation
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/dbwrap/dbwrap.h | 3 | ||||
-rw-r--r-- | source3/lib/dbwrap/dbwrap_util.c | 7 | ||||
-rw-r--r-- | source3/lib/sharesec.c | 24 |
3 files changed, 21 insertions, 13 deletions
diff --git a/source3/lib/dbwrap/dbwrap.h b/source3/lib/dbwrap/dbwrap.h index 423791660c..f3e3bfe2d4 100644 --- a/source3/lib/dbwrap/dbwrap.h +++ b/source3/lib/dbwrap/dbwrap.h @@ -72,7 +72,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); +NTSTATUS dbwrap_store_int32(struct db_context *db, const char *keystr, + int32_t v); 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); diff --git a/source3/lib/dbwrap/dbwrap_util.c b/source3/lib/dbwrap/dbwrap_util.c index bd29460f49..31beadb6a2 100644 --- a/source3/lib/dbwrap/dbwrap_util.c +++ b/source3/lib/dbwrap/dbwrap_util.c @@ -51,7 +51,8 @@ NTSTATUS dbwrap_fetch_int32(struct db_context *db, const char *keystr, return NT_STATUS_OK; } -int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v) +NTSTATUS dbwrap_store_int32(struct db_context *db, const char *keystr, + int32_t v) { struct db_record *rec; int32 v_store; @@ -59,7 +60,7 @@ int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v) rec = dbwrap_fetch_locked(db, NULL, string_term_tdb_data(keystr)); if (rec == NULL) { - return -1; + return NT_STATUS_UNSUCCESSFUL; } SIVAL(&v_store, 0, v); @@ -69,7 +70,7 @@ int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v) sizeof(v_store)), TDB_REPLACE); TALLOC_FREE(rec); - return NT_STATUS_IS_OK(status) ? 0 : -1; + return status; } NTSTATUS dbwrap_fetch_uint32(struct db_context *db, const char *keystr, diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c index 9b3d5607fd..2c324cf971 100644 --- a/source3/lib/sharesec.c +++ b/source3/lib/sharesec.c @@ -191,9 +191,11 @@ bool share_info_db_init(void) if ((vers_id == SHARE_DATABASE_VERSION_V1) || (IREV(vers_id) == SHARE_DATABASE_VERSION_V1)) { /* Written on a bigendian machine with old fetch_int code. Save as le. */ - if (dbwrap_store_int32(share_db, vstring, - SHARE_DATABASE_VERSION_V2) != 0) { - DEBUG(0, ("dbwrap_store_int32 failed\n")); + status = dbwrap_store_int32(share_db, vstring, + SHARE_DATABASE_VERSION_V2); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("dbwrap_store_int32 failed: %s\n", + nt_errstr(status))); goto cancel; } vers_id = SHARE_DATABASE_VERSION_V2; @@ -205,9 +207,11 @@ bool share_info_db_init(void) DEBUG(0, ("traverse failed\n")); goto cancel; } - if (dbwrap_store_int32(share_db, vstring, - SHARE_DATABASE_VERSION_V2) != 0) { - DEBUG(0, ("dbwrap_store_int32 failed\n")); + status = dbwrap_store_int32(share_db, vstring, + SHARE_DATABASE_VERSION_V2); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("dbwrap_store_int32 failed: %s\n", + nt_errstr(status))); goto cancel; } } @@ -219,9 +223,11 @@ bool share_info_db_init(void) DEBUG(0, ("traverse failed\n")); goto cancel; } - if (dbwrap_store_int32(share_db, vstring, - SHARE_DATABASE_VERSION_V3) != 0) { - DEBUG(0, ("dbwrap_store_int32 failed\n")); + status = dbwrap_store_int32(share_db, vstring, + SHARE_DATABASE_VERSION_V3); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("dbwrap_store_int32 failed: %s\n", + nt_errstr(status))); goto cancel; } |