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 59374431FBF for ; Wed, 18 Jan 2012 16:40:20 -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 JrosXgVSNRvt for ; Wed, 18 Jan 2012 16:40:19 -0800 (PST) Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU [18.7.68.35]) by olra.theworths.org (Postfix) with ESMTP id A2BEE431FAF for ; Wed, 18 Jan 2012 16:40:19 -0800 (PST) X-AuditID: 12074423-b7f9c6d0000008c3-21-4f17667354b3 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id A9.AE.02243.376671F4; Wed, 18 Jan 2012 19:40:19 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q0J0eIa7000782; Wed, 18 Jan 2012 19:40:18 -0500 Received: from drake.mit.edu (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0J0eHMA016741 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 18 Jan 2012 19:40:18 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1Rng36-0004Ys-TE; Wed, 18 Jan 2012 19:40:16 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 2/2] Silence buildbot warnings about unused results Date: Wed, 18 Jan 2012 19:40:11 -0500 Message-Id: <1326933611-16898-3-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1326933611-16898-1-git-send-email-amdragon@mit.edu> References: <1326933611-16898-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrFucJu5v8KeL2+L6zZnMDowez1bd Yg5gjOKySUnNySxLLdK3S+DKmNsYWrBRsGJD7162BsaTvF2MnBwSAiYSv0+1sEPYYhIX7q1n 62Lk4hAS2McosWHZOUYIZwOjxPPmZywQzn0mib9nJrNCOPMZJf5s+84E0s8moCGxbf9yRhBb REBaYufd2UBFHBzMAmoSf7pUQExhAWeJfU8NQCpYBFQlZnTNBdvMK+AgMfPmQlaIKxQkzq0+ BxbnFHCUuPrlKNh0IaCaDZdWsExg5F/AyLCKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI10wvN7NE LzWldBMjKGTYXZR3MP45qHSIUYCDUYmHN0JE3F+INbGsuDL3EKMkB5OSKO+jVKAQX1J+SmVG YnFGfFFpTmrxIUYJDmYlEd6dJkA53pTEyqrUonyYlDQHi5I4r4bWOz8hgfTEktTs1NSC1CKY rAwHh5IErxIwNoQEi1LTUyvSMnNKENJMHJwgw3mAhnOB1PAWFyTmFmemQ+RPMSpKifN+B7lI ACSRUZoH1wuL6VeM4kCvCPMKgbTzANMBXPcroMFMQIM9msRABpckIqSkGhi3WFy57iaW+J7n ZRSbbjPbml2vbzc5fC5oOCjA37Tt5GHFct69P2Mlqw4rRh8t8Vyz7M+dXuHQbla9NyIztDq8 8yJWbxWeNGfO6s9+Wn+nvjhcKSDP8obH5c2artaQ2qz/uW0vF5nbaQplS7I+uNS2+ntZa/7y a0Ea7Rrr6kyb9hxa1r39qacSS3FGoqEWc1FxIgD0/MMpxAIAAA== 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 00:40:20 -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