Skip to contentSkip to conversation

x86-tsc.c : fix compile warning

PATCH Applied Figo.zhang 5 participants 10 messages Jun 17, 2009 – Jun 18, 2009 1 message not in the archive x86

lore
Share & tools
lore

Figo.zhang

author
#0 lore raw

PATCH 1/1 x86-tsc.c : fix compile warning

fix compile warning:
arch/x86/kernel/tsc.c: In function ‘time_cpufreq_notifier’:
arch/x86/kernel/tsc.c:635: warning: ‘dummy’ may be used uninitialized in this function

---
arch/x86/kernel/tsc.c | 2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/tsc.c +1 -1
index ae3180c..e65492a 100644
@@ -632,7 +632,7 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
 				void *data)
 {
 	struct cpufreq_freqs *freq = data;
-	unsigned long *lpj, dummy;
+	unsigned long *lpj, dummy = 0;
 
 	if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
 		return 0;
#2 lore raw
In reply to a message not in the archive
Quoted 6 lines

fix compile warning:
arch/x86/kernel/tsc.c: In function ‘time_cpufreq_notifier’:
arch/x86/kernel/tsc.c:635: warning: ‘dummy’ may be used uninitialized in this function

Hello Figo,

Please refer to the following links on discussion on this issue earlier:
http://lkml.org/lkml/2009/5/19/312
http://lkml.org/lkml/2009/5/19/301
http://lkml.org/lkml/2009/5/20/23

I tried to fix it in some other way.

Regards--
Subrata

Quoted 19 lines

---
arch/x86/kernel/tsc.c | 2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/tsc.c +1 -1
index ae3180c..e65492a 100644
@@ -632,7 +632,7 @@ static int time_cpufreq_notifier(struct
 notifier_block *nb, unsigned long val,
                               void *data)
 {
       struct cpufreq_freqs *freq = data;
-       unsigned long *lpj, dummy;
+       unsigned long *lpj, dummy = 0;
 
       if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
               return 0;
author
#3 lore raw
Quoted 7 lines · Subrata Modak
Quoted 6 lines

fix compile warning:
arch/x86/kernel/tsc.c: In function ‘time_cpufreq_notifier’:
arch/x86/kernel/tsc.c:635: warning: ‘dummy’ may be used uninitialized in this function

Quoted 8 lines

Hello Figo,

Please refer to the following links on discussion on this issue earlier:
http://lkml.org/lkml/2009/5/19/312
http://lkml.org/lkml/2009/5/19/301
http://lkml.org/lkml/2009/5/20/23

I tried to fix it in some other way.

hi Subrata,

That is ok.

Best Regards,
Figo.zhang

Quoted 25 lines

Regards--
Subrata

Quoted 19 lines

---
arch/x86/kernel/tsc.c | 2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/tsc.c +1 -1
index ae3180c..e65492a 100644
@@ -632,7 +632,7 @@ static int time_cpufreq_notifier(struct
 notifier_block *nb, unsigned long val,
                               void *data)
 {
       struct cpufreq_freqs *freq = data;
-       unsigned long *lpj, dummy;
+       unsigned long *lpj, dummy = 0;
 
       if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
               return 0;
Applied
#4 lore raw
In reply to Subrata Modak
Quoted 7 lines · Subrata Modak
Quoted 6 lines

fix compile warning:
arch/x86/kernel/tsc.c: In function ‘time_cpufreq_notifier’:
arch/x86/kernel/tsc.c:635: warning: ‘dummy’ may be used uninitialized in this function

Quoted 8 lines

Hello Figo,

Please refer to the following links on discussion on this issue earlier:
http://lkml.org/lkml/2009/5/19/312
http://lkml.org/lkml/2009/5/19/301
http://lkml.org/lkml/2009/5/20/23

I tried to fix it in some other way.

Ah, and you fixed in what a superior way: you improved the code in the process :-) This is how warnings should be fixed really.

Applied.

We apparently missed it when you sent it in May - generally feel free to re-send patches if you dont see a commit notification within a few days.

Thanks,

Ingo

#5 lore raw
Quoted 16 lines · Ingo Molnar
Quoted 14 lines · Subrata Modak
Quoted 6 lines

fix compile warning:
arch/x86/kernel/tsc.c: In function ‘time_cpufreq_notifier’:
arch/x86/kernel/tsc.c:635: warning: ‘dummy’ may be used uninitialized in this function

Hello Figo,

Please refer to the following links on discussion on this issue earlier:
http://lkml.org/lkml/2009/5/19/312
http://lkml.org/lkml/2009/5/19/301
http://lkml.org/lkml/2009/5/20/23

Quoted 4 lines
Quoted 1 line

I tried to fix it in some other way.

Ah, and you fixed in what a superior way: you improved the code in the process :-) This is how warnings should be fixed really.

Thanks Ingo. I would do whenever i find again one.

Quoted 6 lines

Applied.

We apparently missed it when you sent it in May - generally feel free to re-send patches if you dont see a commit notification within a few days.

My mistake. I did not keep track.

Regards--
Subrata

Quoted 4 lines

Thanks,

Ingo

#6 lore raw
In reply to Ingo Molnar
Quoted 2 lines · Ingo Molnar

Ah, and you fixed in what a superior way: you improved the code in the process :-) This is how warnings should be fixed really.

Hmm. Did you also see Pavel's reply to that patch [1]:
! But that's a bug to be fixed, I'd say? ... actually I believe you are ! introducing a bug here. Yes, old code would put random numbers in ! loops_per_jiffy_ref for !CPUFREQ_CONST_LOOPS, but you are introducing ! oops there.

Was his comment incorrect?

Cheers,
FJP

[1] http://lkml.org/lkml/2009/5/24/159

#7 lore raw
Quoted 10 lines · Frans Pop
Quoted 2 lines · Ingo Molnar

Ah, and you fixed in what a superior way: you improved the code in the process :-) This is how warnings should be fixed really.

Hmm. Did you also see Pavel's reply to that patch [1]:
! But that's a bug to be fixed, I'd say? ... actually I believe you are ! introducing a bug here. Yes, old code would put random numbers in ! loops_per_jiffy_ref for !CPUFREQ_CONST_LOOPS, but you are introducing ! oops there.

Quoted 6 lines

Was his comment incorrect?

Cheers,
FJP

[1] http://lkml.org/lkml/2009/5/24/159

hm, Pavel seems right - i missed that. Subrata, mind sending an updated patch?

Thanks,

Ingo

#8 lore raw
Quoted 14 lines · Ingo Molnar
Quoted 12 lines · Frans Pop
Quoted 2 lines · Ingo Molnar

Ah, and you fixed in what a superior way: you improved the code in the process :-) This is how warnings should be fixed really.

Hmm. Did you also see Pavel's reply to that patch [1]:
! But that's a bug to be fixed, I'd say? ... actually I believe you are ! introducing a bug here. Yes, old code would put random numbers in ! loops_per_jiffy_ref for !CPUFREQ_CONST_LOOPS, but you are introducing ! oops there.

Was his comment incorrect?

Quoted 7 lines
Quoted 4 lines

Cheers,
FJP

[1] http://lkml.org/lkml/2009/5/24/159

hm, Pavel seems right - i missed that. Subrata, mind sending an updated patch?

Hmmm. I would try doing that soon.

Regards--
Subrata

Quoted 4 lines

Thanks,

Ingo

#9 lore raw
In reply to Ingo Molnar
Quoted 15 lines · Ingo Molnar
Quoted 12 lines · Frans Pop
Quoted 2 lines · Ingo Molnar

Ah, and you fixed in what a superior way: you improved the code in the process :-) This is how warnings should be fixed really.

Hmm. Did you also see Pavel's reply to that patch [1]:
! But that's a bug to be fixed, I'd say? ... actually I believe you are ! introducing a bug here. Yes, old code would put random numbers in ! loops_per_jiffy_ref for !CPUFREQ_CONST_LOOPS, but you are introducing ! oops there.

Was his comment incorrect?

Quoted 8 lines
Quoted 4 lines

Cheers,
FJP

[1] http://lkml.org/lkml/2009/5/24/159

hm, Pavel seems right - i missed that. Subrata, mind sending an updated patch?

Hi, Ingo,

Yes, it does seem that we'll oops at *lpj, but to be honest the code is badly written, ideally the CONFIG_SMP part should be abstracted out, having that in a if loop makes reading it time consuming and kills a few neuro cells each time.

Signature · 1 line
	Balbir
#10 lore raw
Quoted 26 lines · Balbir Singh
Quoted 15 lines · Ingo Molnar
Quoted 12 lines · Frans Pop
Quoted 2 lines · Ingo Molnar

Ah, and you fixed in what a superior way: you improved the code in the process :-) This is how warnings should be fixed really.

Hmm. Did you also see Pavel's reply to that patch [1]:
! But that's a bug to be fixed, I'd say? ... actually I believe you are ! introducing a bug here. Yes, old code would put random numbers in ! loops_per_jiffy_ref for !CPUFREQ_CONST_LOOPS, but you are introducing ! oops there.

Was his comment incorrect?

Quoted 8 lines
Quoted 4 lines

Cheers,
FJP

[1] http://lkml.org/lkml/2009/5/24/159

hm, Pavel seems right - i missed that. Subrata, mind sending an updated patch?

Quoted 6 lines

Hi, Ingo,

Yes, it does seem that we'll oops at *lpj, but to be honest the code is badly written, ideally the CONFIG_SMP part should be abstracted out, having that in a if loop makes reading it time consuming and kills a few neuro cells each time.

Balbir/Ingo,

I find this fixed in todayś Linus´s git tree. dummy has been removed, and, so does lpj initialization taking place properly.

631 static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
632 void *data)
633 {
634 struct cpufreq_freqs *freq = data;
635 unsigned long *lpj;
636
637 if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
638 return 0;
639
640 lpj = &boot_cpu_data.loops_per_jiffy;

this gets initialized here for the first time on any system.

641 #ifdef CONFIG_SMP
642 if (!(freq->flags & CPUFREQ_CONST_LOOPS))
643 lpj = &cpu_data(freq->cpu).loops_per_jiffy;
644 #endif

And gets re-assigned if CONFIG_SMP.

Regards--
Subrata

Quoted 2 lines