]> git.ozlabs.org Git - ccan/blobdiff - ccan/failtest/failtest.c
crypto/shachain/tools: update to new rbuf API.
[ccan] / ccan / failtest / failtest.c
index fda2b344ff52af9464a1bdc6c4aa92b6556546bb..c61ce442a5d03b39444a87a468514f23c6f3c962 100644 (file)
@@ -91,7 +91,7 @@ static int control_fd = -1;
 /* If we're a child, this is the first call we did ourselves. */
 static struct failtest_call *our_history_start = NULL;
 /* For printing runtime with --trace. */
-static struct timespec start;
+static struct timeabs start;
 /* Set when failtest_hook returns FAIL_PROBE */
 static bool probing = false;
 /* Table to track duplicates. */
@@ -613,8 +613,10 @@ static NORETURN void failtest_cleanup(bool forced_cleanup, int status)
 
                /* But their program shouldn't leak, even on failure. */
                if (!forced_cleanup && i->can_leak) {
+                       char *p = failpath_string();
                        printf("Leak at %s:%u: --failpath=%s\n",
-                              i->file, i->line, failpath_string());
+                              i->file, i->line, p);
+                       free(p);
                        status = 1;
                }
        }
@@ -761,13 +763,13 @@ static bool should_fail(struct failtest_call *call)
        if (child == 0) {
                traceindent++;
                if (tracef) {
-                       struct timespec diff;
+                       struct timerel diff;
                        const char *p;
                        char *failpath;
                        struct failtest_call *c;
 
                        c = tlist_tail(&history, list);
-                       diff = time_sub(time_now(), start);
+                       diff = time_between(time_now(), start);
                        failpath = failpath_string();
                        p = strrchr(c->file, '/');
                        if (p)
@@ -776,7 +778,7 @@ static bool should_fail(struct failtest_call *call)
                                p = c->file;
                        trace("%u->%u (%u.%02u): %s (%s:%u)\n",
                              getppid(), getpid(),
-                             (int)diff.tv_sec, (int)diff.tv_nsec / 10000000,
+                             (int)diff.ts.tv_sec, (int)diff.ts.tv_nsec / 10000000,
                              failpath, p, c->line);
                        free(failpath);
                }
@@ -1085,8 +1087,8 @@ int failtest_open(const char *pathname,
        call.closed = false;
        if (call.flags & O_CREAT) {
                call.mode = va_arg(ap, int);
-               va_end(ap);
        }
+       va_end(ap);
        p = add_history(FAILTEST_OPEN, true, file, line, &call);
        /* Avoid memory leak! */
        if (p == &unrecorded_call)