]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb/freelistcheck.c
container_of: don't put member_ptr in container_off.
[ccan] / ccan / tdb / freelistcheck.c
index efc050df9c65f8650bf0631fc394394c19501ac0..5afcaa2a18967094d074b4232d9d1383e05b640c 100644 (file)
@@ -46,8 +46,8 @@ static int seen_insert(struct tdb_context *mem_tdb, tdb_off_t rec_ptr)
 int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries)
 {
        struct tdb_context *mem_tdb = NULL;
-       struct list_struct rec;
-       tdb_off_t rec_ptr, last_ptr;
+       struct tdb_record rec;
+       tdb_off_t rec_ptr;
        int ret = -1;
 
        *pnum_entries = 0;
@@ -63,11 +63,10 @@ int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries)
                return 0;
        }
 
-       last_ptr = FREELIST_TOP;
-
        /* Store the FREELIST_TOP record. */
-       if (seen_insert(mem_tdb, last_ptr) == -1) {
-               ret = TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
+       if (seen_insert(mem_tdb, FREELIST_TOP) == -1) {
+               tdb->ecode = TDB_ERR_CORRUPT;
+               ret = -1;
                goto fail;
        }
 
@@ -83,7 +82,8 @@ int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries)
                   be corrupt. */
 
                if (seen_insert(mem_tdb, rec_ptr)) {
-                       ret = TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
+                       tdb->ecode = TDB_ERR_CORRUPT;
+                       ret = -1;
                        goto fail;
                }
 
@@ -92,7 +92,6 @@ int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries)
                }
 
                /* move to the next record */
-               last_ptr = rec_ptr;
                rec_ptr = rec.next;
                *pnum_entries += 1;
        }