--- /dev/null
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 21C0E431FBC\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 06:00:38 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.738\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.738 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id mnspBoGBoB+T for <notmuch@notmuchmail.org>;\r
+ Sat, 7 Mar 2015 06:00:35 -0800 (PST)\r
+Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
+ [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id B27C2431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 06:00:34 -0800 (PST)\r
+Received: by widex7 with SMTP id ex7so8954426wid.3\r
+ for <notmuch@notmuchmail.org>; Sat, 07 Mar 2015 06:00:33 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:subject:in-reply-to:references\r
+ :user-agent:date:message-id:mime-version:content-type;\r
+ bh=YVV2JUurDzsr6lc7zVUKUmcXy/5h5FAab/nRvI9XA9M=;\r
+ b=GJ+NqAIjJKqcNee0QTgSHrarFF4KZdEe/Es7+P/qx/6EG0Rc5cvCYwMn5u7enST+mu\r
+ /aZxuqHcV4gTVFloeIci82jLLtTkJuK0uI0IyxryKOjVFHTcXSamToVrMBpl+lRxX3yf\r
+ cbJFVhuWy4qIP8TU7e28fn1ckNeqlTjEweGpPzb6MXHbVXobMVLrTKEeQ82KLwLecRJB\r
+ bKBNMC4F8XDLaV8271N4zjbdiT42PIJY2z2exyEyjjzYIRsqZ2IkX1HnHptdyPe6QTqC\r
+ wRQIeOhBfoJWsUT/5bDC2wsSd9jaKL7xQX8aftN4HCfqVCxPMofMbp4ibS0T5gSH4KYA\r
+ rNww==\r
+X-Gm-Message-State:\r
+ ALoCoQnj/77iwdnWIVlmNOYH/FB8Q+dILdAT/Di6db9qPpimYww6sLkEmp+pAINzFbIRfHdbrCI6\r
+X-Received: by 10.180.82.129 with SMTP id i1mr42296183wiy.77.1425736833854;\r
+ Sat, 07 Mar 2015 06:00:33 -0800 (PST)\r
+Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi.\r
+ [188.238.59.76])\r
+ by mx.google.com with ESMTPSA id fa3sm6745204wib.17.2015.03.07.06.00.32\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sat, 07 Mar 2015 06:00:33 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/4] cli: update to use new count API\r
+In-Reply-To: <1425717797-19990-3-git-send-email-david@tethera.net>\r
+References: <1419971380-10307-6-git-send-email-david@tethera.net>\r
+ <1425717797-19990-1-git-send-email-david@tethera.net>\r
+ <1425717797-19990-3-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.19+74~g6aeef2e (http://notmuchmail.org) Emacs/24.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 07 Mar 2015 16:00:53 +0200\r
+Message-ID: <87sidgj4a2.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 07 Mar 2015 14:00:38 -0000\r
+\r
+On Sat, 07 Mar 2015, David Bremner <david@tethera.net> wrote:\r
+> Essentially replace each call to notmuch_count_* with an if block.\r
+\r
+LGTM, nitpicks inline.\r
+\r
+> ---\r
+> notmuch-count.c | 14 ++++++++++++--\r
+> notmuch-reply.c | 8 +++++++-\r
+> notmuch-search.c | 14 ++++++++++++--\r
+> notmuch-show.c | 8 +++++++-\r
+> 4 files changed, 38 insertions(+), 6 deletions(-)\r
+>\r
+> diff --git a/notmuch-count.c b/notmuch-count.c\r
+> index 6058f7c..cd6b0c9 100644\r
+> --- a/notmuch-count.c\r
+> +++ b/notmuch-count.c\r
+> @@ -71,6 +71,8 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+> {\r
+> notmuch_query_t *query;\r
+> size_t i;\r
+> + unsigned count;\r
+\r
+As I said in patch 1, I'd personally prefer "unsigned int".\r
+\r
+> + notmuch_status_t status;\r
+> \r
+> query = notmuch_query_create (notmuch, query_str);\r
+> if (query == NULL) {\r
+> @@ -83,10 +85,18 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+> \r
+> switch (output) {\r
+> case OUTPUT_MESSAGES:\r
+> - printf ("%u\n", notmuch_query_count_messages (query));\r
+> + if ((status = notmuch_query_count_messages_st (query, &count))) {\r
+\r
+I'd rather have the assignment and check in separate lines. Somehow I\r
+feel it emphasizes the distinction between the happy day flow and the\r
+unusual cases. Same for other hunks in this patch.\r
+\r
+> + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
+> + return 1;\r
+> + }\r
+> + printf ("%u\n", count);\r
+> break;\r
+> case OUTPUT_THREADS:\r
+> - printf ("%u\n", notmuch_query_count_threads (query));\r
+> + if ((status = notmuch_query_count_threads_st (query, &count))) {\r
+> + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
+> + return 1;\r
+> + }\r
+> + printf ("%u\n", count);\r
+> break;\r
+> case OUTPUT_FILES:\r
+> printf ("%u\n", count_files (query));\r
+> diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+> index 7c1c809..0b3e5fd 100644\r
+> --- a/notmuch-reply.c\r
+> +++ b/notmuch-reply.c\r
+> @@ -650,8 +650,14 @@ notmuch_reply_format_sprinter(void *ctx,\r
+> notmuch_messages_t *messages;\r
+> notmuch_message_t *message;\r
+> mime_node_t *node;\r
+> + unsigned count;\r
+> + notmuch_status_t status;\r
+> \r
+> - if (notmuch_query_count_messages (query) != 1) {\r
+> + if ((status = notmuch_query_count_messages_st (query, &count))) {\r
+> + fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
+> + return 1;\r
+> + }\r
+> + if (count != 1) {\r
+> fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+> return 1;\r
+> }\r
+> diff --git a/notmuch-search.c b/notmuch-search.c\r
+> index a591d45..ba631c0 100644\r
+> --- a/notmuch-search.c\r
+> +++ b/notmuch-search.c\r
+> @@ -113,7 +113,14 @@ do_search_threads (search_context_t *ctx)\r
+> int i;\r
+> \r
+> if (ctx->offset < 0) {\r
+> - ctx->offset += notmuch_query_count_threads (ctx->query);\r
+> + unsigned count;\r
+> + notmuch_status_t status;\r
+> + if ((status = notmuch_query_count_threads_st (ctx->query, &count))) {\r
+> + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
+> + return 1;\r
+> + }\r
+> +\r
+> + ctx->offset += count;\r
+> if (ctx->offset < 0)\r
+> ctx->offset = 0;\r
+> }\r
+> @@ -414,7 +421,10 @@ do_search_messages (search_context_t *ctx)\r
+> int i;\r
+> \r
+> if (ctx->offset < 0) {\r
+> - ctx->offset += notmuch_query_count_messages (ctx->query);\r
+> + unsigned count;\r
+> + if (notmuch_query_count_messages_st (ctx->query, &count))\r
+> + return 1;\r
+> + ctx->offset += count;\r
+> if (ctx->offset < 0)\r
+> ctx->offset = 0;\r
+> }\r
+> diff --git a/notmuch-show.c b/notmuch-show.c\r
+> index d416fbd..749b1af 100644\r
+> --- a/notmuch-show.c\r
+> +++ b/notmuch-show.c\r
+> @@ -982,8 +982,14 @@ do_show_single (void *ctx,\r
+> {\r
+> notmuch_messages_t *messages;\r
+> notmuch_message_t *message;\r
+> + unsigned count;\r
+> + notmuch_status_t status;\r
+> + if ((status = notmuch_query_count_messages_st (query, &count))) {\r
+> + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
+> + return 1;\r
+> + }\r
+> \r
+> - if (notmuch_query_count_messages (query) != 1) {\r
+> + if (count != 1) {\r
+> fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+> return 1;\r
+> }\r
+> -- \r
+> 2.1.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r