]> git.notmuchmail.org Git - notmuch/commitdiff
Fix notmuch_message_get_message_id to never return NULL.
authorCarl Worth <cworth@cworth.org>
Fri, 23 Oct 2009 13:04:57 +0000 (06:04 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 23 Oct 2009 13:04:57 +0000 (06:04 -0700)
With the recent improvements to the handling of message IDs we
"know" that a NULL message ID is impossible, (so we simply
abort if the impossible happens).

message.cc
notmuch.h

index ce600af94b1340310aa252cf7a8ee0433aae1929..65e5ad78a269b6da86ef5a3b7c289871d8096712 100644 (file)
@@ -215,10 +215,11 @@ notmuch_message_get_message_id (notmuch_message_t *message)
     i = message->doc.termlist_begin ();
     i.skip_to (_find_prefix ("msgid"));
 
-    /* XXX: This should really be an internal error, but we'll need to
-     * fix the add_message side of things first. */
-    if (i == message->doc.termlist_end ())
-       return NULL;
+    if (i == message->doc.termlist_end ()) {
+       fprintf (stderr, "Internal error: Message with document ID of %d has no message ID.\n",
+                message->doc_id);
+       exit (1);
+    }
 
     message->message_id = talloc_strdup (message, (*i).c_str () + 1);
     return message->message_id;
index 57ff8c8f3003fd63298ca7acd9464399ffe9262b..f568bc0a2da3458fad66b6b13f03d7fadb267f24 100644 (file)
--- a/notmuch.h
+++ b/notmuch.h
@@ -338,6 +338,10 @@ notmuch_results_destroy (notmuch_results_t *results);
  * modified by the caller and will only be valid for as long as the
  * 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).
  */
 const char *
 notmuch_message_get_message_id (notmuch_message_t *message);