--- /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 96EF7429E29\r
+ for <notmuch@notmuchmail.org>; Fri, 26 Dec 2014 09:43:30 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 rUJwf1nSfOoe for <notmuch@notmuchmail.org>;\r
+ Fri, 26 Dec 2014 09:43:26 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\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 0AC74431E84\r
+ for <notmuch@notmuchmail.org>; Fri, 26 Dec 2014 09:43:26 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1Y4Yv1-0005zr-Mh; Fri, 26 Dec 2014 13:43:19 -0400\r
+Received: (nullmailer pid 21760 invoked by uid 1000); Fri, 26 Dec 2014\r
+ 17:43:08 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/4] lib: eliminate fprintf from _notmuch_message_file_open\r
+Date: Fri, 26 Dec 2014 18:42:41 +0100\r
+Message-Id: <1419615761-21581-5-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.3\r
+In-Reply-To: <1419615761-21581-1-git-send-email-david@tethera.net>\r
+References: <1419615761-21581-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: Fri, 26 Dec 2014 17:43:31 -0000\r
+\r
+I considered fancier solutions but memory management is already a bit\r
+delicate here, and I didn't want to mess it up. The remaining fprintf\r
+is 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 | 7 ++++---\r
+ 4 files changed, 14 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 8143758..b22a0e6 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -2244,7 +2244,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 eda1b74..ce435dd 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 60601ef..3abe7ba 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 d4b4858..b7fa09b 100644\r
+--- a/lib/notmuch-private.h\r
++++ b/lib/notmuch-private.h\r
+@@ -351,15 +351,16 @@ typedef struct _notmuch_message_file notmuch_message_file_t;\r
+ /* Open a file containing a single email message.\r
+ *\r
+ * The caller should call notmuch_message_close when done with this.\r
+- *\r
++ * \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.3\r
+\r