Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp166882pxp; Sat, 5 Mar 2022 00:57:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUuRKMWvumsewVHaSr2phBg+b3aN6/9joJUpdVBLJyqHv5FcNn4/s4Sj3DafYYuHtlcPHz X-Received: by 2002:a17:90a:1f4d:b0:1bb:a657:ace5 with SMTP id y13-20020a17090a1f4d00b001bba657ace5mr14554984pjy.39.1646470646805; Sat, 05 Mar 2022 00:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646470646; cv=none; d=google.com; s=arc-20160816; b=kZcpq2X89o1hOtL4B+OWRbI3fDMSL4bk68RompQkxvI0/OpYh0/tLIBNoTURnPciZ9 3IPtB4M7mcogln4gcvyYl8B3HTW+ikwX+61g67MxqM+NFfEcXh3SuRpbbgNqWm5ZP0pq xu27cctvXdvp1LTzjNsqsf/ITG6ZBilSeIDzKy4iRr9sHZbCyW/TJ5seeZEwX7kJhcrh KGxqan+ilF9yPJhfZfgVntoqEHT3KssQI5AHj9WgBW36VVxoIZ0nU/A9BqXEZQTmPGgV 4ZQ8vdT5+anzZk+94IPRZIq71a79KtZKbbDTFsrjrpvZoOIO+5kzS6PdPP/ARoe9vkUf 7FpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zkOG+K6NjbwTehAPwQYjOzi8UwOfG9D2oWxDR8dVyLE=; b=SqFf5hjppid1vEyU/wNiApaZZvIUG7fAMjR1IVGpqdvhoQ2TiTBr9AqSVXojNmlL5x aKVPLuwSGJArL3Oo6U0/Rxy+I9TKWabeiJylEH5ifwrJlnwtmnYsY++gMGvwiUCC1+Aq Becl1Ag8iry9DuSbe600TmxJjfaBLzx1dEQFcFQVLpxnJChWyxSQw63uctrg27Lgr/xj o7mT05igoIQxVJlvsRY9kCgOZ/+EytGAdkkkwmzeUPu04sqp8eUg0eHlXkeLrCW6OrHc XQae/EIBKhacSUZViF7zrxtRy/Ssmn6hQqwuerYVt12s+ybOdfcCCgByUQX+0vrou5JN N3sQ== 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 k11-20020a170902ce0b00b0015181e7ef98si7029924plg.69.2022.03.05.00.57.10; Sat, 05 Mar 2022 00:57:26 -0800 (PST) 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 S231143AbiCEEBC (ORCPT + 99 others); Fri, 4 Mar 2022 23:01:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbiCEEBB (ORCPT ); Fri, 4 Mar 2022 23:01:01 -0500 Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06FA48880 for ; Fri, 4 Mar 2022 20:00:11 -0800 (PST) Received: from localhost.localdomain ([106.133.30.151]) by smtp.orange.fr with ESMTPA id QLa9ndULWQTuBQLaMn8sXz; Sat, 05 Mar 2022 05:00:09 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: MDU0YmViZGZmMDIzYiBlMiM2NTczNTRjNWZkZTMwOGRiOGQ4ODf3NWI1ZTMyMzdiODlhOQ== X-ME-Date: Sat, 05 Mar 2022 05:00:09 +0100 X-ME-IP: 106.133.30.151 From: Vincent Mailhol To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: linux-kernel@vger.kernel.org, "H . Peter Anvin" , Nick Desaulniers , Alexey Dobriyan , Josh Poimboeuf , Vincent Mailhol Subject: [PATCH v2] x86/bug: __WARN_FLAGS: prevent shadowing by renaming local variable f to __flags Date: Sat, 5 Mar 2022 12:59:43 +0900 Message-Id: <20220305035943.2420331-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 The macro __WARN_FLAGS() uses a local variable named "f". This being a common name, there is a risk of shadowing other variables. For example: | In file included from ./include/linux/bug.h:5, | from ./include/linux/cpumask.h:14, | from ./arch/x86/include/asm/cpumask.h:5, | from ./arch/x86/include/asm/msr.h:11, | from ./arch/x86/include/asm/processor.h:22, | from ./arch/x86/include/asm/timex.h:5, | from ./include/linux/timex.h:65, | from ./include/linux/time32.h:13, | from ./include/linux/time.h:60, | from ./include/linux/stat.h:19, | from ./include/linux/module.h:13, | from virt/lib/irqbypass.mod.c:1: | ./include/linux/rcupdate.h: In function 'rcu_head_after_call_rcu': | ./arch/x86/include/asm/bug.h:80:21: warning: declaration of 'f' shadows a parameter [-Wshadow] | 80 | __auto_type f = BUGFLAG_WARNING|(flags); \ | | ^ | ./include/asm-generic/bug.h:106:17: note: in expansion of macro '__WARN_FLAGS' | 106 | __WARN_FLAGS(BUGFLAG_ONCE | \ | | ^~~~~~~~~~~~ | ./include/linux/rcupdate.h:1007:9: note: in expansion of macro 'WARN_ON_ONCE' | 1007 | WARN_ON_ONCE(func != (rcu_callback_t)~0L); | | ^~~~~~~~~~~~ | In file included from ./include/linux/rbtree.h:24, | from ./include/linux/mm_types.h:11, | from ./include/linux/buildid.h:5, | from ./include/linux/module.h:14, | from virt/lib/irqbypass.mod.c:1: | ./include/linux/rcupdate.h:1001:62: note: shadowed declaration is here | 1001 | rcu_head_after_call_rcu(struct rcu_head *rhp, rcu_callback_t f) | | ~~~~~~~~~~~~~~~^ This patch renames the variable from f to __flags (with two underscore prefixes as suggested in the Linux kernel coding style [1]) in order to prevent collisions. [1] Linux kernel coding style, section 12) Macros, Enums and RTL, paragraph 5) namespace collisions when defining local variables in macros resembling functions https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl Fixes: bfb1a7c91fb7 ("x86/bug: Merge annotate_reachable() into_BUG_FLAGS() asm") Acked-by: Josh Poimboeuf Reviewed-by: Nick Desaulniers Signed-off-by: Vincent Mailhol --- Changelog: v1 -> v2: * Update the reference link to the kernel documentation to latest version. * Do not break the Fixes: tag to a new line. * Added the Acked-by and Reviewed-by tags. --- arch/x86/include/asm/bug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index bab883c0b6fe..66570e95af39 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -77,9 +77,9 @@ do { \ */ #define __WARN_FLAGS(flags) \ do { \ - __auto_type f = BUGFLAG_WARNING|(flags); \ + __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, f, ASM_REACHABLE); \ + _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ instrumentation_end(); \ } while (0) -- 2.34.1