Re: [notmuch] [PATCH] Switch from random to sequential thread identifiers.

Subject: Re: [notmuch] [PATCH] Switch from random to sequential thread identifiers.

Date: Tue, 09 Feb 2010 15:40:00 +0100

To: Carl Worth, notmuch@notmuchmail.org

Cc:

From: Michal Sojka


On Mon, 08 Feb 2010 13:36:14 -0800, Carl Worth <cworth@cworth.org> wrote:
> The sequential identifiers have the advantage of being guaranteed to
> be unique (until we overflow a 64-bit unsigned integer), and also take
> up half as much space in the "notmuch search" output (16 columns
> rather than 32).
>  [...]

On amd64 I get:
lib/database.cc: In function ‘const char* _notmuch_database_generate_thread_id(notmuch_database_t*)’:
lib/database.cc:1309: warning: format ‘%016llx’ expects type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’

What about the following? This could also fix Sebastian's problem.

---- 8< ----
>From afcc07ae03ae40cf7e1c33d8632fba0a9fc0b4c8 Mon Sep 17 00:00:00 2001
From: Michal Sojka <sojkam1@fel.cvut.cz>
Date: Tue, 9 Feb 2010 15:35:39 +0100
Subject: [PATCH] Suppress warning on amd64

---
 lib/database.cc |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 8641321..20a4c72 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -26,6 +26,9 @@
 #include <signal.h>
 #include <xapian.h>

+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
 #include <glib.h> /* g_free, GPtrArray, GHashTable */

 using namespace std;
@@ -1306,7 +1309,7 @@ _notmuch_database_generate_thread_id (notmuch_database_t *notmuch)

     notmuch->last_thread_id++;

-    sprintf (thread_id, "%016llx", notmuch->last_thread_id);
+    sprintf (thread_id, "%016"PRIx64, notmuch->last_thread_id);

     db->set_metadata ("last_thread_id", thread_id);

Thread: