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 8AD80431FBC for ; Mon, 27 Feb 2012 07:49:28 -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 13GGVoeR7E+t for ; Mon, 27 Feb 2012 07:49:28 -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 EC3FF431FAE for ; Mon, 27 Feb 2012 07:49:27 -0800 (PST) X-AuditID: 1209190c-b7fad6d000000920-f2-4f4ba60796e9 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 31.13.02336.706AB4F4; Mon, 27 Feb 2012 10:49:27 -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 q1RFnQsS006846; Mon, 27 Feb 2012 10:49:26 -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 q1RFnPsb003382 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 27 Feb 2012 10:49:26 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1S22pJ-0000N6-8v; Mon, 27 Feb 2012 10:49:25 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 1/3] new: Consistently treat fatal errors as fatal Date: Mon, 27 Feb 2012 10:49:17 -0500 Message-Id: <1330357759-1337-2-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1330357759-1337-1-git-send-email-amdragon@mit.edu> References: <1330357759-1337-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixCmqrMu+zNvf4OI1aYvrN2cyOzB6PFt1 izmAMYrLJiU1J7MstUjfLoEr48ra7YwFjQIVf/YcZmlgPM7TxcjJISFgIvH/9z1WCFtM4sK9 9WxdjFwcQgL7GCXeXmlkgnA2MEr8X3SdBcK5zyRxacd+qLL5jBKH2jsZQfrZBDQktu1fDmaL CEhL7Lw7G2guBwezgJrEny4VkLCwgJPEocc/mUBsFgFViRvP5rKB2LwC9hJPl96HOkNB4tzq c+wgNqeAg8TLNX/BaoSAahadO8M8gZF/ASPDKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl1DvdzM Er3UlNJNjOCwkeTZwfjmoNIhRgEORiUe3qJZ3v5CrIllxZW5hxglOZiURHk9lwCF+JLyUyoz Eosz4otKc1KLDzFKcDArifDqZwPleFMSK6tSi/JhUtIcLErivCpa7/yEBNITS1KzU1MLUotg sjIcHEoSvAJLgRoFi1LTUyvSMnNKENJMHJwgw3mAhpuC1PAWFyTmFmemQ+RPMSpKifOygyQE QBIZpXlwvbC4fsUoDvSKMK8lSBUPMCXAdb8CGswENDiAE2xwSSJCSqqBkUN3ZdKTzSmMetc4 dTPnXtK7Zx/2PmC9cOH7eeefG4uw/8v1M7lfVSywaqfja4G55pu3tW15cL5ebG9q2OVF9pkL ZkdMN0/6ejxVv/ixcPAnLtVvXlJsupXbPtlqivx7u3JSXrNCRV3J7TWyEfwfsyq+BHecS3jx VWhBB49Euo3LJoV9jf8PKrEUZyQaajEXFScCAIOewMDGAgAA 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: Mon, 27 Feb 2012 15:49:28 -0000 Previously, fatal errors in add_files_recursive were not treated as fatal by its callers (including itself!) and add_files_recursive sometimes returned errors on non-fatal conditions. This makes add_files_recursive errors consistently fatal and updates all callers to treat them as fatal. --- notmuch-new.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 4f13535..bd9786a 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -308,7 +308,6 @@ add_files_recursive (notmuch_database_t *notmuch, if (num_fs_entries == -1) { fprintf (stderr, "Error opening directory %s: %s\n", path, strerror (errno)); - ret = NOTMUCH_STATUS_FILE_ERROR; goto DONE; } @@ -351,8 +350,10 @@ add_files_recursive (notmuch_database_t *notmuch, next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); status = add_files_recursive (notmuch, next, state); - if (status && ret == NOTMUCH_STATUS_SUCCESS) + if (status) { ret = status; + goto DONE; + } talloc_free (next); next = NULL; } @@ -933,6 +934,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) } ret = add_files (notmuch, db_path, &add_files_state); + if (ret) + goto DONE; gettimeofday (&tv_start, NULL); for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) { @@ -965,6 +968,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) } } + DONE: talloc_free (add_files_state.removed_files); talloc_free (add_files_state.removed_directories); talloc_free (add_files_state.directory_mtimes); @@ -1012,10 +1016,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) printf ("\n"); - if (ret) { - printf ("\nNote: At least one error was encountered: %s\n", + if (ret) + printf ("\nNote: A fatal error was encountered: %s\n", notmuch_status_to_string (ret)); - } notmuch_database_close (notmuch); -- 1.7.7.3