]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/check.c
tdb2: make tdb_check typesafe.
[ccan] / ccan / tdb2 / check.c
index de1cb98b8ce1c8c4ac52f49ce754ca8d82a6c40c..9bbd12645f199ba6a5a62708caccc79d08cf16d1 100644 (file)
@@ -131,7 +131,7 @@ static enum TDB_ERROR check_hash_chain(struct tdb_context *tdb,
        ecode = check_hash_tree(tdb, off, 0, hash, 64,
                                used, num_used, num_found, check, private_data);
        if (ecode != TDB_SUCCESS) {
-               return false;
+               return ecode;
        }
 
        off = tdb_read_off(tdb, off + offsetof(struct tdb_chain, next));
@@ -526,7 +526,7 @@ static enum TDB_ERROR check_free_table(struct tdb_context *tdb,
                        }
                        ecode = check_free(tdb, off, &f, prev, ftable_num, i);
                        if (ecode != TDB_SUCCESS) {
-                               return false;
+                               return ecode;
                        }
 
                        /* FIXME: Check hash bits */
@@ -717,10 +717,10 @@ static enum TDB_ERROR check_linear(struct tdb_context *tdb,
        return TDB_SUCCESS;
 }
 
-enum TDB_ERROR tdb_check(struct tdb_context *tdb,
-                        enum TDB_ERROR (*check)(TDB_DATA key, TDB_DATA data,
-                                                void *private_data),
-                        void *private_data)
+enum TDB_ERROR tdb_check_(struct tdb_context *tdb,
+                         enum TDB_ERROR (*check)(TDB_DATA key, TDB_DATA data,
+                                                 void *private),
+                         void *private)
 {
        tdb_off_t *fr = NULL, *used = NULL, ft, recovery;
        size_t num_free = 0, num_used = 0, num_found = 0, num_ftables = 0;
@@ -759,8 +759,7 @@ enum TDB_ERROR tdb_check(struct tdb_context *tdb,
        }
 
        /* FIXME: Check key uniqueness? */
-       ecode = check_hash(tdb, used, num_used, num_ftables, check,
-                          private_data);
+       ecode = check_hash(tdb, used, num_used, num_ftables, check, private);
        if (ecode != TDB_SUCCESS)
                goto out;