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,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 C80F41F8C6 for ; Sat, 31 Jul 2021 19:53:02 +0000 (UTC) Received: from localhost ([::1]:51846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9v2b-0000qd-IQ for normalperson@yhbt.net; Sat, 31 Jul 2021 15:53:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9v2W-0000pF-WD for bug-gnulib@gnu.org; Sat, 31 Jul 2021 15:52:57 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9v2U-0006xT-3U for bug-gnulib@gnu.org; Sat, 31 Jul 2021 15:52:56 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B2DB816007D for ; Sat, 31 Jul 2021 12:52:51 -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 CKvDKJ74S0c8 for ; Sat, 31 Jul 2021 12:52:50 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D5E151600DB for ; Sat, 31 Jul 2021 12:52:50 -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 l7TKiUX9Voec for ; Sat, 31 Jul 2021 12:52:50 -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 B01B216007D for ; Sat, 31 Jul 2021 12:52:50 -0700 (PDT) To: Gnulib bugs From: Paul Eggert Organization: UCLA Computer Science Department Subject: Using C2x attributes more effectively in Gnulib Message-ID: <0ed0a5a4-ed41-7d40-1c31-f422b55e7ab3@cs.ucla.edu> Date: Sat, 31 Jul 2021 12:52:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 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, 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" Because draft C2x requires using [[maybe_unused]] before a parameter=20 instead of after, the recent C2x-related changes to Gnulib caused me to=20 move all uses of _GL_UNUSED_PARAMETER; and while I was at it I changed=20 it to _GL_ATTRIBUTE_MAYBE_UNUSED FILE thus removing a dependency on the=20 snippet/unused-parameter module. For example: SE_SELINUX_INLINE int -fsetfilecon (int fd _GL_UNUSED_PARAMETER, - char const *con _GL_UNUSED_PARAMETER) +fsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED int fd, + _GL_ATTRIBUTE_MAYBE_UNUSED char const *con) { errno =3D ENOTSUP; return -1; } A nice property of the change is that the text lines up a bit better.=20 However, _GL_ATTRIBUTE_MAYBE_UNUSED is too long, so I propose we rename=20 it to something shorter. Also, draft C2x lets one write the above function without naming the=20 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=20 *definitely* unused instead of merely *maybe* unused, and that allows a=20 bit more checking of the code. So, how about the following ideas: * Rename _GL_ATTRIBUTE_MAYBE_UNUSED to _GL_maybe_unused. Similarly for=20 _GL_deprecated, _GL_fallthrough, and _GL_nodiscard. As C2x becomes more=20 popular, it'll be easy to read _GL_deprecated as shorthand for=20 "[[deprecated]] if supported, empty otherwise". Using lowercase in the=20 macro names helps readability and will help avoid collisions between=20 future C2x-like attributes and other Gnulib macros. * Remove all uses of _GL_UNUSED after arguments in Gnulib, replacing=20 them with _GL_maybe_unused before arguments. This will support non-GCC=20 C2x compilers better. Deprecate _GL_UNUSED. * Define a macro _GL_UNUSED_ARG(TYPE, NAME) that expands to 'TYPE' in=20 draft C2x, and to '_GL_maybe_unused TYPE NAME' otherwise. That way, one=20 can write: SE_SELINUX_INLINE int fsetfilecon (_GL_UNUSED_ARG (int, fd), _GL_UNUSED_ARG (char const *, con)) { errno =3D ENOTSUP; return -1; } * Define a macro _GL_UNUSED_ARGNAME(NAME) that expands to NAME if not=20 draft C2x, empty otherwise. Programs can use this macro for complicated=20 argument types where _GL_UNUSED_ARG does not suffice, e.g.,=20 '_GL_maybe_unused int (*_GL_UNUSED_ARGNAME (p)) (int)'. * Remove the snippet/unused-parameter module as it's not used now.