Skip to contentSkip to conversation

perf/x86: Fix 'may be used uninitialized' build warnings in core.c

PATCH In review Augusto Mecking Caringi 2 participants 2 messages Jan 5, 2017 – Jan 12, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/x86: Fix 'may be used uninitialized' build warnings in core.c

This patch fixes the following build warnings in core.c:

linux/arch/x86/events/core.c: In function ‘init_hw_perf_events’:
linux/include/linux/printk.h:292:2: warning: ‘reg_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^
linux/arch/x86/events/core.c:194:14: note: ‘reg_fail’ was declared here int i, reg, reg_fail, ret = 0;

linux/include/linux/printk.h:292:2: warning: ‘val_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^
linux/arch/x86/events/core.c:193:11: note: ‘val_fail’ was declared here u64 val, val_fail, val_new= ~0;

---
 arch/x86/events/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/events/core.c +2 -2
index 019c588..f6e41b4 100644
@@ -190,8 +190,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 = 0, val_new= ~0;
+	int i, reg, reg_fail = 0, ret = 0;
 	int bios_fail = 0;
 	int reg_safe = -1;
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 27 lines · Augusto Mecking Caringi

This patch fixes the following build warnings in core.c:

linux/arch/x86/events/core.c: In function ‘init_hw_perf_events’:
linux/include/linux/printk.h:292:2: warning: ‘reg_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^
linux/arch/x86/events/core.c:194:14: note: ‘reg_fail’ was declared here int i, reg, reg_fail, ret = 0;

linux/include/linux/printk.h:292:2: warning: ‘val_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^
linux/arch/x86/events/core.c:193:11: note: ‘val_fail’ was declared here u64 val, val_fail, val_new= ~0;

---
 arch/x86/events/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/events/core.c +0 -0
index 019c588..f6e41b4 100644

arch/x86/events/core.c static void release_pmc_hardware(void) {} · line 196

Quoted 9 lines
arch/x86/events/core.c +2 -2
@@ -190,8 +190,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 = 0, val_new= ~0;
+	int i, reg, reg_fail = 0, ret = 0;
 	int bios_fail = 0;
 	int reg_safe = -1;

What's not mentioned in the changelog is whether the warning was right or wrong - i.e. whether this patch changes behavior or silences a false positive warning.

Whether the compiler changed object code as result of this change would be good to know as well.

Thanks,

Ingo