Re: [PATCH 4/5] fix wrong printf formatting of signed/unsigned integers

Subject: Re: [PATCH 4/5] fix wrong printf formatting of signed/unsigned integers

Date: Mon, 26 Jun 2017 10:04:25 -0300

To: Piotr Trojanek, Daniel Kahn Gillmor

Cc: notmuch@notmuchmail.org

From: David Bremner


Piotr Trojanek <piotr.trojanek@gmail.com> writes:

> For the second FIXME, I don't quite see why not just use the bsearch
> function. It could be called either with strcmp (if exact is true) or
> with a simple wrapper around strncmp (if exact is false). This wrapper
> could replace the string_cmp routine, so together with bsearch this
> could even make the code smaller.

AFAIK, bsearch does not guarantee to return the first string matching
the key, which is what we need here.

>
> Also, I don't really understand the intention behind declaring
> string_cmp as returning notmuch_bool_t and then, in bsearch_first,
> casting its result to int.

yes, that looks odd to me also, especially since it really just wraps
strcmp / strncmp, which are signed. Probably just an error on my part.

d

Thread: