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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 18 Oct 2021 08:58:38 -0500
From:   Andrew Halaney <ahalaney@...hat.com>
To:     Rasmus Villemoes <linux@...musvillemoes.dk>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] init/main.c: silence some -Wunused-parameter warnings

On Fri, May 21, 2021 at 09:34:45AM +0200, Rasmus Villemoes wrote:
> On 20/05/2021 15.03, Andrew Halaney wrote:
> > On Wed, May 19, 2021 at 09:37:31PM -0700, Andrew Morton wrote:
> >> On Wed, 19 May 2021 11:23:41 -0500 Andrew Halaney <ahalaney@...hat.com> wrote:
> >>
> 
> > If we decide we don't care about such warnings then feel free to ignore
> > this patch, but since I was playing around here anyways I thought I'd
> > clean it up a little. My preference would be to care, but the output is
> > so loud it is easy to make the argument that it is too late to start
> > caring.
> 
> Those always-unused annotations are quite verbose. Could we instead
> allow both int (*)(char *) and int (*)(void) functions via some macro
> magic, say extending __setup_param to something like (entirely untested)
> 
> #define __setup_param(str, unique_id, fn, early)                    \
>         static const char __setup_str_##unique_id[] __initconst     \
>                 __aligned(1) = str;                                 \
> +       static_assert(same_type(&fn, int (*)(char *)) || same_type(&fn,
> int (*)(void)));
>         static struct obs_kernel_param __setup_##unique_id          \
>                 __used __section(".init.setup")                     \
>                 __aligned(__alignof__(struct obs_kernel_param))     \
> -                = { __setup_str_##unique_id, fn, early }
> +                = { __setup_str_##unique_id, (int (*)(char *)fn, early }
> 
> That would still require modifying each callback, but then it would be
> to the more plain-C
> 
> int foo(void) // yeah, this doesn't use any parameters
> 
> I checked, the transparent_union trick doesn't work for static
> initialization.
> 
> But really, the compiler should have some heuristic that said "hm, ok,
> the address of this function was taken so it probably has that prototype
> because it has to be that way". I bet that would remove 90% of the
> Wunused-parameter noise.
> 
> Rasmus
> 

Sorry for the way late reply Rasmus, my spam filter has been flagging a
few things incorrectly and this was one.

I'll be completely honest, both the macro magic and teaching the
compiler are things I'm not familiar with. If I get some free
time I'll look more into the macro magic approach to see if anything is
possible, but I wouldn't hold your breath for a speedy update :P

Thanks,
Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ