From: Paolo Bonzini <pbonzini@redhat.com>
To: "Radim Krčmář" <rkrcmar@redhat.com>, linux-kernel@vger.kernel.org
Cc: kvm@vger.kernel.org, Nadav Amit <namit@cs.technion.ac.il>,
Gleb Natapov <gleb@kernel.org>
Subject: Re: [PATCH 2/8] KVM: x86: cleanup kvm_apic_match_*()
Date: Fri, 30 Jan 2015 09:52:56 +0100 [thread overview]
Message-ID: <54CB4668.30909@redhat.com> (raw)
In-Reply-To: <1422568135-28402-3-git-send-email-rkrcmar@redhat.com>
On 29/01/2015 22:48, Radim Krčmář wrote:
> The majority of this patch turns
> result = 0; if (CODE) result = 1; return result;
> into
> return CODE;
> because we return bool now.
Added a bunch of "!= 0" to avoid automagic conversion to bool.
Paolo
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
> arch/x86/kvm/lapic.c | 44 +++++++++++++++-----------------------------
> 1 file changed, 15 insertions(+), 29 deletions(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 478dd8bd653b..271e7d076879 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -594,42 +594,34 @@ static bool kvm_apic_match_physical_addr(struct kvm_lapic *apic, u32 dest)
>
> static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
> {
> - int result = 0;
> u32 logical_id;
>
> if (kvm_apic_broadcast(apic, mda))
> - return 1;
> + return true;
>
> - if (apic_x2apic_mode(apic)) {
> - logical_id = kvm_apic_get_reg(apic, APIC_LDR);
> + logical_id = kvm_apic_get_reg(apic, APIC_LDR);
> +
> + if (apic_x2apic_mode(apic))
> return logical_id & mda;
> - }
>
> - logical_id = GET_APIC_LOGICAL_ID(kvm_apic_get_reg(apic, APIC_LDR));
> + logical_id = GET_APIC_LOGICAL_ID(logical_id);
>
> switch (kvm_apic_get_reg(apic, APIC_DFR)) {
> case APIC_DFR_FLAT:
> - if (logical_id & mda)
> - result = 1;
> - break;
> + return logical_id & mda;
> case APIC_DFR_CLUSTER:
> - if (((logical_id >> 4) == (mda >> 0x4))
> - && (logical_id & mda & 0xf))
> - result = 1;
> - break;
> + return ((logical_id >> 4) == (mda >> 4))
> + && (logical_id & mda & 0xf);
> default:
> apic_debug("Bad DFR vcpu %d: %08x\n",
> apic->vcpu->vcpu_id, kvm_apic_get_reg(apic, APIC_DFR));
> - break;
> + return false;
> }
> -
> - return result;
> }
>
> bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
> int short_hand, unsigned int dest, int dest_mode)
> {
> - int result = 0;
> struct kvm_lapic *target = vcpu->arch.apic;
>
> apic_debug("target %p, source %p, dest 0x%x, "
> @@ -641,27 +633,21 @@ bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
> case APIC_DEST_NOSHORT:
> if (dest_mode == 0)
> /* Physical mode. */
> - result = kvm_apic_match_physical_addr(target, dest);
> + return kvm_apic_match_physical_addr(target, dest);
> else
> /* Logical mode. */
> - result = kvm_apic_match_logical_addr(target, dest);
> - break;
> + return kvm_apic_match_logical_addr(target, dest);
> case APIC_DEST_SELF:
> - result = (target == source);
> - break;
> + return target == source;
> case APIC_DEST_ALLINC:
> - result = 1;
> - break;
> + return true;
> case APIC_DEST_ALLBUT:
> - result = (target != source);
> - break;
> + return target != source;
> default:
> apic_debug("kvm: apic: Bad dest shorthand value %x\n",
> short_hand);
> - break;
> + return false;
> }
> -
> - return result;
> }
>
> bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
>
next prev parent reply other threads:[~2015-01-30 8:52 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 21:48 [PATCH 0/8] KVM: minor APIC fixes and cleanups Radim Krčmář
2015-01-29 21:48 ` [PATCH 1/8] KVM: x86: return bool from kvm_apic_match*() Radim Krčmář
2015-01-29 22:10 ` Joe Perches
2015-01-30 8:50 ` Paolo Bonzini
2015-01-29 21:48 ` [PATCH 2/8] KVM: x86: cleanup kvm_apic_match_*() Radim Krčmář
2015-01-30 8:52 ` Paolo Bonzini [this message]
2015-01-30 13:06 ` Radim Krčmář
2015-02-02 14:26 ` Radim Krčmář
2015-02-02 14:28 ` Paolo Bonzini
2015-02-02 14:30 ` Radim Krčmář
2015-02-02 14:29 ` Radim Krčmář
2015-01-29 21:48 ` [PATCH 3/8] KVM: x86: replace 0 with APIC_DEST_PHYSICAL Radim Krčmář
2015-01-29 21:48 ` [PATCH 4/8] KVM: x86: fix x2apic logical address matching Radim Krčmář
2015-01-29 21:48 ` [PATCH 5/8] KVM: x86: use MDA for interrupt matching Radim Krčmář
2015-01-30 9:03 ` Paolo Bonzini
2015-01-30 13:09 ` Radim Krčmář
2015-01-29 21:48 ` [PATCH 6/8] KVM: x86: allow mixed APIC mode broadcast Radim Krčmář
2015-01-29 21:48 ` [PATCH 7/8] KVM: x86: avoid logical_map when it is invalid Radim Krčmář
2015-01-30 9:19 ` Paolo Bonzini
2015-01-30 14:21 ` Radim Krčmář
2015-01-30 14:21 ` Paolo Bonzini
2015-01-30 9:38 ` Paolo Bonzini
2015-01-30 14:56 ` Radim Krčmář
2015-01-30 15:10 ` Paolo Bonzini
2015-01-30 17:09 ` Radim Krčmář
2015-01-29 21:48 ` [PATCH 8/8] KVM: x86: simplify kvm_apic_map Radim Krčmář
2015-01-30 9:18 ` Paolo Bonzini
2015-01-30 15:14 ` Radim Krčmář
2015-01-30 15:23 ` Paolo Bonzini
2015-01-30 16:57 ` Radim Krčmář
2015-01-30 21:15 ` Paolo Bonzini
2015-01-30 9:22 ` [PATCH 0/8] KVM: minor APIC fixes and cleanups Paolo Bonzini
2015-01-30 15:20 ` Radim Krčmář
2015-01-30 15:24 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54CB4668.30909@redhat.com \
--to=pbonzini@redhat.com \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namit@cs.technion.ac.il \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox