Re: [PATCH] hv:Fix misra-c return value violations for vioapic APIs


Eddie Dong
 

-----Original Message-----
From: acrn-dev@...
[mailto:acrn-dev@...] On Behalf Of Mingqiang Chi
Sent: Monday, August 13, 2018 3:47 PM
To: acrn-dev@...
Subject: [acrn-dev] [PATCH] hv:Fix misra-c return value violations for vioapic
APIs

From: Mingqiang Chi <mingqiang.chi@...>

--Changed 4 APIs to void type
vioapic_set_irqstate
vioapic_assert_irq
vioapic_deassert_irq
vioapic_pulse_irq

Signed-off-by: Mingqiang Chi <mingqiang.chi@...>
---
hypervisor/common/hypercall.c | 6 +++---
hypervisor/dm/vioapic.c | 20 +++++++++-----------
hypervisor/include/arch/x86/guest/vioapic.h | 6 +++---
3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/hypervisor/common/hypercall.c
b/hypervisor/common/hypercall.c index f8efb35..110b3b1 100644
--- a/hypervisor/common/hypercall.c
+++ b/hypervisor/common/hypercall.c
@@ -109,13 +109,13 @@ handle_vioapic_irqline(struct vm *vm, uint32_t irq,
enum irq_mode mode)

switch (mode) {
case IRQ_ASSERT:
- ret = vioapic_assert_irq(vm, irq);
+ vioapic_assert_irq(vm, irq);
break;
case IRQ_DEASSERT:
- ret = vioapic_deassert_irq(vm, irq);
+ vioapic_deassert_irq(vm, irq);
break;
case IRQ_PULSE:
- ret = vioapic_pulse_irq(vm, irq);
+ vioapic_pulse_irq(vm, irq);
break;
default:
/*
diff --git a/hypervisor/dm/vioapic.c b/hypervisor/dm/vioapic.c index
4692094..3724be0 100644
--- a/hypervisor/dm/vioapic.c
+++ b/hypervisor/dm/vioapic.c
@@ -150,14 +150,15 @@ enum irqstate {
IRQSTATE_PULSE
};

-static int
+static void
vioapic_set_irqstate(struct vm *vm, uint32_t irq, enum irqstate irqstate) {
struct vioapic *vioapic;
uint32_t pin = irq;

if (pin >= vioapic_pincount(vm)) {
- return -EINVAL;
+ pr_err("invalid vioapic pin number %hhu", pin);
+ return;
This is not equivalent... I think, we have to make it as a pre-assumption, by doing so. Please check with Junjie.

}

vioapic = vm_ioapic(vm);
@@ -178,26 +179,23 @@ vioapic_set_irqstate(struct vm *vm, uint32_t irq,
enum irqstate irqstate)
panic("vioapic_set_irqstate: invalid irqstate %d", irqstate);
}
VIOAPIC_UNLOCK(vioapic);
-
- return 0;
}

-int
+void
vioapic_assert_irq(struct vm *vm, uint32_t irq) {
- return vioapic_set_irqstate(vm, irq, IRQSTATE_ASSERT);
+ vioapic_set_irqstate(vm, irq, IRQSTATE_ASSERT);
}

-int
-vioapic_deassert_irq(struct vm *vm, uint32_t irq)
+void vioapic_deassert_irq(struct vm *vm, uint32_t irq)
{
- return vioapic_set_irqstate(vm, irq, IRQSTATE_DEASSERT);
+ vioapic_set_irqstate(vm, irq, IRQSTATE_DEASSERT);
}

-int
+void
vioapic_pulse_irq(struct vm *vm, uint32_t irq) {
- return vioapic_set_irqstate(vm, irq, IRQSTATE_PULSE);
+ vioapic_set_irqstate(vm, irq, IRQSTATE_PULSE);
}

/*
diff --git a/hypervisor/include/arch/x86/guest/vioapic.h
b/hypervisor/include/arch/x86/guest/vioapic.h
index 98ffc9e..29bb540 100644
--- a/hypervisor/include/arch/x86/guest/vioapic.h
+++ b/hypervisor/include/arch/x86/guest/vioapic.h
@@ -41,9 +41,9 @@ struct vioapic *vioapic_init(struct vm *vm);
void vioapic_cleanup(struct vioapic *vioapic);
void vioapic_reset(struct vioapic *vioapic);

-int vioapic_assert_irq(struct vm *vm, uint32_t irq);
-int vioapic_deassert_irq(struct vm *vm, uint32_t irq);
-int vioapic_pulse_irq(struct vm *vm, uint32_t irq);
+void vioapic_assert_irq(struct vm *vm, uint32_t irq);
+void vioapic_deassert_irq(struct vm *vm, uint32_t irq);
+void vioapic_pulse_irq(struct vm *vm, uint32_t irq);
void vioapic_update_tmr(struct vcpu *vcpu);

void vioapic_mmio_write(struct vm *vm, uint64_t gpa, uint32_t wval);
--
2.7.4


Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.