lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK8P3a32dWaCQV8Q1g0eoQD2PFb8Jt2pDHEkTJOMAoyJpOhD3w@mail.gmail.com>
Date:   Mon, 26 Oct 2020 20:22:09 +0100
From:   Arnd Bergmann <arnd@...nel.org>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     Nathan Chancellor <natechancellor@...il.com>,
        LKML <linux-kernel@...r.kernel.org>,
        clang-built-linux <clang-built-linux@...glegroups.com>,
        Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Subject: Re: [PATCH] ctype.h: remove duplicate isdigit() helper

On Mon, Oct 26, 2020 at 7:23 PM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@...glegroups.com> wrote:
>
> On Mon, Oct 26, 2020 at 9:23 AM Arnd Bergmann <arnd@...nel.org> wrote:
> >
> > From: Arnd Bergmann <arnd@...db.de>
> >
> > gcc warns a few thousand times about the isdigit() shadow:
> >
> > include/linux/ctype.h:26:19: warning: declaration of 'isdigit' shadows a built-in function [-Wshadow]
>
> Don't all functions defined here shadow builtins in GCC?  Why is
> `isdigit` unique?  Is that because it's a `static inline` definition
> vs a function like macro?  If that's the case, what's the harm in
> converting it to a function like macro if that silences the warning?

It was originally a macro but got changed to an inline function in
1204c77f9b6a ("include/linux/ctype.h: make isdigit() table lookupless"),
apparently in order to avoid evaluating the argument more than once.

I suppose we could make it a statement expression with a local
variable like

#define isdigit(c) ({ __auto_type __c = (c);  '0' <= __c && __c <= '9'; })

> > @@ -39,6 +35,18 @@ static inline int isdigit(int c)
> >  #define isascii(c) (((unsigned char)(c))<=0x7f)
> >  #define toascii(c) (((unsigned char)(c))&0x7f)
> >
> > +#if defined __has_builtin
>
> #ifdef
>
> only use `defined` explicitly when there's more than one condition
> being checked with logical `&&` or `||`.
>
> > +#if __has_builtin(__builtin_isdigit)
>
> GCC only recently gained the `__has_builtin` macro (I filed the bug);
> I would like to see something akin to
> include/linux/compiler_attributes.h but using `__has_builtin` like
> compiler_attributes.h uses `__has_attribute`.  That way we avoid
> spaghetti like this throughout the kernel.

Ok. I've added a 'has_builtin()' macro (without underscores)
in linux/compiler.h in version 2. I don't use it anywhere else
in my current series, so there should be no dependencies.

     Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ