]> git.ozlabs.org Git - ccan/commitdiff
tdb2: avoid writing uninitialized bytes in test/layout.c
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Mar 2011 11:42:21 +0000 (22:12 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Mar 2011 11:42:21 +0000 (22:12 +1030)
ccan/tdb2/test/layout.c
ccan/tdb2/test/run-03-coalesce.c

index ad775c8ad49483f4275d1fedb0bc718bd1b6e9b4..16f077198dbea011a2e9510a9b6dc1aa1b938260 100644 (file)
@@ -252,6 +252,8 @@ struct tdb_context *tdb_layout_get(struct tdb_layout *layout)
        }
 
        mem = malloc(off);
+       /* Fill with some weird pattern. */
+       memset(mem, 0x99, off);
        /* Now populate our header, cribbing from a real TDB header. */
        tdb = tdb_open(NULL, TDB_INTERNAL, O_RDWR, 0, &tap_log_attr);
        memcpy(mem, tdb->map_ptr, sizeof(struct tdb_header));
index 7325a4498c81e5d8c1b1497f8cc64c8b770e7b7b..ffa2b6c97bd111e6cadab66ee3c6efb5a2c62d69 100644 (file)
@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
        key.dsize = 5;
 
        /* No coalescing can be done due to EOF */
-       layout = new_tdb_layout(NULL);
+       layout = new_tdb_layout("run-03-coalesce.tdb");
        tdb_layout_add_freetable(layout);
        len = 1024;
        tdb_layout_add_free(layout, len, 0);
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
        tdb_layout_free(layout);
 
        /* No coalescing can be done due to used record */
-       layout = new_tdb_layout(NULL);
+       layout = new_tdb_layout("run-03-coalesce.tdb");
        tdb_layout_add_freetable(layout);
        tdb_layout_add_free(layout, 1024, 0);
        tdb_layout_add_used(layout, key, data, 6);
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
        tdb_layout_free(layout);
 
        /* Coalescing can be done due to two free records, then EOF */
-       layout = new_tdb_layout(NULL);
+       layout = new_tdb_layout("run-03-coalesce.tdb");
        tdb_layout_add_freetable(layout);
        tdb_layout_add_free(layout, 1024, 0);
        tdb_layout_add_free(layout, 2048, 0);
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
        tdb_layout_free(layout);
 
        /* Coalescing can be done due to two free records, then data */
-       layout = new_tdb_layout(NULL);
+       layout = new_tdb_layout("run-03-coalesce.tdb");
        tdb_layout_add_freetable(layout);
        tdb_layout_add_free(layout, 1024, 0);
        tdb_layout_add_free(layout, 512, 0);
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
        tdb_layout_free(layout);
 
        /* Coalescing can be done due to three free records, then EOF */
-       layout = new_tdb_layout(NULL);
+       layout = new_tdb_layout("run-03-coalesce.tdb");
        tdb_layout_add_freetable(layout);
        tdb_layout_add_free(layout, 1024, 0);
        tdb_layout_add_free(layout, 512, 0);