diff mbox series

[linux-next] KVM: x86: remove redundant ret variable

Message ID 202211231704457807160@zte.com.cn (mailing list archive)
State New, archived
Headers show
Series [linux-next] KVM: x86: remove redundant ret variable | expand

Commit Message

zhang.songyi@zte.com.cn Nov. 23, 2022, 9:04 a.m. UTC
From: zhang songyi <zhang.songyi@zte.com.cn>

Return value from apic_get_tmcct() directly instead of taking
this in another redundant variable.

Signed-off-by: zhang songyi <zhang.songyi@zte.com.cn>
---
 arch/x86/kvm/lapic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--
2.15.2

Comments

Sean Christopherson Jan. 18, 2023, 8:29 p.m. UTC | #1
On Wed, Nov 23, 2022, zhang.songyi@zte.com.cn wrote:
> From: zhang songyi <zhang.songyi@zte.com.cn>
> 
> Return value from apic_get_tmcct() directly instead of taking
> this in another redundant variable.
> 
> Signed-off-by: zhang songyi <zhang.songyi@zte.com.cn>
> ---
>  arch/x86/kvm/lapic.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index d7639d126e6c..707970804502 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1363,7 +1363,6 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
>  {
>         ktime_t remaining, now;
>         s64 ns;
> -       u32 tmcct;
> 
>         ASSERT(apic != NULL);
> 
> @@ -1378,10 +1377,9 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
>                 remaining = 0;
> 
>         ns = mod_64(ktime_to_ns(remaining), apic->lapic_timer.period);
> -       tmcct = div64_u64(ns,
> -                        (APIC_BUS_CYCLE_NS * apic->divide_count));
> 
> -       return tmcct;
> +       return div64_u64(ns,
> +                       (APIC_BUS_CYCLE_NS * apic->divide_count));

No need to wrap here, this fits comfortably on a single line (so does the
existing code, i.e. not your "bug").  No need for v2, I'll fix up when applying.
Sean Christopherson Jan. 19, 2023, 8:35 p.m. UTC | #2
On Wed, 23 Nov 2022 17:04:45 +0800, zhang.songyi@zte.com.cn wrote:
> Return value from apic_get_tmcct() directly instead of taking
> this in another redundant variable.

This patch was whitespace damaged, please fix your setup.  I manually applied it
(and one other) since it's a trivial change, but I likely won't have that luxury
for future patches.

Applied to kvm-x86 apic, thanks!

[1/1] KVM: x86: remove redundant ret variable
      https://github.com/kvm-x86/linux/commit/14bd05184168

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes
diff mbox series

Patch

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index d7639d126e6c..707970804502 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1363,7 +1363,6 @@  static u32 apic_get_tmcct(struct kvm_lapic *apic)
 {
        ktime_t remaining, now;
        s64 ns;
-       u32 tmcct;

        ASSERT(apic != NULL);

@@ -1378,10 +1377,9 @@  static u32 apic_get_tmcct(struct kvm_lapic *apic)
                remaining = 0;

        ns = mod_64(ktime_to_ns(remaining), apic->lapic_timer.period);
-       tmcct = div64_u64(ns,
-                        (APIC_BUS_CYCLE_NS * apic->divide_count));

-       return tmcct;
+       return div64_u64(ns,
+                       (APIC_BUS_CYCLE_NS * apic->divide_count));
 }

 static void __report_tpr_access(struct kvm_lapic *apic, bool write)