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 E9697431FD0 for ; Wed, 21 Dec 2011 23:02:43 -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 y1retHeD3LpJ for ; Wed, 21 Dec 2011 23:02:43 -0800 (PST) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 606EA431FB6 for ; Wed, 21 Dec 2011 23:02:43 -0800 (PST) X-AuditID: 1209190c-b7fad6d000000920-72-4ef2d6129922 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 52.3D.02336.216D2FE4; Thu, 22 Dec 2011 02:02:42 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id pBM72fAs014255; Thu, 22 Dec 2011 02:02:41 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pBM72d1U010181 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 22 Dec 2011 02:02:40 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1Rdcgr-0007Cz-Oy; Thu, 22 Dec 2011 02:03:45 -0500 Date: Thu, 22 Dec 2011 02:03:45 -0500 From: Austin Clements To: David Edmondson Subject: Re: [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return. Message-ID: <20111222070345.GI10376@mit.edu> References: <1324503532-5799-1-git-send-email-dme@dme.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1324503532-5799-1-git-send-email-dme@dme.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgleLIzCtJLcpLzFFi42IRYrdT0RW69snPYOoLbYt9d7YwWVy/OZPZ gclj1/O/TB7PVt1iDmCK4rJJSc3JLEst0rdL4MqYO72oYL9gxaYFRg2Ma3m7GDk5JARMJPpe 3mWDsMUkLtxbD2YLCexjlPi0saaLkQvI3sAo0TZtDyOEc5JJYtarj8wQVUsYJW71+oLYLAKq Ek+nrgaLswloSGzbv5wRxBYRUJT4/20FO4jNLCAt8e13MxOILSwQLXH1x3EWEJtXQEdi0se9 TBAzrST+/1vLBBEXlDg58wkLRK+WxI1/L4HiHGBzlv/jAAlzClhLdHVcAztaVEBFYsrJbWwT GIVmIemehaR7FkL3AkbmVYyyKblVurmJmTnFqcm6xcmJeXmpRbqGermZJXqpKaWbGEEBzSnJ s4PxzUGlQ4wCHIxKPLwvhT75CbEmlhVX5h5ilORgUhLlzb8KFOJLyk+pzEgszogvKs1JLT7E KMHBrCTC+ygGKMebklhZlVqUD5OS5mBREudV0XrnJySQnliSmp2aWpBaBJOV4eBQkuAtARkq WJSanlqRlplTgpBm4uAEGc4DNDwbpIa3uCAxtzgzHSJ/ilFRSpy3HiQhAJLIKM2D64UlnFeM 4kCvCPPmglTxAJMVXPcroMFMQIO3OX8AGVySiJCSamAMvHdH686f8wdPWaTP7HK4kv/ufGwN w/ofF0RPOBXJyL9+YfXEYi3TOb6vGjMWHFuTI+Jm+2nm4xU/Kq8sZXp8Sfu9dMgsVlHlJsXi wN/F9fvzn51MYlx3rjqp8sPEIibLcxwH3wi2rfjzaJ3/uqmmzvlhdvP/L6j4c25l8uFX0YLT knUbf99vVmIpzkg01GIuKk4EAERB7WITAwAA Cc: notmuch@notmuchmail.org 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, 22 Dec 2011 07:02:44 -0000 I must admit I haven't been following the warnings problem very closely, but perhaps we shouldn't be ignoring these return codes? Quoth David Edmondson on Dec 21 at 9:38 pm: > --- > > 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; > } >