From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id D7E616DE1E3E for ; Sat, 18 Feb 2017 06:46:58 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e4P82j2EBn7Y for ; Sat, 18 Feb 2017 06:46:57 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id E4D0B6DE1E45 for ; Sat, 18 Feb 2017 06:46:43 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cf6H0-0004Zs-MR; Sat, 18 Feb 2017 09:46:06 -0500 Received: (nullmailer pid 23024 invoked by uid 1000); Sat, 18 Feb 2017 14:46:33 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 3/8] lib: propagate error return from some calls to _n_m_e_metadata Date: Sat, 18 Feb 2017 10:45:46 -0400 Message-Id: <20170218144551.22925-4-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170218144551.22925-1-david@tethera.net> References: <20170218144551.22925-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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, 18 Feb 2017 14:46:59 -0000 In this commit we take care of the easy cases, where _n_m_e_metadata is called from a non-void function. Three tricker cases are left for future commits. --- lib/message.cc | 15 +++++++++++---- lib/notmuch.h | 9 ++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 916dd441..16ea980c 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -458,7 +458,9 @@ const char * notmuch_message_get_message_id (notmuch_message_t *message) { if (!message->message_id) - _notmuch_message_ensure_metadata (message); + if (_notmuch_message_ensure_metadata (message)) + return NULL; + if (!message->message_id) INTERNAL_ERROR ("Message with document ID of %u has no message ID.\n", message->doc_id); @@ -534,7 +536,9 @@ const char * _notmuch_message_get_in_reply_to (notmuch_message_t *message) { if (!message->in_reply_to) - _notmuch_message_ensure_metadata (message); + if (_notmuch_message_ensure_metadata (message)) + return NULL; + return message->in_reply_to; } @@ -542,7 +546,9 @@ const char * notmuch_message_get_thread_id (notmuch_message_t *message) { if (!message->thread_id) - _notmuch_message_ensure_metadata (message); + if (_notmuch_message_ensure_metadata (message)) + return NULL; + if (!message->thread_id) INTERNAL_ERROR ("Message with document ID of %u has no thread ID.\n", message->doc_id); @@ -982,7 +988,8 @@ notmuch_message_get_tags (notmuch_message_t *message) notmuch_tags_t *tags; if (!message->tag_list) - _notmuch_message_ensure_metadata (message); + if (_notmuch_message_ensure_metadata (message)) + return NULL; tags = _notmuch_tags_create (message, message->tag_list); /* _notmuch_tags_create steals the reference to the tag_list, but diff --git a/lib/notmuch.h b/lib/notmuch.h index 16da8be9..62866e5a 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -1286,9 +1286,7 @@ notmuch_messages_collect_tags (notmuch_messages_t *messages); * message is valid, (which is until the query from which it derived * is destroyed). * - * This function will not return NULL since Notmuch ensures that every - * message has a unique message ID, (Notmuch will generate an ID for a - * message if the original file does not contain one). + * The function returns NULL on error. */ const char * notmuch_message_get_message_id (notmuch_message_t *message); @@ -1302,8 +1300,7 @@ notmuch_message_get_message_id (notmuch_message_t *message); * notmuch_message_destroy on 'message' or until a query from which it * derived is destroyed). * - * This function will not return NULL since Notmuch ensures that every - * message belongs to a single thread. + * The function returns NULL on error. */ const char * notmuch_message_get_thread_id (notmuch_message_t *message); @@ -1449,6 +1446,8 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header); * notmuch_tags_t object. (For consistency, we do provide a * notmuch_tags_destroy function, but there's no good reason to call * it if the message is about to be destroyed). + * + * The function returns NULL on error. */ notmuch_tags_t * notmuch_message_get_tags (notmuch_message_t *message); -- 2.11.0