From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3EdR9XAoKB5oG4LGMNLIHAAIIAF8.6IGHINGO6BHINGO6BG4CF.ILA@flex--marmstrong.bounces.google.com> Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 7B2936DE1039 for ; Mon, 4 Mar 2019 17:42:43 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -7.807 X-Spam-Level: X-Spam-Status: No, score=-7.807 tagged_above=-999 required=5 tests=[AWL=-0.107, DKIMWL_WL_MED=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ecP5KlotjVT0 for ; Mon, 4 Mar 2019 17:42:42 -0800 (PST) Received: from mail-yw1-f74.google.com (mail-yw1-f74.google.com [209.85.161.74]) by arlo.cworth.org (Postfix) with ESMTPS id A17DB6DE0F80 for ; Mon, 4 Mar 2019 17:42:42 -0800 (PST) Received: by mail-yw1-f74.google.com with SMTP id c8so10974507ywa.0 for ; Mon, 04 Mar 2019 17:42:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to; bh=TJN2KshJzGPDdupGiizXU1b/dL2XkqJT4mIoqr+h2WA=; b=Zf2fKAbYd6WuyjTFxzDwWRyjQ8scW9XOGwyJ7Dh+jcJEULgrCtOMDhpfmDwr0rm4V0 I6iavKV1RRk1Bw+EyHotESfp2dx/ZT/9pmzzwQLwXPKpJjABydjAMuyPNgNG4RYb/QLe AGDVf042Wz57Ttus9CJZOUkH/RTbHnJFZXg23/FKmAmkzjtv3UvA78/usE814X3BDFlb CzdO9cu5GwKFg2Af38mMxOFqCKXO87DuUiQf55sdIYKM256tz9tEuhsJXxabQD9VipXN ica3du+oHjIUVO+1IN/2E8Z6lR3WeLYGLAffBFXc/CGyMwhQ0TsgEzZ1isnjzXboOXSy hl2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=TJN2KshJzGPDdupGiizXU1b/dL2XkqJT4mIoqr+h2WA=; b=c8lTwbkaYGmyVwdSSpV88BO+XgXvTmUhaCzLz0p78IOS08GaJ7oeLteedyLriNCN7p TdNhaNdzfozWihpAmGB8vVhWdfWDOQgkJJSHmvNbAb7Kq00RHWtERVIiTtzxQo8KMZ/A QmB4/88vSjEk73FRFjpSNl7muo5a9ICaiX+1uQB4WgFWFMlf0hSYM8UgXAm6HwyNLfGY O0EeOD8kG6xbJ9hVAlEVN62HhxOWQVtM8cznfMCkKivESabDmjvy2k7z/eqn5RsWV1Xp y8lUW1T5BRIlPwEUDLwVIodAVfEtO/LrmE8UvDE57cDy5kR5sNRMXUicAlCS61H3qkhu 5DLQ== X-Gm-Message-State: APjAAAUopoxlGGUPrDcjFjMhB9Tcghk53bX1hhZEYUgrosJs6YM9rREI 23f2psGgtppYPanI0q2oQ8izB4sQ5VeJB23g X-Google-Smtp-Source: APXvYqzOZ7n/PenNYjMbO0Op3uC5FsNC+39EIU968WJ8WKGKpBemcQxa7Pz/gSwQ0xeHybDr0mHgzswnMu27xqzd X-Received: by 2002:a25:d6cc:: with SMTP id n195mr150401ybg.33.1551750161569; Mon, 04 Mar 2019 17:42:41 -0800 (PST) Date: Mon, 04 Mar 2019 17:42:39 -0800 In-Reply-To: <20190302183412.6822-1-david@tethera.net> Message-Id: Mime-Version: 1.0 References: <20190302183412.6822-1-david@tethera.net> Subject: Re: [PATCH] lib/string_map: fix return type of string_cmp From: Matt Armstrong To: David Bremner , notmuch@notmuchmail.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 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: Tue, 05 Mar 2019 01:42:43 -0000 David Bremner 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 > #include > 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.