mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-06 19:30:46 +00:00
hv: dm: fix "Procedure has more than one exit point"
IEC 61508,ISO 26262 standards highly recommend single-exit rule. Reduce the count of the "return entries". Fix the violations which is comply with the cases list below: 1.Function has 2 return entries. 2.The first return entry is used to return the error code of checking variable whether is valid. Fix the violations in "if else" format. V1->V2: make the return value match to int32_t Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -86,26 +86,24 @@ vioapic_set_pinstate(struct acrn_vioapic *vioapic, uint16_t pin, uint32_t level)
|
||||
uint32_t old_lvl;
|
||||
union ioapic_rte rte;
|
||||
|
||||
if (pin >= REDIR_ENTRIES_HW) {
|
||||
return;
|
||||
}
|
||||
|
||||
rte = vioapic->rtbl[pin];
|
||||
old_lvl = (uint32_t)bitmap_test(pin & 0x3FU, &vioapic->pin_state[pin >> 6U]);
|
||||
if (level == 0U) {
|
||||
/* clear pin_state and deliver interrupt according to polarity */
|
||||
bitmap_clear_nolock(pin & 0x3FU,
|
||||
&vioapic->pin_state[pin >> 6U]);
|
||||
if (((rte.full & IOAPIC_RTE_INTPOL) != 0UL)
|
||||
&& old_lvl != level) {
|
||||
vioapic_send_intr(vioapic, pin);
|
||||
}
|
||||
} else {
|
||||
/* set pin_state and deliver intrrupt according to polarity */
|
||||
bitmap_set_nolock(pin & 0x3FU, &vioapic->pin_state[pin >> 6U]);
|
||||
if (((rte.full & IOAPIC_RTE_INTPOL) == 0UL)
|
||||
&& old_lvl != level) {
|
||||
vioapic_send_intr(vioapic, pin);
|
||||
if (pin < REDIR_ENTRIES_HW) {
|
||||
rte = vioapic->rtbl[pin];
|
||||
old_lvl = (uint32_t)bitmap_test(pin & 0x3FU, &vioapic->pin_state[pin >> 6U]);
|
||||
if (level == 0U) {
|
||||
/* clear pin_state and deliver interrupt according to polarity */
|
||||
bitmap_clear_nolock(pin & 0x3FU,
|
||||
&vioapic->pin_state[pin >> 6U]);
|
||||
if (((rte.full & IOAPIC_RTE_INTPOL) != 0UL)
|
||||
&& old_lvl != level) {
|
||||
vioapic_send_intr(vioapic, pin);
|
||||
}
|
||||
} else {
|
||||
/* set pin_state and deliver intrrupt according to polarity */
|
||||
bitmap_set_nolock(pin & 0x3FU, &vioapic->pin_state[pin >> 6U]);
|
||||
if (((rte.full & IOAPIC_RTE_INTPOL) == 0UL)
|
||||
&& old_lvl != level) {
|
||||
vioapic_send_intr(vioapic, pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -260,16 +258,18 @@ static inline bool vioapic_need_intr(const struct acrn_vioapic *vioapic, uint16_
|
||||
{
|
||||
uint32_t lvl;
|
||||
union ioapic_rte rte;
|
||||
bool ret;
|
||||
|
||||
if (pin >= REDIR_ENTRIES_HW) {
|
||||
return false;
|
||||
ret = false;
|
||||
} else {
|
||||
rte = vioapic->rtbl[pin];
|
||||
lvl = (uint32_t)bitmap_test(pin & 0x3FU, &vioapic->pin_state[pin >> 6U]);
|
||||
ret = !!((((rte.full & IOAPIC_RTE_INTPOL) != 0UL) && lvl == 0U) ||
|
||||
(((rte.full & IOAPIC_RTE_INTPOL) == 0UL) && lvl != 0U));
|
||||
}
|
||||
|
||||
rte = vioapic->rtbl[pin];
|
||||
lvl = (uint32_t)bitmap_test(pin & 0x3FU, &vioapic->pin_state[pin >> 6U]);
|
||||
|
||||
return !!((((rte.full & IOAPIC_RTE_INTPOL) != 0UL) && lvl == 0U) ||
|
||||
(((rte.full & IOAPIC_RTE_INTPOL) == 0UL) && lvl != 0U));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -525,11 +525,15 @@ vioapic_init(struct acrn_vm *vm)
|
||||
uint32_t
|
||||
vioapic_pincount(const struct acrn_vm *vm)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
if (is_vm0(vm)) {
|
||||
return REDIR_ENTRIES_HW;
|
||||
ret = REDIR_ENTRIES_HW;
|
||||
} else {
|
||||
return VIOAPIC_RTE_NUM;
|
||||
ret = VIOAPIC_RTE_NUM;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vioapic_mmio_access_handler(struct io_request *io_req, void *handler_private_data)
|
||||
|
Reference in New Issue
Block a user