From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A97AE1F8C6 for ; Mon, 9 Aug 2021 10:09:03 +0000 (UTC) Received: from localhost ([::1]:33114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD2DO-0006Bt-4t for normalperson@yhbt.net; Mon, 09 Aug 2021 06:09:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD2DJ-0006BK-Gp for bug-gnulib@gnu.org; Mon, 09 Aug 2021 06:08:57 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:53080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD2DG-0007sz-Sm for bug-gnulib@gnu.org; Mon, 09 Aug 2021 06:08:57 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 05A481600EF; Mon, 9 Aug 2021 03:08:52 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 2Fp_TEvEzhAm; Mon, 9 Aug 2021 03:08:51 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2A8001600F3; Mon, 9 Aug 2021 03:08:51 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id F9cvvsE7ztDk; Mon, 9 Aug 2021 03:08:51 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 04E5F1600EF; Mon, 9 Aug 2021 03:08:51 -0700 (PDT) To: Bruno Haible , bug-gnulib@gnu.org References: <0ed0a5a4-ed41-7d40-1c31-f422b55e7ab3@cs.ucla.edu> <37018291.SK6AWJdEcI@omega> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: Using C2x attributes more effectively in Gnulib Message-ID: <997c192f-7736-e0a3-0c04-7596d7bf6f5b@cs.ucla.edu> Date: Mon, 9 Aug 2021 03:08:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <37018291.SK6AWJdEcI@omega> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" On 8/7/21 6:40 PM, Bruno Haible wrote: >> Also, draft C2x lets one write the above function without naming the >> parameters, as follows: >> >> SE_SELINUX_INLINE int >> fsetfilecon (int, char const *) >> { errno =3D ENOTSUP; return -1; } >> >> This is nicer than [[maybe_unused]], because it says the arguments are >> *definitely* unused instead of merely *maybe* unused, and that allows = a >> bit more checking of the code. >=20 > I disagree on this one. For a human reader who wants to understand the = code, > the parameter name is more important than its type. OK, perhaps this would do instead (assuming C2x): SE_SELINUX_INLINE int fsetfilecon (int /*fd*/, char const * /*context*/) { errno =3D ENOTSUP; return -1; } > they have designed > this language feature from the perspective what the compiler needs in > order to generate machine code It's more than just machine code. It's telling the reader that the=20 arguments are definitely unused. This gives the reader more information=20 than [[maybe_unused]] does. It's a C2x feature I find helpful from a readability point of view,=20 since I find the names to be clutter in situations like these. Indeed,=20 I'd rather see something like this: SE_SELINUX_INLINE fsetfilecon { errno =3D ENOTSUP; return -1; } since setfilecon's signature (which I can easily navigate to, or ask=20 about) tells me all I need to know about the API that doesn't matter here= . Admittedly readability tastes differ. > I have personally used mixed-case macro names in GNU clisp, and I can > assert (in hindsight) that it did *not* contribute to maintainability. Fair enough; let's stick to uppercase. > Hmm. This _GL_UNUSED macro is used a lot in .c code, simply because it > it short (and the "maybe" in _GL_ATTRIBUTE_MAYBE_UNUSED is more of a > compiler technicality). It's not merely a technicality. I often write code where an argument may=20 be unused, in the sense that there's an ifdef where it's used on some=20 platforms but not others. MAYBE_UNUSED is helpful in this situations. > I'm OK with moving all _GL_UNUSED from after > the parameter declaration to before the parameter declaration. Then > we can continue to have > #define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED Yes, this sounds like a win. It's a lot simpler than my proposal.=20 Although it loses a bit of information when the arg is definitely=20 unused, perhaps that's not worth worrying about. >> * Remove the snippet/unused-parameter module as it's not used now. >=20 > Indeed, this module is unused in gnulib. It may be used in packages tha= t > use gnulib; therefore I vote for marking it 'obsolete' and remove it on= ly > in a year or two. Sounds good to me too.