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 0DB9C431FBF for ; Thu, 19 Jan 2012 14:29:27 -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 PeNKLJBp8WAk for ; Thu, 19 Jan 2012 14:29:26 -0800 (PST) Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU [18.9.25.14]) by olra.theworths.org (Postfix) with ESMTP id 75715431FAE for ; Thu, 19 Jan 2012 14:29:26 -0800 (PST) X-AuditID: 1209190e-b7f7c6d0000008c3-57-4f1899454232 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 1F.5B.02243.549981F4; Thu, 19 Jan 2012 17:29:25 -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 q0JMTPwm010018; Thu, 19 Jan 2012 17:29:25 -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 q0JMTOcc010686 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 19 Jan 2012 17:29:25 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1Ro0U0-000526-CZ; Thu, 19 Jan 2012 17:29:24 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v3 1/2] show: Handle read and write errors Date: Thu, 19 Jan 2012 17:29:18 -0500 Message-Id: <1327012159-19242-2-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1327012159-19242-1-git-send-email-amdragon@mit.edu> References: <1326996065-29467-1-git-send-email-amdragon@mit.edu> <1327012159-19242-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBIsWRmVeSWpSXmKPExsUixCmqrOs6U8LfYPplG4t9d7YwWVy/OZPZ gclj1/O/TB7PVt1iDmCK4rJJSc3JLEst0rdL4Mq4vmQqe8EhzoquTROYGxg3s3cxcnJICJhI 3FrzkRHCFpO4cG89WxcjF4eQwD5GiU1nWlhBEkICGxglbnXWQCSOM0mc//GBCcKZzyjR8uIU WDubgIbEtv3LwWwRAWmJnXdng3UzCxhL/J0+H8jm4BAWsJKY+qYAJMwioCqxon0CG4jNK+Ag 8X7aGTaIKxQkzq0+B3Ydp4CjxKwJe9kgjiiXuD79D8sERv4FjAyrGGVTcqt0cxMzc4pTk3WL kxPz8lKLdI31cjNL9FJTSjcxggNJkm8H49eDSocYBTgYlXh4OV0l/IVYE8uKK3MPMUpyMCmJ 8m6bDhTiS8pPqcxILM6ILyrNSS0+xCjBwawkwtvQB5TjTUmsrEotyodJSXOwKInzqmm98xMS SE8sSc1OTS1ILYLJynBwKEnwLp8B1ChYlJqeWpGWmVOCkGbi4AQZzgM0fCFIDW9xQWJucWY6 RP4Uoy7Hl99t5xmFWPLy81KlxHmrQIoEQIoySvPg5sASwCtGcaC3hHkXgVTxAJMH3KRXQEuY gJZ4NImBLClJREhJNTB2H6tbpyGws3a7UdXE2/rLLJ82ZQgvOSOm3zVXZoVoz+73AqfrWlMq eG5PuLNf/NTOgl2Z+tJWE5yUuc8nfJh/bKPEVe0rBbKWP6LeNl6catdjqVQlIOm1jqcuP1Kn ITrmRNjRHd8nznJ+KmcoYSbJd7/5dEJ3aEug6oHOZSW/PqSnztgb6aXEUpyRaKjFXFScCACx pvne2wIAAA== 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 22:29:27 -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