tdb: fix warnings with gcc -O3, and one test crash.
[ccan] / ccan / tdb / test / run-corrupt.c
index 2109e936b1bf77eb645ffc7627f50896ed6b436e..6f753ea6d46c81c9dbd3f9e388c1f3078c98e30e 100644 (file)
@@ -43,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;
                ((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;
                c ^= mask;
-               pwrite(tdb->fd, &c, 1, off);
+               if (pwrite(tdb->fd, &c, 1, off) != 1)
+                       err(1, "pwrite");
        }
 }
 
        }
 }