mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
tdb_traverse/tdb_traverse_read: check returns for negative, not -1.
TDB2 returns a negative error number on failure. This is compatible if we always check for < 0 instead of == -1. Also, there's no tdb_traverse_read in TDB2: we don't try to make traverse reliable any more, so there are no write locks anyway. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
9850f25633
commit
5a7874e119
@ -960,7 +960,7 @@ static bool mapping_switch(const char *ldb_path)
|
||||
/* ldb is just a very fancy tdb, read out raw data and perform
|
||||
* conversion */
|
||||
ret = tdb_traverse(ltdb, convert_ldb_record, NULL);
|
||||
if (ret == -1) goto failed;
|
||||
if (ret < 0) goto failed;
|
||||
|
||||
if (ltdb) {
|
||||
tdb_close(ltdb);
|
||||
|
@ -433,7 +433,7 @@ static NTSTATUS dbwrap_trans_traverse_action(struct db_context* db, void* privat
|
||||
|
||||
int ret = db->traverse(db, ctx->f, ctx->private_data);
|
||||
|
||||
return (ret == -1) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK;
|
||||
return (ret < 0) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS dbwrap_trans_traverse(struct db_context *db,
|
||||
@ -452,7 +452,7 @@ NTSTATUS dbwrap_traverse(struct db_context *db,
|
||||
void *private_data)
|
||||
{
|
||||
int ret = db->traverse(db, f, private_data);
|
||||
return (ret == -1) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK;
|
||||
return (ret < 0) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -488,7 +488,7 @@ bool gencache_stabilize(void)
|
||||
state.written = false;
|
||||
|
||||
res = tdb_traverse(cache_notrans, stabilize_fn, &state);
|
||||
if ((res == -1) || state.error) {
|
||||
if ((res < 0) || state.error) {
|
||||
tdb_transaction_cancel(cache_notrans);
|
||||
tdb_transaction_cancel(cache);
|
||||
return false;
|
||||
|
@ -71,7 +71,7 @@ static int tdb_validate_child(struct tdb_context *tdb,
|
||||
num_entries = tdb_traverse(tdb, validate_fn, (void *)&v_status);
|
||||
if (!v_status.success) {
|
||||
goto out;
|
||||
} else if (num_entries == -1) {
|
||||
} else if (num_entries < 0) {
|
||||
v_status.tdb_error = True;
|
||||
v_status.success = False;
|
||||
goto out;
|
||||
|
@ -266,7 +266,7 @@ static bool upgrade_to_version_4(void)
|
||||
|
||||
talloc_destroy( ctx );
|
||||
|
||||
return ( result != -1 );
|
||||
return ( result >= 0 );
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -334,7 +334,7 @@ static bool upgrade_to_version_5(void)
|
||||
|
||||
talloc_destroy( ctx );
|
||||
|
||||
return ( result != -1 );
|
||||
return ( result >= 0 );
|
||||
}
|
||||
|
||||
bool nt_printing_tdb_upgrade(void)
|
||||
|
@ -482,7 +482,7 @@ static WERROR regdb_upgrade_v1_to_v2(void)
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
if (rc == -1) {
|
||||
if (rc < 0) {
|
||||
return WERR_REG_IO_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ static WERROR net_enum_pipes(TALLOC_CTX *ctx,
|
||||
fenum.username = username;
|
||||
fenum.ctr3 = *ctr3;
|
||||
|
||||
if (connections_traverse(pipe_enum_fn, &fenum) == -1) {
|
||||
if (connections_traverse(pipe_enum_fn, &fenum) < 0) {
|
||||
DEBUG(0,("net_enum_pipes: traverse of connections.tdb "
|
||||
"failed\n"));
|
||||
return WERR_NOMEM;
|
||||
|
@ -120,7 +120,7 @@ int count_current_connections( const char *sharename, bool clear )
|
||||
ret = connections_forall(count_fn, &cs);
|
||||
unbecome_root();
|
||||
|
||||
if (ret == -1) {
|
||||
if (ret < 0) {
|
||||
DEBUG(0,("count_current_connections: traverse of "
|
||||
"connections.tdb failed\n"));
|
||||
return 0;
|
||||
|
@ -264,7 +264,7 @@ int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list)
|
||||
sesslist.sessions = NULL;
|
||||
|
||||
ret = sessionid_traverse_read(gather_sessioninfo, (void *) &sesslist);
|
||||
if (ret == -1) {
|
||||
if (ret < 0) {
|
||||
DEBUG(3, ("Session traverse failed\n"));
|
||||
SAFE_FREE(sesslist.sessions);
|
||||
*session_list = NULL;
|
||||
|
@ -175,7 +175,7 @@ done:
|
||||
TALLOC_FREE(g_ctx);
|
||||
TALLOC_FREE(msg);
|
||||
TALLOC_FREE(ev);
|
||||
return ret;
|
||||
return ret < 0 ? -1 : ret;
|
||||
}
|
||||
|
||||
int net_g_lock(struct net_context *c, int argc, const char **argv)
|
||||
|
@ -37,7 +37,7 @@ static int net_serverid_list(struct net_context *c, int argc,
|
||||
const char **argv)
|
||||
{
|
||||
d_printf("pid unique_id msg_flags\n");
|
||||
return serverid_traverse_read(net_serverid_list_fn, NULL) ? 0 : -1;
|
||||
return serverid_traverse_read(net_serverid_list_fn, NULL) > 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
static int net_serverid_wipe_fn(struct db_record *rec,
|
||||
@ -62,7 +62,7 @@ static int net_serverid_wipe_fn(struct db_record *rec,
|
||||
static int net_serverid_wipe(struct net_context *c, int argc,
|
||||
const char **argv)
|
||||
{
|
||||
return serverid_traverse(net_serverid_wipe_fn, NULL) ? 0 : -1;
|
||||
return serverid_traverse(net_serverid_wipe_fn, NULL) > 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
static int net_serverid_wipedbs_conn(
|
||||
|
@ -474,7 +474,7 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
|
||||
|
||||
if (result == 0) {
|
||||
d_printf("No locked files\n");
|
||||
} else if (result == -1) {
|
||||
} else if (result < 0) {
|
||||
d_printf("locked file list truncated\n");
|
||||
}
|
||||
|
||||
|
@ -3383,7 +3383,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const
|
||||
ret = tdb_traverse(cache->tdb, traverse_fn_get_credlist, NULL);
|
||||
if (ret == 0) {
|
||||
return NT_STATUS_OK;
|
||||
} else if ((ret == -1) || (wcache_cred_list == NULL)) {
|
||||
} else if ((ret < 0) || (wcache_cred_list == NULL)) {
|
||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ int ltdb_reindex(struct ldb_module *module)
|
||||
* putting NULL entries in the in-memory tdb
|
||||
*/
|
||||
ret = tdb_traverse(ltdb->tdb, delete_index, module);
|
||||
if (ret == -1) {
|
||||
if (ret < 0) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
@ -1583,7 +1583,7 @@ int ltdb_reindex(struct ldb_module *module)
|
||||
|
||||
/* now traverse adding any indexes for normal LDB records */
|
||||
ret = tdb_traverse(ltdb->tdb, re_index, &ctx);
|
||||
if (ret == -1) {
|
||||
if (ret < 0) {
|
||||
struct ldb_context *ldb = ldb_module_get_ctx(module);
|
||||
ldb_asprintf_errstring(ldb, "reindexing traverse failed: %s", ldb_errstring(ldb));
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
|
@ -480,7 +480,7 @@ static int ltdb_search_full(struct ltdb_context *ctx)
|
||||
ret = tdb_traverse_read(ltdb->tdb, search_func, ctx);
|
||||
}
|
||||
|
||||
if (ret == -1) {
|
||||
if (ret < 0) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user