Skip to contentSkip to conversation

KVM: arm64: remove unneeded comparison

PATCH In review Jason Wang 2 participants 2 messages Nov 14, 2021

Subsystems (2)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 KVM: arm64: remove unneeded comparison

The unsigned expression compared with zero target < 0' is unneeded and its result is always false. we can also check the target's value returned from kvm_target_cpu' is one of the KVM_* macros, and these macros are defined greater than or equal to 0.
Therefore, the comparison code block:

    if (target < 0)
        return -ENODEV;

is unneeded. We can safely remove it.

---
 arch/arm64/kvm/guest.c | 3 ---
 1 file changed, 3 deletions(-)
arch/arm64/kvm/guest.c +0 -3
index 5ce26bedf23c..1605cb71dd52 100644
@@ -873,9 +873,6 @@ int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init)
 {
 	u32 target = kvm_target_cpu();
 
-	if (target < 0)
-		return -ENODEV;
-
 	memset(init, 0, sizeof(*init));
 
 	/*
Signature · 1 line
2.33.0
reviewer
#1 lore raw

Hi,

Quoted 20 lines · Jason Wang

The unsigned expression compared with zero target < 0' is unneeded and its result is always false. we can also check the target's value returned from kvm_target_cpu' is one of the KVM_* macros, and these macros are defined greater than or equal to 0.
Therefore, the comparison code block:

    if (target < 0)
        return -ENODEV;

is unneeded. We can safely remove it.

---
 arch/arm64/kvm/guest.c | 3 ---
 1 file changed, 3 deletions(-)
arch/arm64/kvm/guest.c +0 -0
index 5ce26bedf23c..1605cb71dd52 100644

arch/arm64/kvm/guest.c int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init) · line 878

Quoted 9 lines
arch/arm64/kvm/guest.c +0 -3
@@ -873,9 +873,6 @@ int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init)
 {
 	u32 target = kvm_target_cpu();
 
-	if (target < 0)
-		return -ENODEV;
-
 	memset(init, 0, sizeof(*init));
 
 	/*

FYI there's already a similar change in mainline now:

https://git.kernel.org/torvalds/c/08e873cb70f3

Thanks,
Zenghui
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm