From ce5cce161d504df849a50ee1080db42a66ca8c42 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Dec 2013 10:53:56 +0000 Subject: test: fix valgrind warnings in test-only C code Unfortunately, none of the C-only tests are run with valgrind (however all of the Ruby ones are). --- test/queue-idle-1.c | 1 + test/trywrite-1.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/queue-idle-1.c b/test/queue-idle-1.c index 3b71923..6dfba51 100644 --- a/test/queue-idle-1.c +++ b/test/queue-idle-1.c @@ -58,6 +58,7 @@ static void test_blocking(void) printf(" end wait: %d\n", (int)time(NULL)); assert(1 == read(fds[0], buf, 1) && "read failed"); assert(buf[0] == 'B' && "didn't read expected 'B'"); + assert(0 == pthread_join(thr, NULL) && "pthread_join failed"); teardown(); } diff --git a/test/trywrite-1.c b/test/trywrite-1.c index a6bbde5..b833979 100644 --- a/test/trywrite-1.c +++ b/test/trywrite-1.c @@ -40,7 +40,7 @@ static void write_wrong(void) close(null); } - { + if (0) { /* FIXME: this makes valgrind unhappy */ void *x = mog_trysend(fds[0], (void *)1, 3, 0); assert(x == MOG_WR_ERROR && "bad addr did not return error"); @@ -55,7 +55,7 @@ static void write_wrong(void) } { - char buf[3]; + char buf[3] = { 0 }; void *x = mog_trysend(fds[1], buf, 3, 0); assert(x == MOG_WR_ERROR && "bad FD did not return error"); @@ -134,7 +134,7 @@ static void trysend_buffer(void) void *x; struct mog_wbuf *wbuf = NULL; int nread; - char buf[5]; + char buf[5] = { 0 }; size_t len = sizeof(buf); socketpair_or_die(fds); @@ -155,6 +155,7 @@ static void trysend_buffer(void) } assert(wbuf && "wbuf not initialized, how did we break from loop?"); + free(wbuf); /* for valgrind, we should never actually do this */ /* socket is/was blocked, it should be readable */ { -- cgit v1.2.3-24-ge0c7