]> git.notmuchmail.org Git - notmuch/commitdiff
Avoid compiler warnings due to ignored write return values
authorDirk-Jan C. Binnema <djcb.bulk@gmail.com>
Mon, 23 Nov 2009 06:03:35 +0000 (08:03 +0200)
committerCarl Worth <cworth@cworth.org>
Tue, 1 Dec 2009 15:50:35 +0000 (07:50 -0800)
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.

notmuch-new.c
notmuch-tag.c

index f58a384b52b1cf48cbb7067b2e5f8743e9b0aeae..9d206167e997382d623934ce4dd1797751b2e950 100644 (file)
@@ -35,8 +35,10 @@ static volatile sig_atomic_t interrupted;
 static void
 handle_sigint (unused (int sig))
 {
 static void
 handle_sigint (unused (int sig))
 {
+    ssize_t ignored;
     static char msg[] = "Stopping...         \n";
     static char msg[] = "Stopping...         \n";
-    write(2, msg, sizeof(msg)-1);
+
+    ignored = write(2, msg, sizeof(msg)-1);
     interrupted = 1;
 }
 
     interrupted = 1;
 }
 
index 07cb8c5f21b53df36452b3fc14415b63f2f0b075..00588a11608bc0b5a8ead8d7f7e4a2bb804d403b 100644 (file)
@@ -25,8 +25,10 @@ static volatile sig_atomic_t interrupted;
 static void
 handle_sigint (unused (int sig))
 {
 static void
 handle_sigint (unused (int sig))
 {
+    ssize_t ignored;
+
     static char msg[] = "Stopping...         \n";
     static char msg[] = "Stopping...         \n";
-    write(2, msg, sizeof(msg)-1);
+    ignored = write(2, msg, sizeof(msg)-1);
     interrupted = 1;
 }
 
     interrupted = 1;
 }