]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb/test/run-corrupt.c
strsplit: remove nump argument
[ccan] / ccan / tdb / test / run-corrupt.c
index 067ac861e4913acef1964da692b88fe625d08159..6f753ea6d46c81c9dbd3f9e388c1f3078c98e30e 100644 (file)
@@ -9,6 +9,7 @@
 #include <ccan/tdb/error.c>
 #include <ccan/tdb/open.c>
 #include <ccan/tdb/check.c>
+#include <ccan/tdb/hash.c>
 #include <ccan/tap/tap.h>
 #include <stdlib.h>
 #include <err.h>
@@ -42,9 +43,11 @@ static void tdb_flip_bit(struct tdb_context *tdb, unsigned int bit)
                ((unsigned char *)tdb->map_ptr)[off] ^= mask;
        else {
                unsigned char c;
-               pread(tdb->fd, &c, 1, off);
+               if (pread(tdb->fd, &c, 1, off) != 1)
+                       err(1, "pread");
                c ^= mask;
-               pwrite(tdb->fd, &c, 1, off);
+               if (pwrite(tdb->fd, &c, 1, off) != 1)
+                       err(1, "pwrite");
        }
 }
 
@@ -73,7 +76,8 @@ static void check_test(struct tdb_context *tdb)
        /* This is how many bytes we expect to be verifiable. */
        /* From the file header. */
        verifiable = strlen(TDB_MAGIC_FOOD) + 1
-               + 2 * sizeof(uint32_t) + 2 * sizeof(tdb_off_t);
+               + 2 * sizeof(uint32_t) + 2 * sizeof(tdb_off_t)
+               + 2 * sizeof(uint32_t);
        /* From the free list chain and hash chains. */
        verifiable += 3 * sizeof(tdb_off_t);
        /* From the record headers & tailer */