Skip to contentSkip to conversation

KVM:VMX:Remove scratch 'cpu' variable that shadows an identical scratch var

PATCH Applied Peng Hao 3 participants 3 messages Feb 22, 2022 – Feb 24, 2022

Subsystems (3)
lore
Share & tools
lore

Peng Hao

author
#0 lore raw

PATCH v2 1/1 KVM:VMX:Remove scratch 'cpu' variable that shadows an identical scratch var

From: Peng Hao <[email protected]>

Remove a redundant 'cpu' declaration from inside an if-statement that that shadows an identical declaration at function scope. Both variables are used as scratch variables in for_each_*_cpu() loops, thus there's no harm in sharing a variable.

---
 arch/x86/kvm/vmx/vmx.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +0 -1
index ba66c171d951..6101c2980a9c 100644
@@ -7931,7 +7931,6 @@ static int __init vmx_init(void)
 	    ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED &&
 	    (ms_hyperv.nested_features & HV_X64_ENLIGHTENED_VMCS_VERSION) >=
 	    KVM_EVMCS_VERSION) {
-		int cpu;
 
 		/* Check that we have assist pages on all online CPUs */
 		for_each_online_cpu(cpu) {
Signature · 1 line
2.27.0
#1 lore raw

Needs a space between "KVM:" and "VMX:". No need to resend, Paolo can fixup when applying.

Quoted 28 lines · Peng Hao

From: Peng Hao <[email protected]>

Remove a redundant 'cpu' declaration from inside an if-statement that that shadows an identical declaration at function scope. Both variables are used as scratch variables in for_each_*_cpu() loops, thus there's no harm in sharing a variable.

---
 arch/x86/kvm/vmx/vmx.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +0 -1
index ba66c171d951..6101c2980a9c 100644
@@ -7931,7 +7931,6 @@ static int __init vmx_init(void)
 	    ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED &&
 	    (ms_hyperv.nested_features & HV_X64_ENLIGHTENED_VMCS_VERSION) >=
 	    KVM_EVMCS_VERSION) {
-		int cpu;
 
 		/* Check that we have assist pages on all online CPUs */
 		for_each_online_cpu(cpu) {
Signature · 1 line
2.27.0
maintainer Applied
#2 lore raw
In reply to Peng Hao
Quoted 18 lines · Peng Hao

From: Peng Hao <[email protected]>

Remove a redundant 'cpu' declaration from inside an if-statement that that shadows an identical declaration at function scope. Both variables are used as scratch variables in for_each_*_cpu() loops, thus there's no harm in sharing a variable.

---
  arch/x86/kvm/vmx/vmx.c | 1 -
  1 file changed, 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +0 -0
index ba66c171d951..6101c2980a9c 100644

arch/x86/kvm/vmx/vmx.c static int __init vmx_init(void) · line 7936

Quoted 7 lines
arch/x86/kvm/vmx/vmx.c +0 -1
@@ -7931,7 +7931,6 @@ static int __init vmx_init(void)
  	    ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED &&
  	    (ms_hyperv.nested_features & HV_X64_ENLIGHTENED_VMCS_VERSION) >=
  	    KVM_EVMCS_VERSION) {
-		int cpu;
 
  		/* Check that we have assist pages on all online CPUs */
  		for_each_online_cpu(cpu) {

Queued, thanks.

Paolo