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 0EE28431FBF for ; Wed, 18 Jan 2012 16:40:21 -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 IkuDlD2B4gEE for ; Wed, 18 Jan 2012 16:40:20 -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 EE7F2431FB6 for ; Wed, 18 Jan 2012 16:40:19 -0800 (PST) X-AuditID: 12074425-b7f4a6d0000008e0-23-4f1766722b0c Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id C6.87.02272.276671F4; Wed, 18 Jan 2012 19:40:18 -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 q0J0eI4K014933; 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 q0J0eGm1016738 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 18 Jan 2012 19:40:17 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1Rng36-0004Ym-CZ; Wed, 18 Jan 2012 19:40:16 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 1/2] show: Handle read and write errors Date: Wed, 18 Jan 2012 19:40:10 -0500 Message-Id: <1326933611-16898-2-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+NgFtrPIsWRmVeSWpSXmKPExsUixCmqrVuUJu5v8PitpMX1mzOZHRg9nq26 xRzAGMVlk5Kak1mWWqRvl8CVcX3JVPaCQ5wVXZsmMDcwbmbvYuTkkBAwkfh+8gAzhC0mceHe erYuRi4OIYF9jBKn+y4xQzgbGCW+vfkM5dxnkmjYuxjKmc8osf7kCkaQfjYBDYlt+5eD2SIC 0hI7785m7WLk4GAWUJP406UCEhYWMJc43LOHCcRmEVCVmHltGpjNK+AgMfFSK9RJChLnVp8D szkFHCWufjkKViMEVLPh0gqWCYz8CxgZVjHKpuRW6eYmZuYUpybrFicn5uWlFula6OVmluil ppRuYgSFDbuL6g7GCYeUDjEKcDAq8fBGiIj7C7EmlhVX5h5ilORgUhLlfZQKFOJLyk+pzEgs zogvKs1JLT7EKMHBrCTCu9MEKMebklhZlVqUD5OS5mBREufV1HrnJySQnliSmp2aWpBaBJOV 4eBQkuA1BBkqWJSanlqRlplTgpBm4uAEGc4DNDwMpIa3uCAxtzgzHSJ/ilGX48vvtvOMQix5 +XmpUuK820GKBECKMkrz4ObA4v0VozjQW8K80SBVPMBUATfpFdASJqAlHk1iIEtKEhFSUg2M Abtm8ob3Llqquy9yk8jps4cailVjGeQCFjdkhNw11GbyWSmZFs6TyRjxVEPLTtSDN93DUUpC zH0++9aFvKukHD3k5tleebJRquOO3pfy2eaaZsE7SnzjrnbrdK8J2dl/7BpbndMyPtbncdbv ta4+3eQc4vzbLqwunoFjv/jdpdO/tO3uLFRiKc5INNRiLipOBABeDbI80gIAAA== 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:21 -0000 For showing a message in raw format, rather than silently succeeding when a read or a write fails (or, probably, looping if a read fails), try to print an error message and exit with a non-zero status. This silences one of the buildbot warnings about unused resuls. 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)) size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); --- notmuch-show.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index d14dac9..c674e25 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -883,7 +883,17 @@ do_show_single (void *ctx, while (!feof (file)) { size = fread (buf, 1, sizeof (buf), file); - (void) fwrite (buf, size, 1, stdout); + if (ferror (file)) { + fprintf (stderr, "Error: Read failed from %s\n", filename); + fclose (file); + return 1; + } + + if (fwrite (buf, size, 1, stdout) != 1) { + fprintf (stderr, "Error: Write failed\n"); + fclose (file); + return 1; + } } fclose (file); -- 1.7.7.3