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