From e9c51d24b1667b94101bf52fbd95aa7f1c6cb1d6 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 24 Mar 2011 13:05:49 +0100 Subject: [PATCH] udp_send: Silence gcc warning. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ubuntu Lucid's gcc-4.3.3 emits the following warning about not checking the return value of write() even if the result is casted to void. udp_send.c: In function ‘udp_close_target’: udp_send.c:65: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result The usual approach to store the return value in a dummy variable is not optimal because the upcoming gcc-4.6 will warn that the variable is set but otherwise unused. Likely there are more places in the paraslash code which have the same problem, so this patch introduce the do_nothing macro in para.h which, creatively enough, does nothing. The new macro is employed like if (write(...)) do_nothing; This gets rid of the warning on Lucid and does not give new warning on gcc-4.6. --- para.h | 3 +++ udp_send.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/para.h b/para.h index 29c5c2b8..08eb0ee6 100644 --- a/para.h +++ b/para.h @@ -221,6 +221,9 @@ _static_inline_ long int para_random(unsigned max) /** Used to avoid a shortcoming in vim's syntax highlighting. */ #define EMBRACE(...) { __VA_ARGS__} +/** A nice cup of STFU for Mr gcc. */ +#define do_nothing do {/* nothing */} while (0) + /** * The sample formats supported by paraslash. * diff --git a/udp_send.c b/udp_send.c index 4fb10b44..b4494eb7 100644 --- a/udp_send.c +++ b/udp_send.c @@ -57,8 +57,13 @@ static void udp_close_target(struct sender_client *sc) const char *buf; size_t len = vss_get_fec_eof_packet(&buf); - /* ignore return value, closing the target anyway. */ - (void)write(sc->fd, buf, len); + /* + * Ignore the return value of wirte() since we are closing the target + * anyway. The sole purpose of the "do_nothing" statement is to silence + * gcc. + */ + if (write(sc->fd, buf, len)) + do_nothing; } static void udp_delete_target(struct sender_client *sc, const char *msg) -- 2.39.2