unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Matt Armstrong <marmstrong@google.com>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH] lib/string_map: fix return type of string_cmp
Date: Mon, 04 Mar 2019 17:42:39 -0800	[thread overview]
Message-ID: <qf5k1heumeo.fsf@naz.kir.corp.google.com> (raw)
In-Reply-To: <20190302183412.6822-1-david@tethera.net>

David Bremner <david@tethera.net> writes:

> I can't figure out how checking the sign of a bool ever worked. The
> following program demonstrates the problem (i.e. for me it prints 1).
>
>  #include <stdio.h>
>  #include <stdbool.h>
>  int main(int argc, char **argv) {
>     bool x;
>     x = -1;
>     printf("x = %d\n", x);
>  }
>
> This seems to be mandated by the C99 standard 6.3.1.2.

Perhaps it never did work?  It looks like this function to date is used
only for properties, where I assume each message has just one or two?
With just a few elements a buggy binary search can do surprisingly well.
Don't ask me how I know this.  ;-)

Perhaps some unit tests for _notmuch_string_map would be worthwhile?


> ---
>
>  I'd like to get this in a new point release ASAP.
>
>  lib/string-map.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/string-map.c b/lib/string-map.c
> index ad818207..a88404c7 100644
> --- a/lib/string-map.c
> +++ b/lib/string-map.c
> @@ -106,7 +106,7 @@ _notmuch_string_map_sort (notmuch_string_map_t *map)
>      map->sorted = true;
>  }
>  
> -static bool
> +static int
>  string_cmp (const char *a, const char *b, bool exact)
>  {
>      if (exact)
> -- 

Looks good.

  reply	other threads:[~2019-03-05  1:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-02 18:34 [PATCH] lib/string_map: fix return type of string_cmp David Bremner
2019-03-05  1:42 ` Matt Armstrong [this message]
2019-03-05 19:29   ` David Bremner
2019-03-06  0:45     ` Matt Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=qf5k1heumeo.fsf@naz.kir.corp.google.com \
    --to=marmstrong@google.com \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).