tdb: fix warnings with gcc -O3, and one test crash.
[ccan] / ccan / tdb / test / run-die-during-transaction.c
index b8943602655f79c5c6a0bc9851321cc4467ee268..aa6b40f6bbad9eb5246d03334ff9b6c0a738cf9f 100644 (file)
@@ -98,6 +98,10 @@ static bool test_death(enum operation op, struct agent *agent)
 
        current = target = 0;
 reset:
+       unlink(TEST_DBNAME);
+       tdb = tdb_open_ex(TEST_DBNAME, 1024, TDB_NOMMAP,
+                         O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
+
        if (setjmp(jmpbuf) != 0) {
                /* We're partway through.  Simulate our death. */
                close(tdb->fd);
@@ -153,10 +157,6 @@ reset:
                goto reset;
        }
 
-       unlink(TEST_DBNAME);
-       tdb = tdb_open_ex(TEST_DBNAME, 1024, TDB_NOMMAP,
-                         O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
-
        /* Put key for agent to fetch. */
        key.dsize = strlen(KEY_STRING);
        key.dptr = (void *)KEY_STRING;