mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Halaney <ahalaney@redhat.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] init/main.c: silence some -Wunused-parameter warnings
Date: Mon, 18 Oct 2021 08:58:38 -0500	[thread overview]
Message-ID: <20211018135838.tdrjqsllozazqa7q@halaneylaptop> (raw)
In-Reply-To: <f06b8308-645b-031b-f9c6-b92400a269aa@rasmusvillemoes.dk>

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


      reply	other threads:[~2021-10-18 14:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 16:23 Andrew Halaney
2021-05-20  4:37 ` Andrew Morton
2021-05-20 13:03   ` Andrew Halaney
2021-05-21  7:34     ` Rasmus Villemoes
2021-10-18 13:58       ` Andrew Halaney [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211018135838.tdrjqsllozazqa7q@halaneylaptop \
    --to=ahalaney@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®