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 514DE431FC0 for ; Thu, 19 Jan 2012 10:01:15 -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 E2Nvsrwx8n2L for ; Thu, 19 Jan 2012 10:01:13 -0800 (PST) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id 2A1F8431FC2 for ; Thu, 19 Jan 2012 10:01:09 -0800 (PST) X-AuditID: 12074424-b7fae6d000000906-1e-4f185a648e6b Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id 21.E1.02310.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 q0JI17rL013123; Thu, 19 Jan 2012 13:01:07 -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 q0JI16l4016831 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 19 Jan 2012 13:01:07 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1RnwIM-0007gm-Oc; Thu, 19 Jan 2012 13:01:06 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 1/2] show: Handle read and write errors Date: Thu, 19 Jan 2012 13:01:04 -0500 Message-Id: <1326996065-29467-1-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+NgFtrPIsWRmVeSWpSXmKPExsUixCmqrZsSJeFvMPGxpsX1mzOZHRg9nq26 xRzAGMVlk5Kak1mWWqRvl8CVcX3JVPaCQ5wVXZsmMDcwbmbvYuTkkBAwkfi4uYURwhaTuHBv PVsXIxeHkMA+RomPf5qZIZwNjBJ/jh+Cyhxnkpg2uZcdwpnPKLF8zkywfjYBDYlt+5eD2SIC 0hI7785m7WLk4GAWUJP406UCEhYWsJLYve8IE4jNIqAqcfniNTCbV8BB4trBNVAnKUicW30O zOYUcJS4+uUoWI0QUM2GSytYJjDyL2BkWMUom5JbpZubmJlTnJqsW5ycmJeXWqRrrpebWaKX mlK6iREUNuwuKjsYmw8pHWIU4GBU4uHlcpXwF2JNLCuuzD3EKMnBpCTK6xkJFOJLyk+pzEgs zogvKs1JLT7EKMHBrCTCe1wMKMebklhZlVqUD5OS5mBREufV0HrnJySQnliSmp2aWpBaBJOV 4eBQkuCdADJUsCg1PbUiLTOnBCHNxMEJMpwHaHg0SA1vcUFibnFmOkT+FKMux5ffbecZhVjy 8vNSpcR560GKBECKMkrz4ObA4v0VozjQW8K8HSBVPMBUATfpFdASJqAlHk1iIEtKEhFSUg2M rarcOmrzepuFWFZL2iULXUm6L/6r5moQy69JC3i2b2yU3bt9y8nbApvfKZf0rizJPPxP1d7G eJp66lK3/RJvP/U8f3DXYPX8TVwMavseFxg/nHNfNfpA3UEz97yP+/mcdVquG+pu3VE330qI iXmroy3/yULNgJw6Z7UGEZb412HzGf7VbrFTYinOSDTUYi4qTgQAj4x1h9ICAAA= 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:15 -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