[PATCH 5/6] lib: replace deprecated n_q_count_messages with status returning version

David Bremner david at tethera.net
Sun Feb 26 13:21:34 PST 2017


This function was deprecated in notmuch 0.21.  We re-use the name for
a status returning version, and deprecate the _st name. One or two
remaining uses of the (removed) non-status returning version fixed at
the same time
---
 bindings/python/notmuch/query.py |  2 +-
 bindings/ruby/query.c            |  2 +-
 lib/database.cc                  |  2 +-
 lib/message.cc                   |  2 +-
 lib/notmuch.h                    | 17 ++++++++---------
 lib/query.cc                     | 12 ++++--------
 notmuch-count.c                  |  2 +-
 notmuch-reply.c                  |  2 +-
 notmuch-search.c                 |  2 +-
 notmuch-show.c                   |  2 +-
 test/T560-lib-error.sh           |  4 ++--
 11 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py
index a91bb740..10fb6dcc 100644
--- a/bindings/python/notmuch/query.py
+++ b/bindings/python/notmuch/query.py
@@ -185,7 +185,7 @@ class Query(object):
             raise NullPointerError
         return Messages(msgs_p, self)
 
-    _count_messages = nmlib.notmuch_query_count_messages_st
+    _count_messages = nmlib.notmuch_query_count_messages
     _count_messages.argtypes = [NotmuchQueryP, POINTER(c_uint)]
     _count_messages.restype = c_uint
 
diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
index 2e36df6a..b6edaef3 100644
--- a/bindings/ruby/query.c
+++ b/bindings/ruby/query.c
@@ -180,7 +180,7 @@ notmuch_rb_query_count_messages (VALUE self)
 
     Data_Get_Notmuch_Query (self, query);
 
-    status = notmuch_query_count_messages_st (query, &count);
+    status = notmuch_query_count_messages (query, &count);
     if (status)
 	notmuch_rb_status_raise (status);
 
diff --git a/lib/database.cc b/lib/database.cc
index 13b9e647..4fc691ff 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1463,7 +1463,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
 	query = notmuch_query_create (notmuch, "");
 	unsigned msg_count;
 
-	status = notmuch_query_count_messages_st (query, &msg_count);
+	status = notmuch_query_count_messages (query, &msg_count);
 	if (status)
 	    goto DONE;
 
diff --git a/lib/message.cc b/lib/message.cc
index 007f1171..29e54425 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1123,7 +1123,7 @@ _notmuch_message_delete (notmuch_message_t *message)
     query = notmuch_query_create (notmuch, query_string);
     if (query == NULL)
 	return NOTMUCH_STATUS_OUT_OF_MEMORY;
-    status = notmuch_query_count_messages_st (query, &count);
+    status = notmuch_query_count_messages (query, &count);
     if (status) {
 	notmuch_query_destroy (query);
 	return status;
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 4b01e3ad..b79618f6 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1008,22 +1008,21 @@ notmuch_threads_destroy (notmuch_threads_t *threads);
  * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The
  *      value of *count is not defined.
  *
- * @since libnotmuch 4.3 (notmuch 0.21)
+ * @since libnotmuch 5 (notmuch 0.25)
  */
 notmuch_status_t
-notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
+notmuch_query_count_messages (notmuch_query_t *query, unsigned int *count);
 
 /**
- * like notmuch_query_count_messages_st, but without a status return.
+ * Deprecated alias for notmuch_query_count_messages
  *
- * May return 0 in the case of errors.
  *
- * @deprecated Deprecated since libnotmuch 4.3 (notmuch 0.21). Please
- * use notmuch_query_count_messages_st instead.
+ * @deprecated Deprecated since libnotmuch 5.0 (notmuch 0.25). Please
+ * use notmuch_query_count_messages instead.
  */
-NOTMUCH_DEPRECATED(4,3)
-unsigned int
-notmuch_query_count_messages (notmuch_query_t *query);
+NOTMUCH_DEPRECATED(5,0)
+notmuch_status_t
+notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
 
 /**
  * Return the number of threads matching a search.
diff --git a/lib/query.cc b/lib/query.cc
index 60d1db94..25b953c7 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -533,18 +533,14 @@ notmuch_threads_destroy (notmuch_threads_t *threads)
     talloc_free (threads);
 }
 
-unsigned int
-notmuch_query_count_messages (notmuch_query_t *query)
+notmuch_status_t
+notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)
 {
-    notmuch_status_t status;
-    unsigned int count;
-
-    status = notmuch_query_count_messages_st (query, &count);
-    return status ? 0 : count;
+    return notmuch_query_count_messages (query, count_out);
 }
 
 notmuch_status_t
-notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)
+notmuch_query_count_messages (notmuch_query_t *query, unsigned *count_out)
 {
     return _notmuch_query_count_documents (query, "mail", count_out);
 }
diff --git a/notmuch-count.c b/notmuch-count.c
index d3457bbe..493be30f 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -92,7 +92,7 @@ print_count (notmuch_database_t *notmuch, const char *query_str,
 
     switch (output) {
     case OUTPUT_MESSAGES:
-	status = notmuch_query_count_messages_st (query, &ucount);
+	status = notmuch_query_count_messages (query, &ucount);
 	if (print_status_query ("notmuch count", query, status))
 	    return -1;
 	printf ("%u", ucount);
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 2a3abfbd..f88f1c4e 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -630,7 +630,7 @@ static int do_reply(notmuch_config_t *config,
     if (format == FORMAT_JSON || format == FORMAT_SEXP) {
 	unsigned count;
 
-	status = notmuch_query_count_messages_st (query, &count);
+	status = notmuch_query_count_messages (query, &count);
 	if (print_status_query ("notmuch reply", query, status))
 	    return 1;
 
diff --git a/notmuch-search.c b/notmuch-search.c
index 1c4d5205..71218fdd 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -529,7 +529,7 @@ do_search_messages (search_context_t *ctx)
     if (ctx->offset < 0) {
 	unsigned count;
 	notmuch_status_t status;
-	status = notmuch_query_count_messages_st (ctx->query, &count);
+	status = notmuch_query_count_messages (ctx->query, &count);
 	if (print_status_query ("notmuch search", ctx->query, status))
 	    return 1;
 
diff --git a/notmuch-show.c b/notmuch-show.c
index 11eb0a6b..4a464ecd 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -912,7 +912,7 @@ do_show_single (void *ctx,
     notmuch_status_t status;
     unsigned int count;
 
-    status = notmuch_query_count_messages_st (query, &count);
+    status = notmuch_query_count_messages (query, &count);
     if (print_status_query ("notmuch show", query, status))
 	return 1;
 
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index ccb77b04..999493d7 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -302,9 +302,9 @@ backup_database
 test_begin_subtest "Xapian exception counting messages"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
    {
+       int count;
        notmuch_query_t *query=notmuch_query_create (db, "id:87ocn0qh6d.fsf at yoom.home.cworth.org");
-       int count = notmuch_query_count_messages (query);
-       stat = (count == 0);
+       stat = notmuch_query_count_messages (query, &count);
    }
 EOF
 sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean
-- 
2.11.0



More information about the notmuch mailing list