Skip to content

Commit

Permalink
test: fix compiler warnings
Browse files Browse the repository at this point in the history
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: #1956
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
davisjam authored and cjihrig committed Sep 18, 2018
1 parent baa621c commit abe9e01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions test/test-fork.c
Expand Up @@ -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 */

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/test-pipe-close-stdout-read-stdin.c
Expand Up @@ -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);
Expand Down

0 comments on commit abe9e01

Please sign in to comment.