linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Arnd Bergmann <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, jpoimboe@redhat.com,
	alexander.shishkin@linux.intel.com, acme@kernel.org,
	arnd@arndb.de, mingo@kernel.org, torvalds@linux-foundation.org,
	luto@kernel.org, hpa@zytor.com, tglx@linutronix.de,
	peterz@infradead.org
Subject: [tip:x86/urgent] perf/x86: Shut up false-positive -Wmaybe-uninitialized warning
Date: Thu, 20 Jul 2017 03:24:45 -0700	[thread overview]
Message-ID: <tip-11d8b05855f3749bcb6c57e2c4052921b9605c77@git.kernel.org> (raw)
In-Reply-To: <20170719125310.2487451-2-arnd@arndb.de>

Commit-ID:  11d8b05855f3749bcb6c57e2c4052921b9605c77
Gitweb:     http://git.kernel.org/tip/11d8b05855f3749bcb6c57e2c4052921b9605c77
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Wed, 19 Jul 2017 14:52:59 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 20 Jul 2017 10:46:23 +0200

perf/x86: Shut up false-positive -Wmaybe-uninitialized warning

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.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170719125310.2487451-2-arnd@arndb.de
Link: https://patchwork.kernel.org/patch/9392595/
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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 ff1ea2f..8e3db8f 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;
 

  reply	other threads:[~2017-07-20 10:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 12:52 [PATCH 0/8] x86: randconfig warning fixes Arnd Bergmann
2017-07-19 12:52 ` [PATCH 1/8] perf/x86: shut up false-positive -Wmaybe-uninitialized warning Arnd Bergmann
2017-07-20 10:24   ` tip-bot for Arnd Bergmann [this message]
2017-07-19 12:53 ` [PATCH 2/8] x86: math-emu: possible uninitialized variable use Arnd Bergmann
2017-07-20 10:25   ` [tip:x86/urgent] x86/fpu/math-emu: Fix " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 3/8] x86: math-emu: avoid bogus -Wint-in-bool-context warning Arnd Bergmann
2017-07-20 10:25   ` [tip:x86/urgent] x86/fpu/math-emu: Avoid " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 4/8] x86: io: add "memory" clobber to insb/insw/insl/outsb/outsw/outsl Arnd Bergmann
2017-07-19 19:25   ` Arnd Bergmann
2017-07-19 19:46   ` Linus Torvalds
2017-07-20 10:25   ` [tip:x86/urgent] x86/io: Add " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 5/8] x86: silence build with "make -s" Arnd Bergmann
2017-07-20 10:26   ` [tip:x86/urgent] x86/build: Silence the " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 6/8] x86: add MULTIUSER dependency for KVM Arnd Bergmann
2017-07-19 14:11   ` Radim Krčmář
2017-07-19 14:18     ` Arnd Bergmann
2017-07-19 16:13       ` Radim Krčmář
2017-07-23 13:41         ` Paolo Bonzini
2017-07-19 12:53 ` [PATCH 7/8] x86: add PCI dependency for PUNIT_ATOM_DEBUG Arnd Bergmann
2017-07-20 10:26   ` [tip:x86/urgent] x86/platform: Add " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 8/8] x86: intel-mid: fix a format string overflow warning Arnd Bergmann
2017-07-20 10:27   ` [tip:x86/urgent] x86/platform/intel-mid: Fix " tip-bot for Arnd Bergmann

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=tip-11d8b05855f3749bcb6c57e2c4052921b9605c77@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).