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 900776DE0EA5 for ; Wed, 12 Jun 2019 13:18:14 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.398 X-Spam-Level: X-Spam-Status: No, score=-0.398 tagged_above=-999 required=5 tests=[AWL=-0.196, 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_HELO_PASS=-0.001, 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 WPe_OrSs7nbO for ; Wed, 12 Jun 2019 13:18:13 -0700 (PDT) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by arlo.cworth.org (Postfix) with ESMTPS id 06C396DE0E8C for ; Wed, 12 Jun 2019 13:18:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 43F993465E; Wed, 12 Jun 2019 22:18:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sgLAgrkhmvZX; Wed, 12 Jun 2019 22:18:08 +0200 (CEST) From: Jorge P. de Morais Neto DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1560370688; bh=dx2cCMfTnI4kmBfITAZL97ruaD+/cQH/53WqgdxRCIQ=; h=From:To:Subject:In-Reply-To:References:Date; b=eprFWU2HorM5dGCwCOsI2ff4ZxY85II6nJNcgG0Q0Wpi89RF5BXo8Q2QlNckE2DJq hU7LKZSLhb6h5G3D/SY3xUP/oTQl2Qb6q+tf8FlXleNjnHiJC7wLV/SMAk0d9gwlDs GCRPmHlGGpZnUIBBNe2mb090sfo3mCPPXtfIurT3VmYo2GQScNp7Lx5azzShJJDHNQ YmTNQ7M8XDOpCax1oOUHoxLgA1TN3EfyRa3WqPGMtE/oEOG34CrJ5I/HPNNwRlz7br aeF2bmVXey6186u5S2ONJFgEGi//ifl3IqvIR92dZcK0ape+ga4qZbnLKbH7y9SMOr WMX4zys10iZgQ== To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 1/7] cli: replace use of !! with macro In-Reply-To: <20190612113506.2892-2-david@tethera.net> References: <20190612113506.2892-1-david@tethera.net> <20190612113506.2892-2-david@tethera.net> User-Agent: Notmuch/0.28.4 (https://notmuchmail.org) Emacs/26.2.50 (x86_64-pc-linux-gnu) Date: Wed, 12 Jun 2019 17:17:57 -0300 Message-ID: <87r27yh822.fsf@disroot.org> 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: Wed, 12 Jun 2019 20:18:14 -0000 Hi. Isn't it good practice to parenthesize the arguments of C macros? So TO_BOOL would be defined as #define TO_BOOL(thing) (!! (thing)) In fact, why not just cast to bool? Regards David Bremner writes: > The slightly annoying reason to do this is because uncrustify can't > handle '!! foo' sensibly. The less annoying reason is that it helps > understand what the code does. > --- > command-line-arguments.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/command-line-arguments.c b/command-line-arguments.c > index d64aa85b..5f0607be 100644 > --- a/command-line-arguments.c > +++ b/command-line-arguments.c > @@ -4,6 +4,8 @@ > #include "error_util.h" > #include "command-line-arguments.h" > > +#define TO_BOOL(thing) (!! thing) > + > typedef enum { > OPT_FAILED, /* false */ > OPT_OK, /* good */ > @@ -120,13 +122,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; > + TO_BOOL (opt_desc->opt_inherit) + > + TO_BOOL (opt_desc->opt_bool) + > + TO_BOOL (opt_desc->opt_int) + > + TO_BOOL (opt_desc->opt_keyword) + > + TO_BOOL (opt_desc->opt_flags) + > + TO_BOOL (opt_desc->opt_string) + > + TO_BOOL (opt_desc->opt_position); > } > > /* Return true if opt_desc is valid. */ > -- > 2.20.1 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch -- - I am Brazilian. I hope my English is correct and I welcome feedback - Please adopt free formats like PDF, ODF, Org, LaTeX, Opus, WebM and 7z - Free/libre software for Android: https://f-droid.org/ - [[https://www.gnu.org/philosophy/free-sw.html][What is free software?]]