Skip to contentSkip to conversation

x86: kvm: avoid unused variable warning

PATCH Applied Arnd Bergmann 3 participants 3 messages Aug 20, 2018 – Aug 22, 2018

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

PATCH 1/1 x86: kvm: avoid unused variable warning

Removing one of the two accesses of the maxphyaddr variable led to a harmless warning:

arch/x86/kvm/x86.c: In function 'kvm_set_mmio_spte_mask':
arch/x86/kvm/x86.c:6563:6: error: unused variable 'maxphyaddr' [-Werror=unused-variable]

Removing the #ifdef seems to be the nicest workaround, as it makes the code look cleaner than adding another #ifdef.

Fixes 28a1f3ac1d0c ("kvm: x86: Set highest physical address bits in non-present/reserved SPTEs")
---
 arch/x86/kvm/x86.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kvm/x86.c +1 -3
index 4a74a7cf0a8b..506bd2b4b8bb 100644
@@ -6576,14 +6576,12 @@ static void kvm_set_mmio_spte_mask(void)
 	/* Set the present bit. */
 	mask |= 1ull;
 
-#ifdef CONFIG_X86_64
 	/*
 	 * If reserved bit is not supported, clear the present bit to disable
 	 * mmio page fault.
 	 */
-	if (maxphyaddr == 52)
+	if (IS_ENABLED(CONFIG_X86_64) && maxphyaddr == 52)
 		mask &= ~1ull;
-#endif
 
 	kvm_mmu_set_mmio_spte_mask(mask, mask);
 }
Signature · 1 line
2.18.0
maintainer Applied
#1 lore raw
Quoted 26 lines · Arnd Bergmann

Removing one of the two accesses of the maxphyaddr variable led to a harmless warning:

arch/x86/kvm/x86.c: In function 'kvm_set_mmio_spte_mask':
arch/x86/kvm/x86.c:6563:6: error: unused variable 'maxphyaddr' [-Werror=unused-variable]

Removing the #ifdef seems to be the nicest workaround, as it makes the code look cleaner than adding another #ifdef.

Fixes 28a1f3ac1d0c ("kvm: x86: Set highest physical address bits in non-present/reserved SPTEs")
---
 arch/x86/kvm/x86.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kvm/x86.c +0 -1
index 4a74a7cf0a8b..506bd2b4b8bb 100644
@@ -6576,14 +6576,12 @@ static void kvm_set_mmio_spte_mask(void)
 	/* Set the present bit. */
 	mask |= 1ull;
 
-#ifdef CONFIG_X86_64
 	/*

arch/x86/kvm/x86.c static void kvm_set_mmio_spte_mask(void) · line 6587

Quoted 10 lines
arch/x86/kvm/x86.c +1 -2
 	 * If reserved bit is not supported, clear the present bit to disable
 	 * mmio page fault.
 	 */
-	if (maxphyaddr == 52)
+	if (IS_ENABLED(CONFIG_X86_64) && maxphyaddr == 52)
 		mask &= ~1ull;
-#endif
 
 	kvm_mmu_set_mmio_spte_mask(mask, mask);
 }

Queued, thanks.

Paolo

Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 26 lines · Arnd Bergmann

Removing one of the two accesses of the maxphyaddr variable led to a harmless warning:

arch/x86/kvm/x86.c: In function 'kvm_set_mmio_spte_mask':
arch/x86/kvm/x86.c:6563:6: error: unused variable 'maxphyaddr' [-Werror=unused-variable]

Removing the #ifdef seems to be the nicest workaround, as it makes the code look cleaner than adding another #ifdef.

Fixes 28a1f3ac1d0c ("kvm: x86: Set highest physical address bits in non-present/reserved SPTEs")
---
 arch/x86/kvm/x86.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kvm/x86.c +0 -1
index 4a74a7cf0a8b..506bd2b4b8bb 100644
@@ -6576,14 +6576,12 @@ static void kvm_set_mmio_spte_mask(void)
 	/* Set the present bit. */
 	mask |= 1ull;
 
-#ifdef CONFIG_X86_64
 	/*

arch/x86/kvm/x86.c static void kvm_set_mmio_spte_mask(void) · line 6587

Quoted 10 lines
arch/x86/kvm/x86.c +1 -2
 	 * If reserved bit is not supported, clear the present bit to disable
 	 * mmio page fault.
 	 */
-	if (maxphyaddr == 52)
+	if (IS_ENABLED(CONFIG_X86_64) && maxphyaddr == 52)
 		mask &= ~1ull;
-#endif
 
 	kvm_mmu_set_mmio_spte_mask(mask, mask);
 }
Signature · 3 lines
Thanks,

David / dhildenb