for consistency and better error propagation
Autobuild-User: Michael Adam <obnox@samba.org>
Autobuild-Date: Tue Oct 11 15:51:00 CEST 2011 on sn-devel-104
int32_t v);
NTSTATUS dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
uint32_t *val);
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);
+NTSTATUS 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);
NTSTATUS dbwrap_trans_change_uint32_atomic(struct db_context *db,
NTSTATUS dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
uint32_t *oldval, uint32_t change_val);
NTSTATUS dbwrap_trans_change_uint32_atomic(struct db_context *db,
-int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v)
+NTSTATUS dbwrap_store_uint32(struct db_context *db, const char *keystr,
+ uint32_t v)
{
struct db_record *rec;
uint32 v_store;
{
struct db_record *rec;
uint32 v_store;
rec = dbwrap_fetch_locked(db, NULL, string_term_tdb_data(keystr));
if (rec == NULL) {
rec = dbwrap_fetch_locked(db, NULL, string_term_tdb_data(keystr));
if (rec == NULL) {
+ return NT_STATUS_INVALID_PARAMETER;
sizeof(v_store)),
TDB_REPLACE);
TALLOC_FREE(rec);
sizeof(v_store)),
TDB_REPLACE);
TALLOC_FREE(rec);
- return NT_STATUS_IS_OK(status) ? 0 : -1;
}
if (version != DATABASE_VERSION) {
}
if (version != DATABASE_VERSION) {
- if (dbwrap_store_uint32(db, vstring, DATABASE_VERSION) != 0) {
- DEBUG(0, ("dbwrap_store_uint32 failed\n"));
+ status = dbwrap_store_uint32(db, vstring, DATABASE_VERSION);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("dbwrap_store_uint32 failed: %s\n",
+ nt_errstr(status)));
- if (dbwrap_store_uint32(db, NEXT_RID_STRING, rid) != 0) {
+ status = dbwrap_store_uint32(db, NEXT_RID_STRING, rid);
+ if (!NT_STATUS_IS_OK(status)) {
static NTSTATUS idmap_tdb_init_hwm(struct idmap_domain *dom)
{
static NTSTATUS idmap_tdb_init_hwm(struct idmap_domain *dom)
{
uint32_t low_uid;
uint32_t low_gid;
bool update_uid = false;
uint32_t low_uid;
uint32_t low_gid;
bool update_uid = false;
- ret = dbwrap_store_uint32(ctx->db, HWM_USER, dom->low_id);
- if (ret == -1) {
+ status = dbwrap_store_uint32(ctx->db, HWM_USER, dom->low_id);
+ if (!NT_STATUS_IS_OK(status)) {
dbwrap_transaction_cancel(ctx->db);
DEBUG(0, ("Unable to initialise user hwm in idmap "
dbwrap_transaction_cancel(ctx->db);
DEBUG(0, ("Unable to initialise user hwm in idmap "
+ "database: %s\n", nt_errstr(status)));
return NT_STATUS_INTERNAL_DB_ERROR;
}
}
if (update_gid) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
}
if (update_gid) {
- ret = dbwrap_store_uint32(ctx->db, HWM_GROUP, dom->low_id);
- if (ret == -1) {
+ status = dbwrap_store_uint32(ctx->db, HWM_GROUP, dom->low_id);
+ if (!NT_STATUS_IS_OK(status)) {
dbwrap_transaction_cancel(ctx->db);
DEBUG(0, ("Unable to initialise group hwm in idmap "
dbwrap_transaction_cancel(ctx->db);
DEBUG(0, ("Unable to initialise group hwm in idmap "
+ "database: %s\n", nt_errstr(status)));
return NT_STATUS_INTERNAL_DB_ERROR;
}
}
return NT_STATUS_INTERNAL_DB_ERROR;
}
}