From 3eaf42e4ff055ef656babb63bcbf3d5dd4b6950c Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 7 Mar 2015 20:23:00 +0100 Subject: [PATCH] [PATCH 3/5] cli/lib: remove most use of deprecated notmuch_query_search_{messages,threads} --- 89/71dd61d08a8d5c08c9370927c6c36fa28cb453 | 319 ++++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 89/71dd61d08a8d5c08c9370927c6c36fa28cb453 diff --git a/89/71dd61d08a8d5c08c9370927c6c36fa28cb453 b/89/71dd61d08a8d5c08c9370927c6c36fa28cb453 new file mode 100644 index 000000000..27cb9c137 --- /dev/null +++ b/89/71dd61d08a8d5c08c9370927c6c36fa28cb453 @@ -0,0 +1,319 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 893B6431FD0 + for ; Sat, 7 Mar 2015 11:25:17 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.438 +X-Spam-Level: ** +X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id UhEWiXOnKj4W for ; + Sat, 7 Mar 2015 11:25:15 -0800 (PST) +Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net + [87.98.215.224]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id E04D5431FCB + for ; Sat, 7 Mar 2015 11:25:14 -0800 (PST) +Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim + 4.80) (envelope-from ) + id 1YUKKv-0004Du-Hs; Sat, 07 Mar 2015 19:24:33 +0000 +Received: (nullmailer pid 28725 invoked by uid 1000); Sat, 07 Mar 2015 + 19:23:13 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH 3/5] cli/lib: remove most use of deprecated + notmuch_query_search_{messages,threads} +Date: Sat, 7 Mar 2015 20:23:00 +0100 +Message-Id: <1425756182-28468-4-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1425756182-28468-1-git-send-email-david@tethera.net> +References: <1425756182-28468-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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, 07 Mar 2015 19:25:17 -0000 + +There two remaining cases in the lib that seem to require more than a +simple replacement of the old call, with the new call plus a check of +the return value. +--- + lib/database.cc | 2 ++ + lib/query.cc | 4 +++- + lib/thread.cc | 2 ++ + notmuch-count.c | 5 +++-- + notmuch-dump.c | 7 ++++++- + notmuch-reply.c | 25 ++++++++++++++++++++++--- + notmuch-search.c | 21 +++++++++++++++------ + notmuch-show.c | 13 ++++++++++--- + notmuch-tag.c | 8 +++++++- + 9 files changed, 70 insertions(+), 17 deletions(-) + +diff --git a/lib/database.cc b/lib/database.cc +index 3974e2e..8680963 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -1306,6 +1306,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, + notmuch_message_t *message; + char *filename; + ++ /* XXX: this should use the _st version, but needs an error ++ path */ + for (messages = notmuch_query_search_messages (query); + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) +diff --git a/lib/query.cc b/lib/query.cc +index 9279915..1871a81 100644 +--- a/lib/query.cc ++++ b/lib/query.cc +@@ -610,7 +610,9 @@ notmuch_query_count_threads (notmuch_query_t *query) + + sort = query->sort; + query->sort = NOTMUCH_SORT_UNSORTED; +- messages = notmuch_query_search_messages (query); ++ ret = notmuch_query_search_messages_st (query, &messages); ++ if (ret) ++ return ret; + query->sort = sort; + if (messages == NULL) + return 0; +diff --git a/lib/thread.cc b/lib/thread.cc +index 9847cf8..c8e58c3 100644 +--- a/lib/thread.cc ++++ b/lib/thread.cc +@@ -504,6 +504,8 @@ _notmuch_thread_create (void *ctx, + * oldest or newest subject is desired. */ + notmuch_query_set_sort (thread_id_query, NOTMUCH_SORT_OLDEST_FIRST); + ++ /* XXX: this should use the _st version, but it needs an error path ++ */ + for (messages = notmuch_query_search_messages (thread_id_query); + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) +diff --git a/notmuch-count.c b/notmuch-count.c +index 6058f7c..d555bf1 100644 +--- a/notmuch-count.c ++++ b/notmuch-count.c +@@ -39,10 +39,11 @@ count_files (notmuch_query_t *query) + notmuch_messages_t *messages; + notmuch_message_t *message; + notmuch_filenames_t *filenames; ++ notmuch_status_t status; + unsigned int count = 0; + +- messages = notmuch_query_search_messages (query); +- if (messages == NULL) ++ status = notmuch_query_search_messages_st (query, &messages); ++ if (status) + return 0; + + for (; +diff --git a/notmuch-dump.c b/notmuch-dump.c +index 9c6ad7f..c6154a9 100644 +--- a/notmuch-dump.c ++++ b/notmuch-dump.c +@@ -48,8 +48,13 @@ database_dump_file (notmuch_database_t *notmuch, gzFile output, + + char *buffer = NULL; + size_t buffer_size = 0; ++ notmuch_status_t status; + +- for (messages = notmuch_query_search_messages (query); ++ status = notmuch_query_search_messages_st (query, &messages); ++ if (status) ++ return EXIT_FAILURE; ++ ++ for (; + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) { + int first = 1; +diff --git a/notmuch-reply.c b/notmuch-reply.c +index 7c1c809..dca4e42 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -606,8 +606,15 @@ notmuch_reply_format_default(void *ctx, + notmuch_messages_t *messages; + notmuch_message_t *message; + mime_node_t *root; ++ notmuch_status_t status; + +- for (messages = notmuch_query_search_messages (query); ++ status = notmuch_query_search_messages_st (query, &messages); ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); ++ return 1; ++ } ++ ++ for (; + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) + { +@@ -656,7 +663,12 @@ notmuch_reply_format_sprinter(void *ctx, + return 1; + } + +- messages = notmuch_query_search_messages (query); ++ status = notmuch_query_search_messages_st (query, &messages); ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); ++ return 1; ++ } ++ + message = notmuch_messages_get (messages); + if (mime_node_open (ctx, message, &(params->crypto), &node) != NOTMUCH_STATUS_SUCCESS) + return 1; +@@ -698,8 +710,15 @@ notmuch_reply_format_headers_only(void *ctx, + notmuch_message_t *message; + const char *in_reply_to, *orig_references, *references; + char *reply_headers; ++ notmuch_status_t status; + +- for (messages = notmuch_query_search_messages (query); ++ status = notmuch_query_search_messages_st (query, &messages); ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); ++ return 1; ++ } ++ ++ for (; + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) + { +diff --git a/notmuch-search.c b/notmuch-search.c +index a591d45..20feda4 100644 +--- a/notmuch-search.c ++++ b/notmuch-search.c +@@ -111,6 +111,7 @@ do_search_threads (search_context_t *ctx) + sprinter_t *format = ctx->format; + time_t date; + int i; ++ notmuch_status_t status; + + if (ctx->offset < 0) { + ctx->offset += notmuch_query_count_threads (ctx->query); +@@ -118,9 +119,11 @@ do_search_threads (search_context_t *ctx) + ctx->offset = 0; + } + +- threads = notmuch_query_search_threads (ctx->query); +- if (threads == NULL) ++ status = notmuch_query_search_threads_st (ctx->query, &threads); ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); + return 1; ++ } + + format->begin_list (format); + +@@ -412,6 +415,7 @@ do_search_messages (search_context_t *ctx) + notmuch_filenames_t *filenames; + sprinter_t *format = ctx->format; + int i; ++ notmuch_status_t status; + + if (ctx->offset < 0) { + ctx->offset += notmuch_query_count_messages (ctx->query); +@@ -419,9 +423,11 @@ do_search_messages (search_context_t *ctx) + ctx->offset = 0; + } + +- messages = notmuch_query_search_messages (ctx->query); +- if (messages == NULL) ++ status = notmuch_query_search_messages_st (ctx->query, &messages); ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); + return 1; ++ } + + format->begin_list (format); + +@@ -508,9 +514,12 @@ do_search_tags (const search_context_t *ctx) + if (strcmp (notmuch_query_get_query_string (query), "*") == 0) { + tags = notmuch_database_get_all_tags (notmuch); + } else { +- messages = notmuch_query_search_messages (query); +- if (messages == NULL) ++ notmuch_status_t status; ++ status = notmuch_query_search_messages_st (query, &messages); ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); + return 1; ++ } + + tags = notmuch_messages_collect_tags (messages); + } +diff --git a/notmuch-show.c b/notmuch-show.c +index d416fbd..af8741d 100644 +--- a/notmuch-show.c ++++ b/notmuch-show.c +@@ -988,7 +988,12 @@ do_show_single (void *ctx, + return 1; + } + +- messages = notmuch_query_search_messages (query); ++ status = notmuch_query_search_messages_st (query, &messages); ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); ++ return 1; ++ } ++ + message = notmuch_messages_get (messages); + + if (message == NULL) { +@@ -1015,9 +1020,11 @@ do_show (void *ctx, + notmuch_messages_t *messages; + notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; + +- threads = notmuch_query_search_threads (query); +- if (! threads) ++ status= notmuch_query_search_threads_st (query, &threads); ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); + return 1; ++ } + + sp->begin_list (sp); + +diff --git a/notmuch-tag.c b/notmuch-tag.c +index 5b2f1e4..dcaca43 100644 +--- a/notmuch-tag.c ++++ b/notmuch-tag.c +@@ -97,6 +97,8 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string, + notmuch_query_t *query; + notmuch_messages_t *messages; + notmuch_message_t *message; ++ notmuch_status_t status; ++ + int ret = NOTMUCH_STATUS_SUCCESS; + + if (! (flags & TAG_FLAG_REMOVE_ALL)) { +@@ -119,7 +121,11 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string, + /* tagging is not interested in any special sort order */ + notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED); + +- for (messages = notmuch_query_search_messages (query); ++ status = notmuch_query_search_messages_st (query, &messages); ++ if (status) ++ return status; ++ ++ for (; + notmuch_messages_valid (messages) && ! interrupted; + notmuch_messages_move_to_next (messages)) { + message = notmuch_messages_get (messages); +-- +2.1.4 + -- 2.26.2