From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 42DE0431FAE for ; Thu, 19 Jan 2012 10:01:16 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xIPzjElL52V2 for ; Thu, 19 Jan 2012 10:01:15 -0800 (PST) Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU [18.7.68.37]) by olra.theworths.org (Postfix) with ESMTP id 2F3A1431FC3 for ; Thu, 19 Jan 2012 10:01:09 -0800 (PST) X-AuditID: 12074425-b7f4a6d0000008e0-cc-4f185a645fb4 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id 52.28.02272.46A581F4; Thu, 19 Jan 2012 13:01:08 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0JI18PM013125; Thu, 19 Jan 2012 13:01:08 -0500 Received: from drake.mit.edu (26-4-166.dynamic.csail.mit.edu [18.26.4.166]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0JI17k2016837 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 19 Jan 2012 13:01:08 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1RnwIN-0007gq-DO; Thu, 19 Jan 2012 13:01:07 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 2/2] Silence buildbot warnings about unused results Date: Thu, 19 Jan 2012 13:01:05 -0500 Message-Id: <1326996065-29467-2-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1326996065-29467-1-git-send-email-amdragon@mit.edu> References: <1326933611-16898-1-git-send-email-amdragon@mit.edu> <1326996065-29467-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixCmqrZsSJeFvsPCttcX1mzOZHRg9nq26 xRzAGMVlk5Kak1mWWqRvl8CVMbcxtGCjYMWG3r1sDYwnebsYOTkkBEwkdq/5wAxhi0lcuLee rYuRi0NIYB+jxPOuBUwQzgZGicZ3M6Cc40wSd84vZYVw5jNK3G/6xwjSzyagIbFt/3IwW0RA WmLn3dlARRwczAJqEn+6VEDCwgJuEt23drOB2CwCqhL/ThxlAinhFXCQOPaWEeIKBYlzq8+x g9icAo4SZ/6/YQMpERIol7i8J3ICI/8CRoZVjLIpuVW6uYmZOcWpybrFyYl5ealFuhZ6uZkl eqkppZsYQQHD7qK6g3HCIaVDjAIcjEo8vNyuEv5CrIllxZW5hxglOZiURHk9I4FCfEn5KZUZ icUZ8UWlOanFhxglOJiVRHiPiwHleFMSK6tSi/JhUtIcLErivJpa7/yEBNITS1KzU1MLUotg sjIcHEoSvBNAhgoWpaanVqRl5pQgpJk4OEGG8wANjwap4S0uSMwtzkyHyJ9iVJQS560HSQiA JDJK8+B6YRH9ilEc6BVh3g6QKh5gMoDrfgU0mAlosEeTGMjgkkSElFQDI1uRgF3R7l9ZC9rc Ivb8+r3yoY7R1AUeU22+npyhsNo7+HNR1spczmsv/ijcvc71s//7rpUFqzmi1icqeuTMZ/T5 rdFWGf9L9Y84y9aTR3kn6r3b3b5F/2C48iXNvc29zczz7+/Q/uf25WLiIk5RWzMNjce79+x6 rHl39uczWvfXPZScbby0Z6cSS3FGoqEWc1FxIgCMKop1wwIAAA== X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jan 2012 18:01:16 -0000 This ignores the results of the two writes in sigint handlers even harder than before. While my libc lacks the declarations that trigger these warnings, this can be tested by adding the following to notmuch.h: __attribute__((warn_unused_result)) ssize_t write(int fd, const void *buf, size_t count); --- compat/compat.h | 8 ++++++++ notmuch-new.c | 6 +++++- notmuch-tag.c | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/compat/compat.h b/compat/compat.h index 7767fe8..b2e2736 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -46,6 +46,14 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp); char* strcasestr(const char *haystack, const char *needle); #endif /* !HAVE_STRCASESTR */ +/* Silence gcc warnings about unused results. These warnings exist + * for a reason; any use of this needs to be justified. */ +#ifdef __GNUC__ +#define IGNORE_RESULT(x) ({ __typeof__(x) __z = (x); (void)(__z = __z); }) +#else /* !__GNUC__ */ +#define IGNORE_RESULT(x) x +#endif /* __GNUC__ */ + #ifdef __cplusplus } #endif diff --git a/notmuch-new.c b/notmuch-new.c index 3512de7..a569a54 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -67,7 +67,11 @@ handle_sigint (unused (int sig)) { static char msg[] = "Stopping... \n"; - (void) write(2, msg, sizeof(msg)-1); + /* This write is "opportunistic", so it's okay to ignore the + * result. It is not required for correctness, and if it does + * fail or produce a short write, we want to get out of the signal + * handler as quickly as possible, not retry it. */ + IGNORE_RESULT (write (2, msg, sizeof(msg)-1)); interrupted = 1; } diff --git a/notmuch-tag.c b/notmuch-tag.c index 292c5da..1564182 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -26,7 +26,10 @@ static void handle_sigint (unused (int sig)) { static char msg[] = "Stopping... \n"; - (void) write(2, msg, sizeof(msg)-1); + + /* See handle_sigint in notmuch-new.c for the justification for + * ignoring write's result. */ + IGNORE_RESULT (write (2, msg, sizeof(msg)-1)); interrupted = 1; } -- 1.7.7.3