public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf/x86: Fix 'may be used uninitialized' build warnings in core.c
@ 2017-01-05 12:33 Augusto Mecking Caringi
  2017-01-12  8:30 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: Augusto Mecking Caringi @ 2017-01-05 12:33 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Augusto Mecking Caringi, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Thomas Gleixner, H. Peter Anvin, x86,
	linux-kernel

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;

Signed-off-by: Augusto Mecking Caringi <augustocaringi@gmail.com>
---
 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 019c588..f6e41b4 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -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;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf/x86: Fix 'may be used uninitialized' build warnings in core.c
  2017-01-05 12:33 [PATCH] perf/x86: Fix 'may be used uninitialized' build warnings in core.c Augusto Mecking Caringi
@ 2017-01-12  8:30 ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2017-01-12  8:30 UTC (permalink / raw)
  To: Augusto Mecking Caringi
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Thomas Gleixner, H. Peter Anvin, x86,
	linux-kernel


* Augusto Mecking Caringi <augustocaringi@gmail.com> wrote:

> 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;
> 
> Signed-off-by: Augusto Mecking Caringi <augustocaringi@gmail.com>
> ---
>  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 019c588..f6e41b4 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-12  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-05 12:33 [PATCH] perf/x86: Fix 'may be used uninitialized' build warnings in core.c Augusto Mecking Caringi
2017-01-12  8:30 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox