tdb2: fix prototype in tdb1 code.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 26 Mar 2012 04:03:17 +0000 (14:33 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 29 Mar 2012 04:44:30 +0000 (15:14 +1030)
We were handing an int-returning function where we should hand an enum TDB_ERROR
returning function.  Worse, it was returning 0/-1 instead of 0/TDB_ERR_*.

Fortunately, it's only compared against success, but the Solaris compiler
warns about it, and it's not correct anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/tdb2/tdb1_tdb.c

index 869672a5780aac73f26b78885daa1e40aefde4e5..ae633ed77b0c78f199b33634fbbe78b53b69c5e6 100644 (file)
@@ -146,17 +146,17 @@ tdb1_off_t tdb1_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t h
 
 static TDB_DATA _tdb1_fetch(struct tdb_context *tdb, TDB_DATA key);
 
-static int tdb_update_hash_cmp(TDB_DATA key, TDB_DATA data, void *private_data)
+static enum TDB_ERROR tdb_update_hash_cmp(TDB_DATA key, TDB_DATA data, void *private_data)
 {
        TDB_DATA *dbuf = (TDB_DATA *)private_data;
 
        if (dbuf->dsize != data.dsize) {
-               return -1;
+               return TDB_ERR_EINVAL;
        }
        if (memcmp(dbuf->dptr, data.dptr, data.dsize) != 0) {
-               return -1;
+               return TDB_ERR_EINVAL;
        }
-       return 0;
+       return TDB_SUCCESS;
 }
 
 /* update an entry in place - this only works if the new data size
@@ -177,7 +177,7 @@ static int tdb1_update_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash
        if (rec.key_len == key.dsize &&
            rec.data_len == dbuf.dsize &&
            rec.full_hash == hash &&
-           tdb1_parse_record(tdb, key, tdb_update_hash_cmp, &dbuf) == 0) {
+           tdb1_parse_record(tdb, key, tdb_update_hash_cmp, &dbuf) == TDB_SUCCESS) {
                        return 0;
        }