mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: remove unneeded comparison
@ 2021-11-14  6:40 Jason Wang
  2021-11-14  7:11 ` Zenghui Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Wang @ 2021-11-14  6:40 UTC (permalink / raw)
  To: catalin.marinas
  Cc: maz, will, james.morse, alexandru.elisei, suzuki.poulose,
	linux-arm-kernel, kvmarm, linux-kernel, 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.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
---
 arch/arm64/kvm/guest.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index 5ce26bedf23c..1605cb71dd52 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -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));
 
 	/*
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: arm64: remove unneeded comparison
  2021-11-14  6:40 [PATCH] KVM: arm64: remove unneeded comparison Jason Wang
@ 2021-11-14  7:11 ` Zenghui Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Zenghui Yu @ 2021-11-14  7:11 UTC (permalink / raw)
  To: Jason Wang
  Cc: catalin.marinas, maz, will, james.morse, alexandru.elisei,
	suzuki.poulose, linux-arm-kernel, kvmarm, linux-kernel

Hi,

On 2021/11/14 14:40, Jason Wang wrote:
> 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.
> 
> Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
> ---
>  arch/arm64/kvm/guest.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
> index 5ce26bedf23c..1605cb71dd52 100644
> --- a/arch/arm64/kvm/guest.c
> +++ b/arch/arm64/kvm/guest.c
> @@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-14  7:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-14  6:40 [PATCH] KVM: arm64: remove unneeded comparison Jason Wang
2021-11-14  7:11 ` Zenghui Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®