aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-04-13 09:40:02 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2015-04-14 12:09:51 -0400
commitbea15428b9d6bc36e87288f168ab314619a66757 (patch)
tree455772e455f999852524239950529c92325d85d7
parent9e9c3fe40bcd28e3f98f0ad8408435f4503f2781 (diff)
KVM: x86: cleanup kvm_irq_delivery_to_apic_fast
Sparse is reporting a "we previously assumed 'src' could be null" error. This is true as far as the static analyzer can see, but in practice only IPIs can set shorthand to self and they also set 'src', so it's ok. Still, move the initialization of x2apic_ipi (and thus the NULL check for src right before the first use. While at it, initializing ret to "false" is somewhat confusing because of the almost immediate assigned of "true" to the same variable. Thus, initialize it to "true" and modify it in the only path that used to use the value from "bool ret = false". There is no change in generated code from this change. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/lapic.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index d67206a7b99a..629af0f1c5c4 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -683,8 +683,7 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
683 unsigned long bitmap = 1; 683 unsigned long bitmap = 1;
684 struct kvm_lapic **dst; 684 struct kvm_lapic **dst;
685 int i; 685 int i;
686 bool ret = false; 686 bool ret, x2apic_ipi;
687 bool x2apic_ipi = src && apic_x2apic_mode(src);
688 687
689 *r = -1; 688 *r = -1;
690 689
@@ -696,16 +695,18 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
696 if (irq->shorthand) 695 if (irq->shorthand)
697 return false; 696 return false;
698 697
698 x2apic_ipi = src && apic_x2apic_mode(src);
699 if (irq->dest_id == (x2apic_ipi ? X2APIC_BROADCAST : APIC_BROADCAST)) 699 if (irq->dest_id == (x2apic_ipi ? X2APIC_BROADCAST : APIC_BROADCAST))
700 return false; 700 return false;
701 701
702 ret = true;
702 rcu_read_lock(); 703 rcu_read_lock();
703 map = rcu_dereference(kvm->arch.apic_map); 704 map = rcu_dereference(kvm->arch.apic_map);
704 705
705 if (!map) 706 if (!map) {
707 ret = false;
706 goto out; 708 goto out;
707 709 }
708 ret = true;
709 710
710 if (irq->dest_mode == APIC_DEST_PHYSICAL) { 711 if (irq->dest_mode == APIC_DEST_PHYSICAL) {
711 if (irq->dest_id >= ARRAY_SIZE(map->phys_map)) 712 if (irq->dest_id >= ARRAY_SIZE(map->phys_map))