lkml.org 
[lkml]   [2021]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@redhat.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

\
 
 \ /
  Last update: 2021-10-18 16:03    [W:0.499 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site