From: Dirk-Jan C. Binnema Date: Mon, 23 Nov 2009 06:03:35 +0000 (+0200) Subject: Avoid compiler warnings due to ignored write return values X-Git-Tag: 0.1~275 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5f0b2ece161b16321792d9ff2f76bcc33a3b6b42;p=notmuch.git Avoid compiler warnings due to ignored write return values Glibc (at least) provides the warn_unused_result attribute on write, (if optimizing and _FORTIFY_SOURCE is defined). So we explicitly ignore the return value in our signal handler, where we couldn't do anything anyway. Compile with: make CFLAGS="-O -D_FORTIFY_SOURCE" before this commit to see the warning. --- diff --git a/notmuch-new.c b/notmuch-new.c index f58a384b..9d206167 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -35,8 +35,10 @@ static volatile sig_atomic_t interrupted; static void handle_sigint (unused (int sig)) { + ssize_t ignored; static char msg[] = "Stopping... \n"; - write(2, msg, sizeof(msg)-1); + + ignored = write(2, msg, sizeof(msg)-1); interrupted = 1; } diff --git a/notmuch-tag.c b/notmuch-tag.c index 07cb8c5f..00588a11 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -25,8 +25,10 @@ static volatile sig_atomic_t interrupted; static void handle_sigint (unused (int sig)) { + ssize_t ignored; + static char msg[] = "Stopping... \n"; - write(2, msg, sizeof(msg)-1); + ignored = write(2, msg, sizeof(msg)-1); interrupted = 1; }