From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 4D35B6DE1050 for ; Sun, 16 Jun 2019 22:01:47 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.05 X-Spam-Level: X-Spam-Status: No, score=-0.05 tagged_above=-999 required=5 tests=[AWL=-0.049, SPF_PASS=-0.001] 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 f3Zu6ZAvRm1e for ; Sun, 16 Jun 2019 22:01:46 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 3D36D6DE0F19 for ; Sun, 16 Jun 2019 22:01:45 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1hcjm3-0001lF-00; Mon, 17 Jun 2019 01:01:43 -0400 Received: (nullmailer pid 597 invoked by uid 1000); Mon, 17 Jun 2019 05:01:39 -0000 From: David Bremner To: Daniel Kahn Gillmor , notmuch@notmuchmail.org Subject: Re: [PATCH 3/8] CLI: replace some constructs with more uncrustify friendly ones In-Reply-To: <87blyx1mp0.fsf@fifthhorseman.net> References: <20190613110837.6256-1-david@tethera.net> <20190613110837.6256-4-david@tethera.net> <87blyx1mp0.fsf@fifthhorseman.net> Date: Mon, 17 Jun 2019 01:01:39 -0400 Message-ID: <87zhmgiz4c.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain 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: Mon, 17 Jun 2019 05:01:47 -0000 Daniel Kahn Gillmor writes: > On Thu 2019-06-13 08:08:32 -0300, David Bremner wrote: >> - add parens in some ternery operators > > itym "ternary" yep. > >> @@ -120,13 +120,13 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char * >> static int _opt_set_count (const notmuch_opt_desc_t *opt_desc) >> { >> return >> - !!opt_desc->opt_inherit + >> - !!opt_desc->opt_bool + >> - !!opt_desc->opt_int + >> - !!opt_desc->opt_keyword + >> - !!opt_desc->opt_flags + >> - !!opt_desc->opt_string + >> - !!opt_desc->opt_position; >> + (bool) opt_desc->opt_inherit + >> + (bool) opt_desc->opt_bool + >> + (bool) opt_desc->opt_int + >> + (bool) opt_desc->opt_keyword + >> + (bool) opt_desc->opt_flags + >> + (bool) opt_desc->opt_string + >> + (bool) opt_desc->opt_position; >> } > > i find this is deeply weird. It looks like it is coercing various types > into bools, and then summing a list of bools. > > While the spec might well say that the sum of two bools should be an int > (i haven't checked), it's not at all obvious to me that the infix + > operator should assume that type. (float + float is a float, not an > int, for example) Yes, the C11 standard seems pretty clear here, 6.3.1.{1,2} > > in some sense, the !! operator works better here because i know that its > output is likely to be an int, so summing makes sense. > For whatever reason I never used this idiom much. I _think_ it should be replaced in new code with (bool), but I don't feel strongly about it. There's an argument to be made that we should really just use ternary operators there. I would accept a patch to do that if you feel strongly enough. d