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 63647431FC2 for ; Sun, 16 Dec 2012 20:00:52 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 07O+a5-mTrVd for ; Sun, 16 Dec 2012 20:00:51 -0800 (PST) Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id DF16C431FC4 for ; Sun, 16 Dec 2012 20:00:46 -0800 (PST) Received: from fctnnbsc30w-142167090129.dhcp-dynamic.fibreop.nb.bellaliant.net ([142.167.90.129] helo=zancas.localnet) by tesseract.cs.unb.ca with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1TkRsk-0008LV-5d; Mon, 17 Dec 2012 00:00:46 -0400 Received: from bremner by zancas.localnet with local (Exim 4.80) (envelope-from ) id 1TkRse-0000ng-N0; Mon, 17 Dec 2012 00:00:40 -0400 From: david@tethera.net To: notmuch@notmuchmail.org Subject: [PATCH 1/3] notmuch-restore: fix return value propagation Date: Sun, 16 Dec 2012 23:59:46 -0400 Message-Id: <1355716788-2940-2-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355716788-2940-1-git-send-email-david@tethera.net> References: <1355716788-2940-1-git-send-email-david@tethera.net> X-Spam_bar: - Cc: David Bremner 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, 17 Dec 2012 04:00:52 -0000 From: David Bremner Previously notmuch_restore_command returned 0 if tag_message returned a non-zero (failure) value. This is wrong, since non-zero status indicates something mysterious went wrong with retrieving the message, or applying it. There was also a failure to check or propagate the return value from tag_op_list_apply in tag_message. --- notmuch-restore.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/notmuch-restore.c b/notmuch-restore.c index 40596a8..5a02328 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -25,6 +25,9 @@ static regex_t regex; +/* Non-zero return indicates an error in retrieving the message, + * or in applying the tags. + */ static int tag_message (unused (void *ctx), notmuch_database_t *notmuch, @@ -48,7 +51,7 @@ tag_message (unused (void *ctx), /* In order to detect missing messages, this check/optimization is * intentionally done *after* first finding the message. */ if ((flags & TAG_FLAG_REMOVE_ALL) || tag_op_list_size (tag_ops)) - tag_op_list_apply (message, tag_ops, flags); + ret = tag_op_list_apply (message, tag_ops, flags); notmuch_message_destroy (message); @@ -231,8 +234,12 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[]) if (ret > 0) continue; - if (ret < 0 || tag_message (ctx, notmuch, query_string, - tag_ops, flags)) + if (ret < 0) + break; + + ret = tag_message (line_ctx, notmuch, query_string, + tag_ops, flags); + if (ret) break; } while ((line_len = getline (&line, &line_size, input)) != -1); -- 1.7.10.4