]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb/test/run-corrupt.c
tdb: fix warnings with gcc -O3, and one test crash.
[ccan] / ccan / tdb / test / run-corrupt.c
index bea7dbcdf490218e4cd8ab0a4983246f6fb8be13..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");
        }
 }