]> git.ozlabs.org Git - ccan/blobdiff - ccan/failtest/failtest.c
Fix missing va_end()s
[ccan] / ccan / failtest / failtest.c
index dae3024ef97f55c24be4169a6589e7ef01258373..aab28dd43472449493297d223afafa21d4e667c2 100644 (file)
@@ -5,7 +5,6 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <ctype.h>
-#include <err.h>
 #include <unistd.h>
 #include <poll.h>
 #include <errno.h>
@@ -17,6 +16,7 @@
 #include <sys/resource.h>
 #include <signal.h>
 #include <assert.h>
+#include <ccan/err/err.h>
 #include <ccan/time/time.h>
 #include <ccan/read_write_all/read_write_all.h>
 #include <ccan/failtest/failtest_proto.h>
@@ -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 timeval start;
+static struct timeabs start;
 /* Set when failtest_hook returns FAIL_PROBE */
 static bool probing = false;
 /* Table to track duplicates. */
@@ -761,13 +761,13 @@ static bool should_fail(struct failtest_call *call)
        if (child == 0) {
                traceindent++;
                if (tracef) {
-                       struct timeval 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 +776,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_usec / 10000,
+                             (int)diff.ts.tv_sec, (int)diff.ts.tv_nsec / 10000000,
                              failpath, p, c->line);
                        free(failpath);
                }
@@ -1085,8 +1085,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)
@@ -1260,7 +1260,7 @@ static ssize_t failtest_add_read(int fd, void *buf, size_t count, off_t off,
                                set_cleanup(p, cleanup_read, struct read_call);
                }
        }
-       trace("%sread %s:%u fd %i %zu@%llu -> %i\n",
+       trace("%sread %s:%u fd %i %zu@%llu -> %zi\n",
              is_pread ? "p" : "", file, line, fd, count, (long long)off,
              p->u.read.ret);
        errno = p->error;
@@ -1362,7 +1362,7 @@ static ssize_t failtest_add_write(int fd, const void *buf,
                else
                        p->u.write.ret = write(fd, buf, count);
        }
-       trace("%swrite %s:%i %zu@%llu on fd %i -> %i\n",
+       trace("%swrite %s:%i %zu@%llu on fd %i -> %zi\n",
              p->u.write.is_pwrite ? "p" : "",
              file, line, count, (long long)off, fd, p->u.write.ret);
        errno = p->error;