From c6c1e42b794171ef77a8d381b3fea12b14d6e5a7 Mon Sep 17 00:00:00 2001 From: Huihuang Shi Date: Mon, 15 Oct 2018 11:31:12 +0800 Subject: [PATCH] HV:fix 'missing for discarded return value' violations Return value should be checked,fix it by add "void" when the function return value is not used. V1->V2: replace printf with pr_warn. V2->V3: change the commit to make read easily. Tracked-On:#861 Signed-off-by: Huihuang Shi Reviewed-by: Jason Chen CJ Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/ucode.c | 2 +- hypervisor/arch/x86/guest/vlapic.c | 11 ++++++----- hypervisor/arch/x86/irq.c | 2 +- hypervisor/arch/x86/mtrr.c | 6 +++--- hypervisor/arch/x86/vtd.c | 14 ++++++++------ hypervisor/common/hypercall.c | 5 ++--- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/hypervisor/arch/x86/guest/ucode.c b/hypervisor/arch/x86/guest/ucode.c index 1bd004788..505767bba 100644 --- a/hypervisor/arch/x86/guest/ucode.c +++ b/hypervisor/arch/x86/guest/ucode.c @@ -71,7 +71,7 @@ void acrn_update_ucode(struct vcpu *vcpu, uint64_t v) msr_write(MSR_IA32_BIOS_UPDT_TRIG, (uint64_t)ucode_ptr + sizeof(struct ucode_header)); - get_microcode_version(); + (void)get_microcode_version(); free(ucode_ptr); } diff --git a/hypervisor/arch/x86/guest/vlapic.c b/hypervisor/arch/x86/guest/vlapic.c index d3aa16cfe..e55699c30 100644 --- a/hypervisor/arch/x86/guest/vlapic.c +++ b/hypervisor/arch/x86/guest/vlapic.c @@ -724,14 +724,14 @@ vlapic_mask_lvts(struct acrn_vlapic *vlapic) vlapic_lvt_write_handler(vlapic, APIC_OFFSET_ERROR_LVT); } -static int +static void vlapic_fire_lvt(struct acrn_vlapic *vlapic, uint32_t lvt) { uint32_t vec, mode; struct vcpu *vcpu = vlapic->vcpu; if ((lvt & APIC_LVT_M) != 0U) { - return 0; + return; } vec = lvt & APIC_LVT_VECTOR; @@ -741,7 +741,7 @@ vlapic_fire_lvt(struct acrn_vlapic *vlapic, uint32_t lvt) case APIC_LVT_DM_FIXED: if (vec < 16U) { vlapic_set_error(vlapic, APIC_ESR_SEND_ILLEGAL_VECTOR); - return 0; + return; } if (vlapic_set_intr_ready(vlapic, vec, false) != 0) { vcpu_make_request(vcpu, ACRN_REQUEST_EVENT); @@ -755,9 +755,10 @@ vlapic_fire_lvt(struct acrn_vlapic *vlapic, uint32_t lvt) break; default: /* Other modes ignored */ - return 0; + pr_warn("func:%s other mode is not support\n",__func__); + return; } - return 1; + return; } static void diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index fa105fce2..8d5c467b2 100644 --- a/hypervisor/arch/x86/irq.c +++ b/hypervisor/arch/x86/irq.c @@ -72,7 +72,7 @@ void free_irq_num(uint32_t irq) if (irq_is_gsi(irq) == false) { spinlock_irqsave_obtain(&irq_alloc_spinlock, &rflags); - bitmap_test_and_clear_nolock((uint16_t)(irq & 0x3FU), + (void)bitmap_test_and_clear_nolock((uint16_t)(irq & 0x3FU), irq_alloc_bitmap + (irq >> 6U)); spinlock_irqrestore_release(&irq_alloc_spinlock, rflags); } diff --git a/hypervisor/arch/x86/mtrr.c b/hypervisor/arch/x86/mtrr.c index df4559416..facbe02fc 100644 --- a/hypervisor/arch/x86/mtrr.c +++ b/hypervisor/arch/x86/mtrr.c @@ -166,7 +166,7 @@ static void update_ept_mem_type(struct vcpu *vcpu) * - when def_type.FE is clear, MTRRdefType.type is applied */ if (!is_mtrr_enabled(vcpu) || !is_fixed_range_mtrr_enabled(vcpu)) { - update_ept(vcpu->vm, 0U, MAX_FIXED_RANGE_ADDR, + (void)update_ept(vcpu->vm, 0U, MAX_FIXED_RANGE_ADDR, get_default_memory_type(vcpu)); return; } @@ -182,14 +182,14 @@ static void update_ept_mem_type(struct vcpu *vcpu) if (type == vcpu->mtrr.fixed_range[i].type[j]) { size += get_subrange_size_of_fixed_mtrr(i); } else { - update_ept(vcpu->vm, start, size, type); + (void)update_ept(vcpu->vm, start, size, type); type = vcpu->mtrr.fixed_range[i].type[j]; start = get_subrange_start_of_fixed_mtrr(i, j); size = get_subrange_size_of_fixed_mtrr(i); } } - update_ept(vcpu->vm, start, size, type); + (void)update_ept(vcpu->vm, start, size, type); } } diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index 65b9fde66..9addcc00a 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -1165,9 +1165,10 @@ int assign_iommu_device(struct iommu_domain *domain, uint8_t bus, /* TODO: check if the device assigned */ - remove_iommu_device(vm0_domain, 0U, bus, devfun); - add_iommu_device(domain, 0U, bus, devfun); - return 0; + if (remove_iommu_device(vm0_domain, 0U, bus, devfun) == 1) { + return 1; + } + return add_iommu_device(domain, 0U, bus, devfun); } int unassign_iommu_device(struct iommu_domain *domain, uint8_t bus, @@ -1179,9 +1180,10 @@ int unassign_iommu_device(struct iommu_domain *domain, uint8_t bus, /* TODO: check if the device assigned */ - remove_iommu_device(domain, 0U, bus, devfun); - add_iommu_device(vm0_domain, 0U, bus, devfun); - return 0; + if (remove_iommu_device(domain, 0U, bus, devfun) == 1) { + return 1; + } + return add_iommu_device(vm0_domain, 0U, bus, devfun); } void enable_iommu(void) diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 2361482b1..713d6fa26 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -242,8 +242,7 @@ int32_t hcall_reset_vm(uint16_t vmid) return -1; } - reset_vm(target_vm); - return 0; + return reset_vm(target_vm); } /** @@ -905,7 +904,7 @@ int32_t hcall_setup_hv_npk_log(struct vm *vm, uint64_t param) { struct hv_npk_log_param npk_param; - memset((void *)&npk_param, 0U, sizeof(npk_param)); + (void)memset((void *)&npk_param, 0U, sizeof(npk_param)); if (copy_from_gpa(vm, &npk_param, param, sizeof(npk_param)) != 0) { pr_err("%s: Unable copy param from vm\n", __func__);