tdb_delete: check returns for 0, not -1.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 20 Jun 2011 09:10:31 +0000 (18:40 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 20 Jun 2011 09:18:35 +0000 (11:18 +0200)
TDB2 returns a negative error number on failure.  This is compatible
if we always check for != 0 instead of == -1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/util/util_tdb.h
source3/lib/gencache.c
source3/libsmb/smb_share_modes.c
source3/winbindd/winbindd_cache.c
source4/ntvfs/posix/xattr_tdb.c

index c563f0d4b65eac188bd4eedddf37f0f73825b254..92b88bacb4b3e5ee050a79e7835c6153a3736c34 100644 (file)
@@ -111,7 +111,7 @@ int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA dat
 TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr);
 
 /****************************************************************************
- Delete an entry using a null terminated string key. 
+ Delete an entry using a null terminated string key.  0 on success, -ve on err.
 ****************************************************************************/
 int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr);
 
index 5e1547282972d8e7d79b82c1711e26651b4db60f..5c9c1a296af956542fb48de3e4ed8cb5b4313cd9 100644 (file)
@@ -548,7 +548,7 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val,
        }
        if ((timeout < time(NULL)) || (val.dsize == 0)) {
                res = tdb_delete(cache, key);
-               if ((res == -1) && (tdb_error(cache) == TDB_ERR_NOEXIST)) {
+               if ((res != 0) && (tdb_error(cache) == TDB_ERR_NOEXIST)) {
                        res = 0;
                } else {
                        state->written = true;
@@ -560,14 +560,14 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val,
                }
        }
 
-       if (res == -1) {
+       if (res != 0) {
                DEBUG(10, ("Transfer to gencache.tdb failed: %s\n",
                           tdb_errorstr(cache)));
                state->error = true;
                return -1;
        }
 
-       if (tdb_delete(cache_notrans, key) == -1) {
+       if (tdb_delete(cache_notrans, key) != 0) {
                DEBUG(10, ("tdb_delete from gencache_notrans.tdb failed: "
                           "%s\n", tdb_errorstr(cache_notrans)));
                state->error = true;
index 2bf430dfea58f7c705b581976dc89e44b17deafd..4477da6a19cc067c60f903f04a066b80cdf791d1 100644 (file)
@@ -450,7 +450,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
                }
                /* It's ours - just remove the entire record. */
                free(db_data.dptr);
-               return tdb_delete(db_ctx->smb_tdb, locking_key);
+               return tdb_delete(db_ctx->smb_tdb, locking_key) ? -1 : 0;
        }
 
        /* More than one - allocate a new record minus the one we'll delete. */
@@ -489,7 +489,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
                /* None left after pruning. Delete record. */
                free(db_data.dptr);
                free(new_data_p);
-               return tdb_delete(db_ctx->smb_tdb, locking_key);
+               return tdb_delete(db_ctx->smb_tdb, locking_key) ? -1 : 0;
        }
 
        /* Copy any delete tokens plus the terminating filenames. */
index daea4e866a66d40560b97f2de61e088aac8940d1..c45aabc90263b67735e63dbf37e388cb1fbad984 100644 (file)
@@ -4420,7 +4420,7 @@ static bool wcache_tdc_store_list( struct winbindd_tdc_domain *domains, size_t n
        SAFE_FREE( data.dptr );
        SAFE_FREE( key.dptr );
 
-       return ( ret != -1 );   
+       return ( ret == 0 );
 }
 
 /*********************************************************************
index c325561562df784731d57c5860a68ff7fb9c44eb..44aced9beed6d504b23f1b42f1a21af87c320efc 100644 (file)
@@ -218,7 +218,7 @@ NTSTATUS delete_xattr_tdb(struct pvfs_state *pvfs, const char *attr_name,
                return status;
        }
        
-       if (tdb_delete(pvfs->ea_db->tdb, tkey) == -1) {
+       if (tdb_delete(pvfs->ea_db->tdb, tkey) != 0) {
                talloc_free(tkey.dptr);
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }