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