Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753797AbdGSMzb (ORCPT ); Wed, 19 Jul 2017 08:55:31 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:49821 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753740AbdGSMz1 (ORCPT ); Wed, 19 Jul 2017 08:55:27 -0400 From: Arnd Bergmann To: x86@kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Thomas Gleixner , "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Alexander Shishkin , Andy Lutomirski , Josh Poimboeuf Subject: [PATCH 1/8] perf/x86: shut up false-positive -Wmaybe-uninitialized warning Date: Wed, 19 Jul 2017 14:52:59 +0200 Message-Id: <20170719125310.2487451-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170719125310.2487451-1-arnd@arndb.de> References: <20170719125310.2487451-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:tBqGbSNp/372vv3mDfo1YevP9LtlvuALFs+8E+BPdaAACB4+4Q6 CC9KogGKYQfmqdhn04KHax7o4P8IgaODwR+BqIlk4J4BuIM66H23tWaWBhrvSy7oSdZ9WD5 FIzkYNP5INkubjTz6xgWj2ZSxHnQMvvcdb8YJjM8OU/XY3jj4g41D4C+GGAvscoEu7A7LBi bDQeD0htygVNq/2nrtiyw== X-UI-Out-Filterresults: notjunk:1;V01:K0:FVR0qPjccaQ=:0fzd48w59xbqXlhviAhL8+ eI+D4DJREO/knbylIhrC1cP87nqPT1RJm4Xl7E5SKAnBk84siLUeSrO7msFPfycI629rg07M5 v3a+c/s752x7kjVZ3UEqnLLrOfwG1H/QWiC7n+yfQJrPvrH1uL1j3vfOTHPzOvRzBuw0/QrxC egi8dsW8aB2mbqiSH/r3lx5rvjqJ/4reim+sTBCQmj7t+3GcC1Im3zYk1n7darEcZDBQOdzB+ Yp1Gn4So4LwjmBOQU9/SUlX0o98uxCV257AdEzZVvuzONQVe7SAxSozQ5nbarUA5azcScTCH2 ElyvUCls5s4xlOy558jhLrqqf6fh0rrBcImzoTomJY/q8vd1Ftm+ftTSzZIEdFAaDhJYdcUQk N/O+o8ownOp0L8DbeX6oSaDBk86nRTb4Gw0y7M8fa2fiAOqWkGpEE8wy8OrYu7quUaah8JzhU ce/aLR3cvMTpLreLpqhbdXGLq4YRFju1qucchIci0kSONcGDEapKXAtqlIszd12Elmu3TTDJV DNUgQ+yJfdWwKGUsB8lJ+e2ct1n9cqFLlyE2vK6QI9LlPjMt6+48q8Xb6jqKet0sJf9vO5D1k qTayzHdGRd7Dayqh7my2MypiaYrpCQqoQORHj3YpBCb8sZJ08LTDNmWusTQOV/00SE9eOS+Og TxL7/gFtiR5ofp2gOxopbR1z6cNn7VrLDdWaPuVJD6VAnOn4Pn2xciQSOWZNZfLZiCwLO8uPj D+hOFpUjxecCUARig+X9Whny7hMcmHpCsInOEmOori+XnPSJ2kdXmgC1Dd8= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1528 Lines: 40 The intialization function checks for various failure scenarios, but unfortunately the compiler gets a little confused about the possible combinations, leading to a false-positive build warning when -Wmaybe-uninitialized is set: arch/x86/events/core.c: In function ‘init_hw_perf_events’: arch/x86/events/core.c:264:3: warning: ‘reg_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] arch/x86/events/core.c:264:3: warning: ‘val_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] pr_err(FW_BUG "the BIOS has corrupted hw-PMU resources (MSR %x is %Lx)\n", We can't actually run into this case, so this shuts up the warning by initializing the variables to a known-invalid state. Link: https://patchwork.kernel.org/patch/9392595/ Suggested-by: Peter Zijlstra Signed-off-by: Arnd Bergmann --- v2: replaced original patch that reordered the code instead of adding a fake initialization. --- arch/x86/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index ff1ea2fb9705..8e3db8f642a7 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -191,8 +191,8 @@ static void release_pmc_hardware(void) {} static bool check_hw_exists(void) { - u64 val, val_fail, val_new= ~0; - int i, reg, reg_fail, ret = 0; + u64 val, val_fail = -1, val_new= ~0; + int i, reg, reg_fail = -1, ret = 0; int bios_fail = 0; int reg_safe = -1; -- 2.9.0