summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-06-20 18:40:33 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-06-20 11:18:35 +0200
commitd925b327f4703cc141c0a7f3eec912dba8440880 (patch)
treea9d190b375dcae03863591d8f31688dc949fa3eb /source3/lib
parentca1936fbb26af0ee8d0421ae6a4e07a0f62311d9 (diff)
downloadsamba-d925b327f4703cc141c0a7f3eec912dba8440880.tar.gz
samba-d925b327f4703cc141c0a7f3eec912dba8440880.tar.bz2
samba-d925b327f4703cc141c0a7f3eec912dba8440880.zip
tdb_compat: Higher level API fixes.
My previous patches fixed up all direct TDB callers, but there are a few utility functions and the db_context functions which are still using the old -1 / 0 return codes. It's clearer to fix up all the callers of these too, so everywhere is consistent: non-zero means an error. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap_tdb.c4
-rw-r--r--source3/lib/dbwrap_util.c2
-rw-r--r--source3/lib/eventlog/eventlog.c2
-rw-r--r--source3/lib/server_mutex.c2
-rw-r--r--source3/lib/serverid.c2
-rw-r--r--source3/lib/tdb_validate.c2
-rw-r--r--source3/lib/util.c2
-rw-r--r--source3/lib/util_tdb.c6
8 files changed, 11 insertions, 11 deletions
diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c
index 2b5f58a56d..2efb3dfe39 100644
--- a/source3/lib/dbwrap_tdb.c
+++ b/source3/lib/dbwrap_tdb.c
@@ -183,7 +183,7 @@ static int db_tdb_parse(struct db_context *db, TDB_DATA key,
struct db_tdb_ctx *ctx = talloc_get_type_abort(
db->private_data, struct db_tdb_ctx);
- return tdb_parse_record(ctx->wtdb->tdb, key, parser, private_data) ? -1 : 0;
+ return tdb_parse_record(ctx->wtdb->tdb, key, parser, private_data);
}
static NTSTATUS db_tdb_store(struct db_record *rec, TDB_DATA data, int flag)
@@ -320,7 +320,7 @@ static int db_tdb_transaction_commit(struct db_context *db)
{
struct db_tdb_ctx *db_ctx =
talloc_get_type_abort(db->private_data, struct db_tdb_ctx);
- return tdb_transaction_commit(db_ctx->wtdb->tdb) == 0 ? 0 : -1;
+ return tdb_transaction_commit(db_ctx->wtdb->tdb);
}
static int db_tdb_transaction_cancel(struct db_context *db)
diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c
index 44a1b8827b..effcf40c6b 100644
--- a/source3/lib/dbwrap_util.c
+++ b/source3/lib/dbwrap_util.c
@@ -492,7 +492,7 @@ TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
{
TDB_DATA result;
- if (db->fetch(db, mem_ctx, key, &result) == -1) {
+ if (db->fetch(db, mem_ctx, key, &result) != 0) {
return make_tdb_data(NULL, 0);
}
diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c
index c29c6f0ed4..67583b8666 100644
--- a/source3/lib/eventlog/eventlog.c
+++ b/source3/lib/eventlog/eventlog.c
@@ -781,7 +781,7 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx,
/* lock */
ret = tdb_lock_bystring_with_timeout(tdb, EVT_NEXT_RECORD, 1);
- if (ret == -1) {
+ if (ret != 0) {
return NT_STATUS_LOCK_NOT_GRANTED;
}
diff --git a/source3/lib/server_mutex.c b/source3/lib/server_mutex.c
index 6eac3182be..dc65819197 100644
--- a/source3/lib/server_mutex.c
+++ b/source3/lib/server_mutex.c
@@ -70,7 +70,7 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
}
if (tdb_lock_bystring_with_timeout(result->tdb->tdb, name,
- timeout) == -1) {
+ timeout) != 0) {
DEBUG(1, ("Could not get the lock for %s\n", name));
TALLOC_FREE(result);
return NULL;
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index e63818e1b8..1a1141265a 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -250,7 +250,7 @@ bool serverid_exists(const struct server_id *id)
state.id = id;
state.exists = false;
- if (db->parse_record(db, tdbkey, server_exists_parse, &state) == -1) {
+ if (db->parse_record(db, tdbkey, server_exists_parse, &state) != 0) {
return false;
}
return state.exists;
diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c
index 617160ee86..385f4d0ef8 100644
--- a/source3/lib/tdb_validate.c
+++ b/source3/lib/tdb_validate.c
@@ -51,7 +51,7 @@ static int tdb_validate_child(struct tdb_context *tdb,
* but I don't want to change all the callers...
*/
ret = tdb_check(tdb, NULL, NULL);
- if (ret == -1) {
+ if (ret != 0) {
v_status.tdb_error = True;
v_status.success = False;
goto out;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index b25c15c7a3..b8fc319a6f 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -406,7 +406,7 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
set_need_random_reseed();
/* tdb needs special fork handling */
- if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) {
+ if (tdb_reopen_all(parent_longlived ? 1 : 0) != 0) {
DEBUG(0,("tdb_reopen_all failed.\n"));
status = NT_STATUS_OPEN_FAILED;
goto done;
diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c
index 2d49b9e2ec..4756fd84ef 100644
--- a/source3/lib/util_tdb.c
+++ b/source3/lib/util_tdb.c
@@ -67,7 +67,7 @@ static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key,
alarm(0);
tdb_setalarm_sigptr(tdb, NULL);
CatchSignal(SIGALRM, SIG_IGN);
- if (gotalarm && (ret == -1)) {
+ if (gotalarm && (ret != 0)) {
DEBUG(0,("tdb_chainlock_with_timeout_internal: alarm (%u) timed out for key %s in tdb %s\n",
timeout, key.dptr, tdb_name(tdb)));
/* TODO: If we time out waiting for a lock, it might
@@ -82,7 +82,7 @@ static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key,
}
/****************************************************************************
- Write lock a chain. Return -1 if timeout or lock failed.
+ Write lock a chain. Return non-zero if timeout or lock failed.
****************************************************************************/
int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout)
@@ -99,7 +99,7 @@ int tdb_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval,
}
/****************************************************************************
- Read lock a chain by string. Return -1 if timeout or lock failed.
+ Read lock a chain by string. Return non-zero if timeout or lock failed.
****************************************************************************/
int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout)