]> git.notmuchmail.org Git - notmuch/blobdiff - message.cc
Fix notmuch_message_get_message_id to never return NULL.
[notmuch] / message.cc
index 281da4f55c34388c3ac54a6cea2a7f8707a75e38..65e5ad78a269b6da86ef5a3b7c289871d8096712 100644 (file)
@@ -41,6 +41,13 @@ struct _notmuch_thread_ids {
     char *next;
 };
 
+/* "128 bits of thread-id ought to be enough for anybody" */
+#define NOTMUCH_THREAD_ID_BITS  128
+#define NOTMUCH_THREAD_ID_DIGITS (NOTMUCH_THREAD_ID_BITS / 4)
+typedef struct _thread_id {
+    char str[NOTMUCH_THREAD_ID_DIGITS + 1];
+} thread_id_t;
+
 #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
 
 /* These prefix values are specifically chosen to be compatible
@@ -208,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;