X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ffailtest%2Ffailtest.c;h=205ded254709e6611d67b4465ca3967744306252;hb=3942778bb3f61cb580dd088c8449ca6dfdf6b7bc;hp=ab8e19cdb9caf60f1d8a9451e8225f874c7932e9;hpb=daf9ee7d8e2b683ff05283beb1843611ad8c9e8a;p=ccan diff --git a/ccan/failtest/failtest.c b/ccan/failtest/failtest.c index ab8e19cd..205ded25 100644 --- a/ccan/failtest/failtest.c +++ b/ccan/failtest/failtest.c @@ -179,7 +179,8 @@ static struct failtest_call *add_history_(enum failtest_call_type type, call->line = line; call->cleanup = NULL; call->backtrace = get_backtrace(&call->backtrace_num); - memcpy(&call->u, elem, elem_size); + if (elem_size != 0) + memcpy(&call->u, elem, elem_size); tlist_add_tail(&history, call, list); return call; } @@ -613,8 +614,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; } } @@ -1085,8 +1088,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) @@ -1200,9 +1203,8 @@ static void cleanup_pipe(struct pipe_call *call, bool restore) int failtest_pipe(int pipefd[2], const char *file, unsigned line) { struct failtest_call *p; - struct pipe_call call; - p = add_history(FAILTEST_PIPE, true, file, line, &call); + p = add_history_(FAILTEST_PIPE, true, file, line, NULL, 0); if (should_fail(p)) { p->u.open.ret = -1; /* FIXME: Play with error codes? */