public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irqdomain: do not shadow nr_irqs global definition
Date: Fri, 29 Jul 2022 10:16:02 +0100	[thread overview]
Message-ID: <2e3ef1724d1d9acdbbf1a80487891a7f@kernel.org> (raw)
In-Reply-To: <20220729090307.57905-1-mailhol.vincent@wanadoo.fr>

On 2022-07-29 10:03, Vincent Mailhol wrote:
> include/linux/irqnr.h declares a global variable named `nr_irqs'.
> 
> The inline function irq_domain_alloc_irqs() from
> include/linux/irqdomain.h also uses the same name and thus shadow the
> global declaration. Rename the function argument from `nr_irqs' to
> `nbr_irqs'.
> 
> This patch silences below -Wshadow warning:
> 
> | In file included from ./arch/x86/include/asm/irqdomain.h:5,
> |                  from ./arch/x86/include/asm/msi.h:5,
> |                  from ./include/linux/msi.h:23,
> |                  from ./include/linux/kvm_host.h:19,
> |                  from arch/x86/kernel/../kvm/vmx/vmx.h:5,
> |                  from arch/x86/kernel/asm-offsets.c:22:
> | ./include/linux/irqdomain.h: In function 'irq_domain_alloc_irqs':
> | ./include/linux/irqdomain.h:514:38: warning: declaration of
> 'nr_irqs' shadows a global declaration [-Wshadow]
> |   514 |                         unsigned int nr_irqs, int node, void 
> *arg)
> |       |                         ~~~~~~~~~~~~~^~~~~~~
> | In file included from ./include/linux/interrupt.h:10,
> |                  from ./include/linux/kernel_stat.h:9,
> |                  from ./include/linux/cgroup.h:26,
> |                  from ./include/linux/memcontrol.h:13,
> |                  from ./include/linux/swap.h:9,
> |                  from ./include/linux/suspend.h:5,
> |                  from arch/x86/kernel/asm-offsets.c:13:
> | ./include/linux/irqnr.h:8:12: note: shadowed declaration is here
> |     8 | extern int nr_irqs;
> |       |            ^~~~~~~
> 
> Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> ---
>  include/linux/irqdomain.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
> index 00d577f90883..76949bb029b0 100644
> --- a/include/linux/irqdomain.h
> +++ b/include/linux/irqdomain.h
> @@ -511,9 +511,9 @@ extern int irq_domain_activate_irq(struct irq_data
> *irq_data, bool early);
>  extern void irq_domain_deactivate_irq(struct irq_data *irq_data);
> 
>  static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
> -			unsigned int nr_irqs, int node, void *arg)
> +					unsigned int nbr_irqs, int node, void *arg)
>  {
> -	return __irq_domain_alloc_irqs(domain, -1, nr_irqs, node, arg, false,
> +	return __irq_domain_alloc_irqs(domain, -1, nbr_irqs, node, arg, 
> false,
>  				       NULL);
>  }

I really don't think this is worth it. A function has its
own namespace, and this warning is on the long list of
"this is completely silly". Case in point:

$ git grep 'unsigned int nr_irqs'| wc -l
207

Is anything broken? Not as far as I can tell.

If there was anything to fix, it is the top-level definition
that should be more indicative of its global status. But again,
there is nothing broken so far.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2022-07-29  9:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29  9:03 [PATCH] irqdomain: do not shadow nr_irqs global definition Vincent Mailhol
2022-07-29  9:16 ` Marc Zyngier [this message]
2022-07-29 11:12   ` Vincent MAILHOL
2022-07-30  4:26     ` Vincent MAILHOL

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=2e3ef1724d1d9acdbbf1a80487891a7f@kernel.org \
    --to=maz@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    /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