From abe9e01cfb29761e6bdd698a2253d4c07069d531 Mon Sep 17 00:00:00 2001 From: Jamie Davis Date: Fri, 24 Aug 2018 21:51:50 -0400 Subject: [PATCH] test: fix compiler warnings Problem: libuv is compiled with -Wunused-result. In two tests, read() is used for ordering and the rc is ignored because it doesn't matter. But -Wunused-result causes warnings in these cases. Fix: Provide a (very generous) check on the rc of read() in these cases. PR-URL: https://github.com/libuv/libuv/pull/1956 Reviewed-By: Colin Ihrig --- test/test-fork.c | 6 ++++-- test/test-pipe-close-stdout-read-stdin.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/test-fork.c b/test/test-fork.c index 2a1ddc497a1..f47ae3e6562 100644 --- a/test/test-fork.c +++ b/test/test-fork.c @@ -283,6 +283,7 @@ TEST_IMPL(fork_signal_to_child_closed) { int sync_pipe[2]; int sync_pipe2[2]; char sync_buf[1]; + int r; fork_signal_cb_called = 0; /* reset */ @@ -326,9 +327,10 @@ TEST_IMPL(fork_signal_to_child_closed) { /* Don't run the loop. Wait for the parent to call us */ printf("Waiting on parent in child\n"); /* Wait for parent. read may fail if the parent tripped an ASSERT - and exited, so this isn't in an ASSERT. + and exited, so this ASSERT is generous. */ - read(sync_pipe2[0], sync_buf, 1); + r = read(sync_pipe2[0], sync_buf, 1); + ASSERT(-1 <= r && r <= 1); ASSERT(0 == fork_signal_cb_called); printf("Exiting child \n"); /* Note that we're deliberately not running the loop diff --git a/test/test-pipe-close-stdout-read-stdin.c b/test/test-pipe-close-stdout-read-stdin.c index 4ab14789a38..c8804b0e189 100644 --- a/test/test-pipe-close-stdout-read-stdin.c +++ b/test/test-pipe-close-stdout-read-stdin.c @@ -66,7 +66,8 @@ TEST_IMPL(pipe_close_stdout_read_stdin) { */ close(fd[1]); /* block until write end of pipe is closed */ - read(fd[0], &buf, 1); + r = read(fd[0], &buf, 1); + ASSERT(-1 <= r && r <= 1); close(0); r = dup(fd[0]); ASSERT(r != -1);