Skip to content

Commit

Permalink
hv: fix '(void) missing for discarded return value'
Browse files Browse the repository at this point in the history
MISRA-C requires that the function call in which the returned
value is discarded shall be clearly indicated using (void).

This patch fixes the violations related to the following
function calls.
- vlapic_set_intr
- vlapic_intr_edge

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
  • Loading branch information
shiqingg authored and wenlingz committed Nov 13, 2018
1 parent b3b2432 commit 3731b4c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 30 deletions.
24 changes: 8 additions & 16 deletions hypervisor/arch/x86/guest/vlapic.c
Expand Up @@ -1285,8 +1285,7 @@ vlapic_icrlo_write_handler(struct acrn_vlapic *vlapic)
target_vcpu = vcpu_from_vid(vlapic->vm, vcpu_id);

if (mode == APIC_DELMODE_FIXED) {
vlapic_set_intr(target_vcpu, vec,
LAPIC_TRIG_EDGE);
vlapic_set_intr(target_vcpu, vec, LAPIC_TRIG_EDGE);
dev_dbg(ACRN_DBG_LAPIC,
"vlapic sending ipi %u to vcpu_id %hu",
vec, vcpu_id);
Expand Down Expand Up @@ -1926,32 +1925,26 @@ vlapic_set_tmr_one_vec(struct acrn_vlapic *vlapic, uint32_t delmode,
vlapic_set_tmr(vlapic, vector, level);
}

int
/*
* @pre vcpu != NULL
* @pre vector <= 255U
*/
void
vlapic_set_intr(struct acrn_vcpu *vcpu, uint32_t vector, bool level)
{
struct acrn_vlapic *vlapic;

/*
* According to section "Maskable Hardware Interrupts" in Intel SDM
* vectors 16 through 255 can be delivered through the local APIC.
*/
if ((vcpu == NULL) || (vector > 255U)) {
return -EINVAL;
}

vlapic = vcpu_vlapic(vcpu);
if (vector < 16U) {
vlapic_set_error(vlapic, APIC_ESR_RECEIVE_ILLEGAL_VECTOR);
dev_dbg(ACRN_DBG_LAPIC,
"vlapic ignoring interrupt to vector %u", vector);
return 0;
return;
}

if (vlapic_set_intr_ready(vlapic, vector, level) != 0) {
vcpu_make_request(vcpu, ACRN_REQUEST_EVENT);
}

return 0;
}

/**
Expand Down Expand Up @@ -2061,8 +2054,7 @@ static void vlapic_timer_expired(void *data)

/* inject vcpu timer interrupt if not masked */
if (!vlapic_lvtt_masked(vlapic)) {
vlapic_intr_edge(vcpu,
lapic->lvt[APIC_LVT_TIMER].v & APIC_LVTT_VECTOR);
vlapic_intr_edge(vcpu, lapic->lvt[APIC_LVT_TIMER].v & APIC_LVTT_VECTOR);
}

if (!vlapic_lvtt_period(vlapic)) {
Expand Down
6 changes: 1 addition & 5 deletions hypervisor/bsp/uefi/uefi.c
Expand Up @@ -18,17 +18,13 @@ static int efi_initialized;
void efi_spurious_handler(int vector)
{
struct acrn_vcpu* vcpu;
int ret;

if (get_cpu_id() != 0)
return;

vcpu = per_cpu(vcpu, 0);
if (vcpu != NULL) {
ret = vlapic_set_intr(vcpu, vector, 0);
if (ret != 0)
pr_err("%s vlapic set intr fail, interrupt lost\n",
__func__);
vlapic_set_intr(vcpu, vector, 0);
} else
pr_err("%s vcpu or vlapic is not ready, interrupt lost\n",
__func__);
Expand Down
16 changes: 7 additions & 9 deletions hypervisor/include/arch/x86/guest/vlapic.h
Expand Up @@ -185,8 +185,10 @@ int vlapic_wrmsr(struct acrn_vcpu *vcpu, uint32_t msr, uint64_t wval);
/*
* Signals to the LAPIC that an interrupt at 'vector' needs to be generated
* to the 'cpu', the state is recorded in IRR.
* @pre vcpu != NULL
* @pre vector <= 255U
*/
int vlapic_set_intr(struct acrn_vcpu *vcpu, uint32_t vector, bool level);
void vlapic_set_intr(struct acrn_vcpu *vcpu, uint32_t vector, bool level);

#define LAPIC_TRIG_LEVEL true
#define LAPIC_TRIG_EDGE false
Expand All @@ -196,13 +198,11 @@ int vlapic_set_intr(struct acrn_vcpu *vcpu, uint32_t vector, bool level);
* @param[in] vcpu Pointer to target vCPU data structure
* @param[in] vector Vector to be injected.
*
* @return 0 on success.
* @return -EINVAL on error that vector is invalid or vcpu is NULL.
*/
static inline int
static inline void
vlapic_intr_level(struct acrn_vcpu *vcpu, uint32_t vector)
{
return vlapic_set_intr(vcpu, vector, LAPIC_TRIG_LEVEL);
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_LEVEL);
}

/**
Expand All @@ -211,13 +211,11 @@ vlapic_intr_level(struct acrn_vcpu *vcpu, uint32_t vector)
* @param[in] vcpu Pointer to target vCPU data structure
* @param[in] vector Vector to be injected.
*
* @return 0 on success.
* @return -EINVAL on error that vector is invalid or vcpu is NULL.
*/
static inline int
static inline void
vlapic_intr_edge(struct acrn_vcpu *vcpu, uint32_t vector)
{
return vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
}

/**
Expand Down

0 comments on commit 3731b4c

Please sign in to comment.