From: David Bremner Date: Sat, 14 Mar 2015 17:02:34 +0000 (+0100) Subject: [Patch v4 9/9] lib: eliminate fprintf from _notmuch_message_file_open X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7680cae3130a51ab9469c04f4771e3f82316839f;p=notmuch-archives.git [Patch v4 9/9] lib: eliminate fprintf from _notmuch_message_file_open --- diff --git a/58/f94b2b67ea9600002e5ec3cd4876c96b644ff9 b/58/f94b2b67ea9600002e5ec3cd4876c96b644ff9 new file mode 100644 index 000000000..cece6a3e6 --- /dev/null +++ b/58/f94b2b67ea9600002e5ec3cd4876c96b644ff9 @@ -0,0 +1,146 @@ +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 3C9B0431FDF + for ; Sat, 14 Mar 2015 10:05:04 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.438 +X-Spam-Level: ** +X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 D0oZMCTTV3pq for ; + Sat, 14 Mar 2015 10:05:02 -0700 (PDT) +Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net + [87.98.215.224]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 48368431FC9 + for ; Sat, 14 Mar 2015 10:05:02 -0700 (PDT) +Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim + 4.80) (envelope-from ) + id 1YWpTz-00027n-37; Sat, 14 Mar 2015 17:04:15 +0000 +Received: (nullmailer pid 4997 invoked by uid 1000); Sat, 14 Mar 2015 + 17:02:41 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [Patch v4 9/9] lib: eliminate fprintf from _notmuch_message_file_open +Date: Sat, 14 Mar 2015 18:02:34 +0100 +Message-Id: <1426352554-4383-10-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1426352554-4383-1-git-send-email-david@tethera.net> +References: <1426352554-4383-1-git-send-email-david@tethera.net> +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: Sat, 14 Mar 2015 17:05:04 -0000 + +You may wonder why _notmuch_message_file_open_ctx has two parameters. +This is because we need sometime to use a ctx which is a +notmuch_message_t. While we could get the database from this, there is +no easy way in C to tell type we are getting. The remaining fprintf is +removed by Jani's series un-deprecating single message mboxes. +--- + lib/database.cc | 2 +- + lib/message-file.c | 11 +++++++---- + lib/message.cc | 3 ++- + lib/notmuch-private.h | 5 +++-- + 4 files changed, 13 insertions(+), 8 deletions(-) + +diff --git a/lib/database.cc b/lib/database.cc +index 6828654..b5f3549 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -2317,7 +2317,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch, + if (ret) + return ret; + +- message_file = _notmuch_message_file_open (filename); ++ message_file = _notmuch_message_file_open (notmuch, filename); + if (message_file == NULL) + return NOTMUCH_STATUS_FILE_ERROR; + +diff --git a/lib/message-file.c b/lib/message-file.c +index a41d9ad..8ac96e8 100644 +--- a/lib/message-file.c ++++ b/lib/message-file.c +@@ -76,7 +76,8 @@ _notmuch_message_file_destructor (notmuch_message_file_t *message) + /* Create a new notmuch_message_file_t for 'filename' with 'ctx' as + * the talloc owner. */ + notmuch_message_file_t * +-_notmuch_message_file_open_ctx (void *ctx, const char *filename) ++_notmuch_message_file_open_ctx (notmuch_database_t *notmuch, ++ void *ctx, const char *filename) + { + notmuch_message_file_t *message; + +@@ -98,16 +99,18 @@ _notmuch_message_file_open_ctx (void *ctx, const char *filename) + return message; + + FAIL: +- fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno)); ++ _notmuch_database_log (notmuch, "Error opening %s: %s\n", ++ filename, strerror (errno)); + _notmuch_message_file_close (message); + + return NULL; + } + + notmuch_message_file_t * +-_notmuch_message_file_open (const char *filename) ++_notmuch_message_file_open (notmuch_database_t *notmuch, ++ const char *filename) + { +- return _notmuch_message_file_open_ctx (NULL, filename); ++ return _notmuch_message_file_open_ctx (notmuch, NULL, filename); + } + + void +diff --git a/lib/message.cc b/lib/message.cc +index a8ca988..5bc7aff 100644 +--- a/lib/message.cc ++++ b/lib/message.cc +@@ -437,7 +437,8 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message) + if (unlikely (filename == NULL)) + return; + +- message->message_file = _notmuch_message_file_open_ctx (message, filename); ++ message->message_file = _notmuch_message_file_open_ctx ( ++ _notmuch_message_database (message), message, filename); + } + + const char * +diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h +index dc58a2f..cc9ce12 100644 +--- a/lib/notmuch-private.h ++++ b/lib/notmuch-private.h +@@ -358,11 +358,12 @@ typedef struct _notmuch_message_file notmuch_message_file_t; + * Returns NULL if any error occurs. + */ + notmuch_message_file_t * +-_notmuch_message_file_open (const char *filename); ++_notmuch_message_file_open (notmuch_database_t *notmuch, const char *filename); + + /* Like notmuch_message_file_open but with 'ctx' as the talloc owner. */ + notmuch_message_file_t * +-_notmuch_message_file_open_ctx (void *ctx, const char *filename); ++_notmuch_message_file_open_ctx (notmuch_database_t *notmuch, ++ void *ctx, const char *filename); + + /* Close a notmuch message previously opened with notmuch_message_open. */ + void +-- +2.1.4 +