Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp751729pxm; Thu, 3 Mar 2022 04:03:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJ0DfO6QBojmxIp/18Ixb3pZjSZNN32QIBAz+HY0gy+uj/ffZBNWFhNL7xB80jqF8oosCJ X-Received: by 2002:a17:902:7895:b0:14b:6b63:b3fa with SMTP id q21-20020a170902789500b0014b6b63b3famr35556334pll.156.1646308999824; Thu, 03 Mar 2022 04:03:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646308999; cv=none; d=google.com; s=arc-20160816; b=paj/nKPscHMUUfEpsZUvQ7pgFJJ8dy9L5Cqd3+OnK7EJ2xJIoSKykeLwq77eDK0+Ru aVu5ISrLf0IUfzbBNA22IiGF+h64I4mqVlR0vMVfAdvHNSEjHgj/3LaKdpoODnwCi3zE FM9M/rpJQYd3HZb3UxU6ryuUCpONzHdqUyLbkrpoaRstF1q4W7cJW5j/I6g1ugThsgSJ hJcOaDw+COxSmkVEIMljal2VdmTHrgYp1HlZY4vTkNIKyYCWHgFry4LnP7QvsTk+sSig nanUo425YdtF/dPsSJNZQfGe3EIlEyuJhpup8M/4ZJuqPIq/Q+1NMrmmx1ikvoXbZ7rB D1pg== 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=W2WVlCnXFvMOrLc4mPPs6IXwCyxQ4RSsoH0bV29VTpA=; b=Et5eCO4qNSmUAglvn/5AkmAhscs132nGfJmltYfv/QzqS50lZr0bDQUzrBxWfp4v5V m+FDLR2j+CUXSwXPxKzBvVxE/Y93ZP3BghOJBKxDKs61WUvQXVOW66CQVhilYc2DeMDj vWrYMECzC2HaMELPGAjC+Vg0nCru0AeKbxEi2aMqyGWRQKD+UGETr6mB7DO7OE14Tled d+5Se/C+/KwpqXupcJqP5OPLEDyxAOYasWeQ79rLTNfOe+hTlsRH/FZqBsSa1wotxrtx caBUOmQP5QqUS3W4WntcVcJ6pzhKUsfq+NVB7aRP/RmasyWt7DMEaNaXw252BAUpSAOt 5hVg== 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 q13-20020a17090aa00d00b001bc737bd8f5si7720417pjp.84.2022.03.03.04.02.56; Thu, 03 Mar 2022 04:03:19 -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 S232661AbiCCLJM (ORCPT + 99 others); Thu, 3 Mar 2022 06:09:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232584AbiCCLJK (ORCPT ); Thu, 3 Mar 2022 06:09:10 -0500 Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB7FFD1E for ; Thu, 3 Mar 2022 03:08:24 -0800 (PST) Received: from localhost.localdomain ([106.133.35.137]) by smtp.orange.fr with ESMTPA id PjJPnAkkavjW4PjJdnUr4r; Thu, 03 Mar 2022 12:08:22 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: MDU0YmViZGZmMDIzYiBlMiM2NTczNTRjNWZkZTMwOGRiOGQ4ODf3NWI1ZTMyMzdiODlhOQ== X-ME-Date: Thu, 03 Mar 2022 12:08:22 +0100 X-ME-IP: 106.133.35.137 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] x86/bug: __WARN_FLAGS: prevent shadowing by renaming local variable f to __flags Date: Thu, 3 Mar 2022 20:07:55 +0900 Message-Id: <20220303110755.24147-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/v4.10/process/coding-style.html#macros-enums-and-rtl fixes: bfb1a7c91fb7 ("x86/bug: Merge annotate_reachable() into _BUG_FLAGS() asm") Signed-off-by: Vincent Mailhol --- 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