Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C810D431FD0 for ; Wed, 21 Dec 2011 13:39:03 -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 Ig6AxIUy42SV for ; Wed, 21 Dec 2011 13:39:03 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 225E9431FB6 for ; Wed, 21 Dec 2011 13:39:03 -0800 (PST) Received: by wibhq2 with SMTP id hq2so2786562wib.26 for ; Wed, 21 Dec 2011 13:39:00 -0800 (PST) Received: by 10.180.81.72 with SMTP id y8mr17622322wix.14.1324503540343; Wed, 21 Dec 2011 13:39:00 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id eg7sm16728841wib.8.2011.12.21.13.38.58 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Dec 2011 13:38:59 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id B5878A05A7; Wed, 21 Dec 2011 21:38:56 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return. Date: Wed, 21 Dec 2011 21:38:52 +0000 Message-Id: <1324503532-5799-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.7.3 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: Wed, 21 Dec 2011 21:39:03 -0000 --- The mechanism used here works for me in an isolated test case and no warnings appear when using it as below, but I'm unsure why the original warning that it is intended to address didn't appear when I build. Any thoughts? compat/compat.h | 6 ++++++ notmuch-new.c | 2 +- notmuch-show.c | 2 +- notmuch-tag.c | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/compat/compat.h b/compat/compat.h index 7767fe8..1160301 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -30,6 +30,12 @@ extern "C" { #endif +#ifdef __GNUC__ +#define ignore_result(x) ({ __typeof__(x) z = x; (void) sizeof (z); }) +#else /* !__GNUC__ */ +#define ignore_result(x) x +#endif /* __GNUC__ */ + #if !HAVE_GETLINE #include #include diff --git a/notmuch-new.c b/notmuch-new.c index 3512de7..0ac04cc 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -67,7 +67,7 @@ handle_sigint (unused (int sig)) { static char msg[] = "Stopping... \n"; - (void) write(2, msg, sizeof(msg)-1); + ignore_result(write(STDERR_FILENO, msg, sizeof(msg)-1)); interrupted = 1; } diff --git a/notmuch-show.c b/notmuch-show.c index 19fb49f..681f778 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -866,7 +866,7 @@ do_show_single (void *ctx, while (!feof (file)) { size = fread (buf, 1, sizeof (buf), file); - (void) fwrite (buf, size, 1, stdout); + ignore_result(fwrite (buf, size, 1, stdout)); } fclose (file); diff --git a/notmuch-tag.c b/notmuch-tag.c index 292c5da..2cbfdc3 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -26,7 +26,7 @@ static void handle_sigint (unused (int sig)) { static char msg[] = "Stopping... \n"; - (void) write(2, msg, sizeof(msg)-1); + ignore_result(write(STDERR_FILENO, msg, sizeof(msg)-1)); interrupted = 1; } -- 1.7.7.3