[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] test-select: avoid warn_unused_result warnings
From: |
Jim Meyering |
Subject: |
Re: [PATCH] test-select: avoid warn_unused_result warnings |
Date: |
Sat, 25 Dec 2010 16:20:12 +0100 |
Bruno Haible wrote:
> Hi Jim,
>
> You wrote on 2010-10-13 in
> <http://lists.gnu.org/archive/html/bug-gnulib/2010-10/msg00318.html>:
>> * tests/test-select.c: Include "macros.h".
>> ASSERT that each call to read, write, and pipe succeeds.
>> While not technically required, also check each "close".
>
> The last part causes a failure on OSF/1 5.1:
>
> Unconnected socket test... passed
> Connected sockets test... test-select.c:357: assertion failed
> sh: 366989 Abort - core dumped
> FAIL: test-select
>
> The reason is that after one end of the connection has been closed,
> the close() on the other end fails, signalling that some bytes have
> been written have been lost.
>
> This patch avoids the failure. Since you said that it's "not
> technically required" to check each close(), I assume you agree.
>
>
> 2010-12-24 Bruno Haible <address@hidden>
>
> select tests: Avoid failures on OSF/1 5.1.
> * tests/test-select.c (test_accept_first, test_socket_pair): Ignore
> failure of closing the last socket; it may fail with ECONNRESET.
>
> --- tests/test-select.c.orig Sat Dec 25 01:23:38 2010
> +++ tests/test-select.c Sat Dec 25 01:22:32 2010
> @@ -310,7 +310,7 @@
> failed ("cannot read data left in the socket by closed process");
> ASSERT (read (c, buf, 3) == 3);
> ASSERT (write (c, "foo", 3) == 3);
> - ASSERT (close (c) == 0);
> + (void) close (c); /* may fail with errno = ECONNRESET */
Thanks, Bruno.
That should be ok, assuming no modern version of gcc
warns about the unused value, in spite of the "(void)" cast.