* [PATCH] LoongArch: KVM: remove unused returns.
@ 2025-09-04 4:26 cuitao
2025-09-04 6:15 ` Bibo Mao
2025-09-04 6:34 ` Tiezhu Yang
0 siblings, 2 replies; 7+ messages in thread
From: cuitao @ 2025-09-04 4:26 UTC (permalink / raw)
To: zhaotianrui, maobibo, chenhuacai, loongarch
Cc: kernel, kvm, linux-kernel, cuitao
The default branch has already handled all undefined cases,
so the final return statement is redundant.
Signed-off-by: cuitao <cuitao@kylinos.cn>
---
arch/loongarch/kvm/exit.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
index 2ce41f93b2a4..e501867740b1 100644
--- a/arch/loongarch/kvm/exit.c
+++ b/arch/loongarch/kvm/exit.c
@@ -778,9 +778,7 @@ static long kvm_save_notify(struct kvm_vcpu *vcpu)
return 0;
default:
return KVM_HCALL_INVALID_CODE;
- };
-
- return KVM_HCALL_INVALID_CODE;
+ }
};
/*
--
2.48.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: KVM: remove unused returns.
2025-09-04 4:26 [PATCH] LoongArch: KVM: remove unused returns cuitao
@ 2025-09-04 6:15 ` Bibo Mao
2025-09-04 6:25 ` Huacai Chen
2025-09-04 6:34 ` Tiezhu Yang
1 sibling, 1 reply; 7+ messages in thread
From: Bibo Mao @ 2025-09-04 6:15 UTC (permalink / raw)
To: cuitao, zhaotianrui, chenhuacai, loongarch; +Cc: kernel, kvm, linux-kernel
On 2025/9/4 下午12:26, cuitao wrote:
> The default branch has already handled all undefined cases,
> so the final return statement is redundant.
>
> Signed-off-by: cuitao <cuitao@kylinos.cn>
> ---
> arch/loongarch/kvm/exit.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
> index 2ce41f93b2a4..e501867740b1 100644
> --- a/arch/loongarch/kvm/exit.c
> +++ b/arch/loongarch/kvm/exit.c
> @@ -778,9 +778,7 @@ static long kvm_save_notify(struct kvm_vcpu *vcpu)
> return 0;
> default:
> return KVM_HCALL_INVALID_CODE;
> - };
> -
> - return KVM_HCALL_INVALID_CODE;
> + }
> };
>
> /*
>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: KVM: remove unused returns.
2025-09-04 6:15 ` Bibo Mao
@ 2025-09-04 6:25 ` Huacai Chen
0 siblings, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2025-09-04 6:25 UTC (permalink / raw)
To: Bibo Mao; +Cc: cuitao, zhaotianrui, loongarch, kernel, kvm, linux-kernel
On Thu, Sep 4, 2025 at 2:17 PM Bibo Mao <maobibo@loongson.cn> wrote:
>
>
>
> On 2025/9/4 下午12:26, cuitao wrote:
> > The default branch has already handled all undefined cases,
> > so the final return statement is redundant.
> >
> > Signed-off-by: cuitao <cuitao@kylinos.cn>
> > ---
> > arch/loongarch/kvm/exit.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
> > index 2ce41f93b2a4..e501867740b1 100644
> > --- a/arch/loongarch/kvm/exit.c
> > +++ b/arch/loongarch/kvm/exit.c
> > @@ -778,9 +778,7 @@ static long kvm_save_notify(struct kvm_vcpu *vcpu)
> > return 0;
> > default:
> > return KVM_HCALL_INVALID_CODE;
> > - };
> > -
> > - return KVM_HCALL_INVALID_CODE;
> > + }
> > };
> >
> > /*
> >
> Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Applied, thanks.
Huacai
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: KVM: remove unused returns.
2025-09-04 4:26 [PATCH] LoongArch: KVM: remove unused returns cuitao
2025-09-04 6:15 ` Bibo Mao
@ 2025-09-04 6:34 ` Tiezhu Yang
2025-09-04 8:13 ` cuitao
1 sibling, 1 reply; 7+ messages in thread
From: Tiezhu Yang @ 2025-09-04 6:34 UTC (permalink / raw)
To: cuitao, zhaotianrui, maobibo, chenhuacai, loongarch
Cc: kernel, kvm, linux-kernel
On 2025/9/4 下午12:26, cuitao wrote:
> The default branch has already handled all undefined cases,
> so the final return statement is redundant.
>
> Signed-off-by: cuitao <cuitao@kylinos.cn>
> ---
> arch/loongarch/kvm/exit.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
> index 2ce41f93b2a4..e501867740b1 100644
> --- a/arch/loongarch/kvm/exit.c
> +++ b/arch/loongarch/kvm/exit.c
> @@ -778,9 +778,7 @@ static long kvm_save_notify(struct kvm_vcpu *vcpu)
> return 0;
> default:
> return KVM_HCALL_INVALID_CODE;
> - };
> -
> - return KVM_HCALL_INVALID_CODE;
> + }
> };
>
> /*
In my opinion, there is only one case, no need to use switch case,
the ";" at the end can be removed, the code can be like this:
static long kvm_save_notify(struct kvm_vcpu *vcpu)
{
unsigned long id, data;
id = kvm_read_reg(vcpu, LOONGARCH_GPR_A1);
data = kvm_read_reg(vcpu, LOONGARCH_GPR_A2);
if (id == BIT(KVM_FEATURE_STEAL_TIME)) {
if (data & ~(KVM_STEAL_PHYS_MASK | KVM_STEAL_PHYS_VALID))
return KVM_HCALL_INVALID_PARAMETER;
vcpu->arch.st.guest_addr = data;
if (!(data & KVM_STEAL_PHYS_VALID))
return 0;
vcpu->arch.st.last_steal = current->sched_info.run_delay;
kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
return 0;
}
return KVM_HCALL_INVALID_CODE;
}
The following is the diff:
diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
index 2ce41f93b2a4..0c18761539fc 100644
--- a/arch/loongarch/kvm/exit.c
+++ b/arch/loongarch/kvm/exit.c
@@ -764,8 +764,7 @@ static long kvm_save_notify(struct kvm_vcpu *vcpu)
id = kvm_read_reg(vcpu, LOONGARCH_GPR_A1);
data = kvm_read_reg(vcpu, LOONGARCH_GPR_A2);
- switch (id) {
- case BIT(KVM_FEATURE_STEAL_TIME):
+ if (id == BIT(KVM_FEATURE_STEAL_TIME)) {
if (data & ~(KVM_STEAL_PHYS_MASK | KVM_STEAL_PHYS_VALID))
return KVM_HCALL_INVALID_PARAMETER;
@@ -776,12 +775,10 @@ static long kvm_save_notify(struct kvm_vcpu *vcpu)
vcpu->arch.st.last_steal = current->sched_info.run_delay;
kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
return 0;
- default:
- return KVM_HCALL_INVALID_CODE;
- };
+ }
return KVM_HCALL_INVALID_CODE;
-};
+}
/*
* kvm_handle_lsx_disabled() - Guest used LSX while disabled in root.
Thanks,
Tiezhu
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: KVM: remove unused returns.
2025-09-04 6:34 ` Tiezhu Yang
@ 2025-09-04 8:13 ` cuitao
2025-09-04 8:20 ` Huacai Chen
0 siblings, 1 reply; 7+ messages in thread
From: cuitao @ 2025-09-04 8:13 UTC (permalink / raw)
To: yangtiezhu
Cc: chenhuacai, cuitao, kernel, kvm, linux-kernel, loongarch,
maobibo, zhaotianrui
Thanks for the review.
My initial idea was to remove the switch-case structure.
However, after checking the case value KVM_FEATURE_STEAL_TIME,
I found there are 13 parallel definitions—and it is unclear when
this part of the development will be completed later. Therefore,
I temporarily retained the switch-case structure.
Now, I have updated the patch according to your suggestion:
- Replaced `switch` with `if` since there is only one case.
- Removed the redundant semicolon after the block.
Please see the updated patch below.
Thanks,
Tiezhu
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: KVM: remove unused returns.
2025-09-04 8:13 ` cuitao
@ 2025-09-04 8:20 ` Huacai Chen
2025-09-04 8:57 ` Bibo Mao
0 siblings, 1 reply; 7+ messages in thread
From: Huacai Chen @ 2025-09-04 8:20 UTC (permalink / raw)
To: cuitao
Cc: yangtiezhu, kernel, kvm, linux-kernel, loongarch, maobibo, zhaotianrui
On Thu, Sep 4, 2025 at 4:14 PM cuitao <cuitao@kylinos.cn> wrote:
>
> Thanks for the review.
>
> My initial idea was to remove the switch-case structure.
> However, after checking the case value KVM_FEATURE_STEAL_TIME,
> I found there are 13 parallel definitions—and it is unclear when
> this part of the development will be completed later. Therefore,
> I temporarily retained the switch-case structure.
>
> Now, I have updated the patch according to your suggestion:
> - Replaced `switch` with `if` since there is only one case.
> - Removed the redundant semicolon after the block.
>
> Please see the updated patch below.
It has been applied, don't make useless effort.
https://github.com/chenhuacai/linux/commit/f5d35375a6546bcc5d0993e3a48cdbc3a7217544
Huacai
>
> Thanks,
> Tiezhu
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: KVM: remove unused returns.
2025-09-04 8:20 ` Huacai Chen
@ 2025-09-04 8:57 ` Bibo Mao
0 siblings, 0 replies; 7+ messages in thread
From: Bibo Mao @ 2025-09-04 8:57 UTC (permalink / raw)
To: Huacai Chen, cuitao
Cc: yangtiezhu, kernel, kvm, linux-kernel, loongarch, zhaotianrui
On 2025/9/4 下午4:20, Huacai Chen wrote:
> On Thu, Sep 4, 2025 at 4:14 PM cuitao <cuitao@kylinos.cn> wrote:
>>
>> Thanks for the review.
>>
>> My initial idea was to remove the switch-case structure.
>> However, after checking the case value KVM_FEATURE_STEAL_TIME,
>> I found there are 13 parallel definitions—and it is unclear when
>> this part of the development will be completed later. Therefore,
>> I temporarily retained the switch-case structure.
>>
>> Now, I have updated the patch according to your suggestion:
>> - Replaced `switch` with `if` since there is only one case.
>> - Removed the redundant semicolon after the block.
>>
>> Please see the updated patch below.
> It has been applied, don't make useless effort.
> https://github.com/chenhuacai/linux/commit/f5d35375a6546bcc5d0993e3a48cdbc3a7217544
I think that it is unnecessary to replace `switch` with `if` here:)
One thing is that the change is big for such thing, and also there may
be new case condition in future, just maybe.
Regards
Bibo Mao
>
> Huacai
>
>>
>> Thanks,
>> Tiezhu
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-09-04 9:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04 4:26 [PATCH] LoongArch: KVM: remove unused returns cuitao
2025-09-04 6:15 ` Bibo Mao
2025-09-04 6:25 ` Huacai Chen
2025-09-04 6:34 ` Tiezhu Yang
2025-09-04 8:13 ` cuitao
2025-09-04 8:20 ` Huacai Chen
2025-09-04 8:57 ` Bibo Mao
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®