Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp704633imn; Fri, 29 Jul 2022 22:50:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vCc/7rdt/eBns0ngYehwnNTtb8/5o/ECtl1oSYtG1zseVZBvn3ZbT+IFYKvOO8VwG5obDk X-Received: by 2002:a05:6402:48c:b0:43a:8bc7:f440 with SMTP id k12-20020a056402048c00b0043a8bc7f440mr6628634edv.8.1659160246539; Fri, 29 Jul 2022 22:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659160246; cv=none; d=google.com; s=arc-20160816; b=t/0u/YkO2rKq8azy43JHzs1RAdzuXX3D8qPZ2DE0sgM9wBepJ5layvneejFbR7Ysdm 4atLJNvhAECoFHCl9Hb4LcnxE6ZexbvPU2yZCPRNMl/TXvd4UM/HVeEFlv3YIxlHEXZi wdkVRuUOJXS2gs3/K33OSakAuZgTvhs29ZABrk8grjIuqasCgwnBwa7FGbP16NGCTqZI nF6+7+uwAS7Yp4M5TrrDBm8lroN92xAzdIbgV/8kCjJ6VIFTG3pPtUv9RlwABKkfD81+ puUKsCW1B5pvztnZJVX7KNzvJc9DHvPN0uEd4pH1vGFhXFsKE+28l4u7IxRUxDvGmuz8 VVdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=gzsdefuadf9H+aE6G/CtU3WmTBAcp2YL8ABvJGwjcew=; b=vaqONSY31R66u5vEUPVwYlV5V9IlGZ5j5Z4liXbFSi27dAmRTupiVV+C5ZDsK40CkG qtpCm+lc0TCnJBRy1pbQk2mkcJcVpAzJOlQhV5mQ4THog705flyQLBdaQxgwUfAeq+1Y sm3kckK16dYfkIRGLO5MHZKdM64I7CZX06n4t+3tJecBPCn3lMsmu2C3pXnneUNYU1zH XxaSzodauThbt5ihAuOmAgq2BZ99r6o2ySy01ht82JuiAWdjpa75r2Ung5xix4RzjtfP QX7z2eeS1ZAbBZTGazL7t/wRrgSnWptTHnsMJoFpbEic0msv1jtqCEHTX7kWyOghRzAb f8jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv19-20020a17090760d300b0070bb971358csi6232455ejc.195.2022.07.29.22.49.59; Fri, 29 Jul 2022 22:50:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239891AbiG3E0g (ORCPT + 99 others); Sat, 30 Jul 2022 00:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234072AbiG3E0f (ORCPT ); Sat, 30 Jul 2022 00:26:35 -0400 Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51567FD3 for ; Fri, 29 Jul 2022 21:26:34 -0700 (PDT) Received: by mail-yb1-f180.google.com with SMTP id 141so11084742ybn.4 for ; Fri, 29 Jul 2022 21:26:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gzsdefuadf9H+aE6G/CtU3WmTBAcp2YL8ABvJGwjcew=; b=yzFdn6bauv5da3EBoeXs5JkVt5HMWnnNejbXxH85NjTw/jm163qZO5s6xWK4F7lKAy gPpAjr+Z+ee1rIYepNqeo/DC8EQ3LbeF7E2/iGa/1raCoV0hyyoBq7f9ZMRofHEqzi4m SUNDcjkizmNan97OhSyaCKlQkXox3YJGIskwmZktHlGyhs2lKXC75ZdxCSOi0C64Z//+ M8CAv9l6+aquSjPjpCExdKXH5KMzZepzfSH2I49JMP1S3Fm4oEUD2uBtTw9rcFn1tkyS i+YZKpAWaKCcAEmWZNA53x1mTpiQiv1Ix/R2F5Qd3pQKc9nxib/t66zuvcpSICbjCAiW s+Zw== X-Gm-Message-State: ACgBeo2RTlJGBM/bfyNXZsiPociWAxcUdXOyXBp9Fs5S4FepBSxRgm/a mVKYQcYOXUgp3i7og3bQHkuwoqHIEgMc44CL9t2MkiUAb4M= X-Received: by 2002:a25:3789:0:b0:671:6d58:f242 with SMTP id e131-20020a253789000000b006716d58f242mr4770892yba.142.1659155193430; Fri, 29 Jul 2022 21:26:33 -0700 (PDT) MIME-Version: 1.0 References: <20220729090307.57905-1-mailhol.vincent@wanadoo.fr> <2e3ef1724d1d9acdbbf1a80487891a7f@kernel.org> In-Reply-To: From: Vincent MAILHOL Date: Sat, 30 Jul 2022 13:26:21 +0900 Message-ID: Subject: Re: [PATCH] irqdomain: do not shadow nr_irqs global definition To: Marc Zyngier Cc: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri. 29 Jul. 2022 at 20:12, Vincent MAILHOL wrote: > On Fri. 29 juil. 2022 at 18:16, Marc Zyngier wrote: > > 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 > > > --- > > > 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. > > Nothing is broken, my only concern is that this occurs in a header > file and thus the warning will pop up in random files which include > this header. > > | git grep "unsigned int nr_irqs" include/ arch/*/include | wc -l > | 17 > (and all static inline function which trigger the warning are from > linux/irqdomain.h) > > Time to time, I check the W=2 output and spam from the headers makes > it annoying to triage. I absolutely do not care of shadowing > everywhere else outside of the includes directory. > > > 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. > > This is also feasible, but it will become a tree-wide patch. And I am > quite certain that it will be NACKed right away, so I will not try > this alternate solution. To add some figures, on a "make allyesconfig" (linux-next branch, x86_64 build, gcc 12), there are in total 36005 -Wshadow and irqdomain.h accounts for 7094 of all these (i.e. this patch suppresses roughly one fifth of all -Wshadow warnings tree wide). Yours sincerely, Vincent Mailhol