Skip to contentSkip to conversation

kvm/x86: Fix unused variable warning in kvm_timer_init()

PATCH Applied Borislav Petkov 2 participants 2 messages Sep 4, 2016 – Sep 29, 2016

Subsystems (3)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

PATCH 1/1 kvm/x86: Fix unused variable warning in kvm_timer_init()

From: Borislav Petkov <[email protected]>

When CONFIG_CPU_FREQ is not set, int cpu is unused and gcc rightfully warns about it:

arch/x86/kvm/x86.c: In function ‘kvm_timer_init’:
arch/x86/kvm/x86.c:5697:6: warning: unused variable ‘cpu’ [-Wunused-variable]

    int cpu;
        ^~~

But since it is used only in the CONFIG_CPU_FREQ block, simply move it there, thus squashing the warning too.

---
 arch/x86/kvm/x86.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +2 -2
index 19f9f9e05c2a..30bff0c1357a 100644
@@ -5694,13 +5694,13 @@ static int kvmclock_cpu_online(unsigned int cpu)
 
 static void kvm_timer_init(void)
 {
-	int cpu;
-
 	max_tsc_khz = tsc_khz;
 
 	if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
 #ifdef CONFIG_CPU_FREQ
 		struct cpufreq_policy policy;
+		int cpu;
+
 		memset(&policy, 0, sizeof(policy));
 		cpu = get_cpu();
 		cpufreq_get_policy(&policy, cpu);
Signature · 1 line
2.10.0
#1 lore raw

2016-09-04 19:13+0200, Borislav Petkov:

Quoted 7 lines

From: Borislav Petkov <[email protected]>

When CONFIG_CPU_FREQ is not set, int cpu is unused and gcc rightfully warns about it:

arch/x86/kvm/x86.c: In function ‘kvm_timer_init’:
arch/x86/kvm/x86.c:5697:6: warning: unused variable ‘cpu’ [-Wunused-variable]

Quoted 8 lines
    int cpu;
        ^~~

But since it is used only in the CONFIG_CPU_FREQ block, simply move it there, thus squashing the warning too.

---

Applied to kvm/queue, thanks.