Skip to content

Commit 666430a

Browse files
mingqiangchilijinxia
authored andcommitted
hv:fix "missing for discarded return value" for memset
No need to check the return value for memset code like this: int a(void) { return 0; } int b(void){ a(); } fix as follow: int a(void) { return 0; } int b(void){ (void)a(); } Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 91ef6ed commit 666430a

File tree

24 files changed

+65
-63
lines changed

24 files changed

+65
-63
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void bsp_boot_init(void)
368368
start_tsc = rdtsc();
369369

370370
/* Clear BSS */
371-
memset(_ld_bss_start, 0, _ld_bss_end - _ld_bss_start);
371+
(void)memset(_ld_bss_start, 0, _ld_bss_end - _ld_bss_start);
372372

373373
/* Build time sanity checks to make sure hard-coded offset
374374
* is matching the actual offset!

hypervisor/arch/x86/cpu_state_tbl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void load_cpu_state_data(void)
113113
int tbl_idx;
114114
const struct cpu_state_info *state_info;
115115

116-
memset(&boot_cpu_data.state_info, 0,
116+
(void)memset(&boot_cpu_data.state_info, 0,
117117
sizeof(struct cpu_state_info));
118118

119119
tbl_idx = get_state_tbl_idx(boot_cpu_data.model_name);

hypervisor/arch/x86/ept.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ int ept_violation_vmexit_handler(struct vcpu *vcpu)
425425
* instruction emulation. For MMIO read, ask DM to run MMIO
426426
* emulation at first.
427427
*/
428-
memset(&vcpu->req, 0, sizeof(struct vhm_request));
428+
(void)memset(&vcpu->req, 0, sizeof(struct vhm_request));
429429

430430
if (dm_emulate_mmio_pre(vcpu, exit_qual) != 0)
431431
goto out;

hypervisor/arch/x86/guest/guest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ uint64_t create_guest_initial_paging(struct vm *vm)
726726
* number for it(without trusty) is GUEST_INIT_PT_PAGE_NUM-1.
727727
* here make sure they are init as 0 (page entry no present)
728728
*/
729-
memset(pml4_addr, 0, PAGE_SIZE_4K * GUEST_INIT_PT_PAGE_NUM-1);
729+
(void)memset(pml4_addr, 0, PAGE_SIZE_4K * GUEST_INIT_PT_PAGE_NUM-1);
730730

731731
/* Write PML4E */
732732
table_present = (IA32E_COMM_P_BIT | IA32E_COMM_RW_BIT);
@@ -766,7 +766,7 @@ uint64_t create_guest_initial_paging(struct vm *vm)
766766
*/
767767
if (vm->sworld_control.sworld_enabled && !is_vm0(vm)) {
768768
/* clear page entry for trusty */
769-
memset(pml4_addr + 6 * PAGE_SIZE_4K, 0, PAGE_SIZE_4K);
769+
(void)memset(pml4_addr + 6 * PAGE_SIZE_4K, 0, PAGE_SIZE_4K);
770770

771771
/* Write PDPTE for trusy memory, PD will use 7th page */
772772
pd_base_paddr = GUEST_INIT_PAGE_TABLE_START +

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ emulate_stack_op(struct vcpu *vcpu, uint64_t mmio_gpa, struct vie *vie,
12411241
uint8_t size, stackaddrsize;
12421242
uint32_t err_code = 0U;
12431243

1244-
memset(&ss_desc, 0U, sizeof(ss_desc));
1244+
(void)memset(&ss_desc, 0U, sizeof(ss_desc));
12451245

12461246
val = 0UL;
12471247
size = vie->opsize;
@@ -1690,7 +1690,7 @@ vie_init(struct vie *vie, struct vcpu *vcpu)
16901690
return -EINVAL;
16911691
}
16921692

1693-
memset(vie, 0U, sizeof(struct vie));
1693+
(void)memset(vie, 0U, sizeof(struct vie));
16941694

16951695
vie->base_register = CPU_REG_LAST;
16961696
vie->index_register = CPU_REG_LAST;

hypervisor/arch/x86/guest/pm.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ static void vm_setup_cpu_px(struct vm *vm)
3636
uint32_t px_data_size;
3737

3838
vm->pm.px_cnt = 0U;
39-
memset(vm->pm.px_data, 0, MAX_PSTATE * sizeof(struct cpu_px_data));
39+
(void)memset(vm->pm.px_data, 0,
40+
MAX_PSTATE * sizeof(struct cpu_px_data));
4041

4142
if ((boot_cpu_data.state_info.px_cnt == 0U)
4243
|| (boot_cpu_data.state_info.px_data == NULL)) {
@@ -60,7 +61,8 @@ static void vm_setup_cpu_cx(struct vm *vm)
6061
uint32_t cx_data_size;
6162

6263
vm->pm.cx_cnt = 0U;
63-
memset(vm->pm.cx_data, 0, MAX_CSTATE * sizeof(struct cpu_cx_data));
64+
(void)memset(vm->pm.cx_data, 0,
65+
MAX_CSTATE * sizeof(struct cpu_cx_data));
6466

6567
if ((boot_cpu_data.state_info.cx_cnt == 0U)
6668
|| (boot_cpu_data.state_info.cx_data == NULL)) {

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ int create_vcpu(uint16_t pcpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle)
9696
ASSERT(vcpu->arch_vcpu.vmcs != NULL, "");
9797

9898
/* Memset VMCS region for this VCPU */
99-
memset(vcpu->arch_vcpu.vmcs, 0, CPU_PAGE_SIZE);
99+
(void)memset(vcpu->arch_vcpu.vmcs, 0, CPU_PAGE_SIZE);
100100

101101
/* Initialize exception field in VCPU context */
102102
vcpu->arch_vcpu.exception_info.exception = VECTOR_INVALID;
@@ -283,7 +283,7 @@ void reset_vcpu(struct vcpu *vcpu)
283283
vcpu->arch_vcpu.cur_context = NORMAL_WORLD;
284284
vcpu->arch_vcpu.irq_window_enabled = 0;
285285
vcpu->arch_vcpu.inject_event_pending = false;
286-
memset(vcpu->arch_vcpu.vmcs, 0, CPU_PAGE_SIZE);
286+
(void)memset(vcpu->arch_vcpu.vmcs, 0, CPU_PAGE_SIZE);
287287

288288
vlapic = vcpu->arch_vcpu.vlapic;
289289
vlapic_reset(vlapic);

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static void vlapic_create_timer(struct vlapic *vlapic)
262262
return;
263263

264264
vlapic_timer = &vlapic->vlapic_timer;
265-
memset(vlapic_timer, 0, sizeof(struct vlapic_timer));
265+
(void)memset(vlapic_timer, 0, sizeof(struct vlapic_timer));
266266

267267
initialize_timer(&vlapic_timer->timer,
268268
vlapic_timer_expired, vlapic->vcpu,
@@ -1491,9 +1491,9 @@ vlapic_reset(struct vlapic *vlapic)
14911491

14921492
lapic = vlapic->apic_page;
14931493
apic_page = (void *)vlapic->apic_page;
1494-
memset(apic_page, 0, CPU_PAGE_SIZE);
1494+
(void)memset(apic_page, 0, CPU_PAGE_SIZE);
14951495
if (vlapic->pir_desc)
1496-
memset(vlapic->pir_desc, 0, sizeof(struct pir_desc));
1496+
(void)memset(vlapic->pir_desc, 0, sizeof(struct pir_desc));
14971497

14981498
lapic->id = vlapic_build_id(vlapic);
14991499
lapic->version = VLAPIC_VERSION;
@@ -1992,7 +1992,7 @@ int vlapic_create(struct vcpu *vcpu)
19921992
ASSERT(vlapic != NULL, "vlapic allocate failed");
19931993
ASSERT(apic_page != NULL, "apic reg page allocate failed");
19941994

1995-
memset((void *)apic_page, 0, CPU_PAGE_SIZE);
1995+
(void)memset((void *)apic_page, 0, CPU_PAGE_SIZE);
19961996
vlapic->vm = vcpu->vm;
19971997
vlapic->vcpu = vcpu;
19981998
vlapic->apic_page = (struct lapic_regs *)apic_page;
@@ -2169,7 +2169,7 @@ apicv_get_apic_access_addr(__unused struct vm *vm)
21692169
ASSERT(apicv_apic_access_addr != NULL,
21702170
"apicv allocate failed.");
21712171

2172-
memset((void *)apicv_apic_access_addr, 0, CPU_PAGE_SIZE);
2172+
(void)memset((void *)apicv_apic_access_addr, 0, CPU_PAGE_SIZE);
21732173
}
21742174
return HVA2HPA(apicv_apic_access_addr);
21752175
}

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void init_msr_emulation(struct vcpu *vcpu)
9292
/* Allocate and initialize memory for MSR bitmap region*/
9393
vcpu->vm->arch_vm.msr_bitmap = alloc_page();
9494
ASSERT(vcpu->vm->arch_vm.msr_bitmap != NULL, "");
95-
memset(vcpu->vm->arch_vm.msr_bitmap, 0x0, CPU_PAGE_SIZE);
95+
(void)memset(vcpu->vm->arch_vm.msr_bitmap, 0x0, CPU_PAGE_SIZE);
9696

9797
msr_bitmap = vcpu->vm->arch_vm.msr_bitmap;
9898

@@ -135,7 +135,7 @@ void init_msr_emulation(struct vcpu *vcpu)
135135
(uint64_t *)calloc(msrs_count, sizeof(uint64_t));
136136

137137
ASSERT(vcpu->guest_msrs != NULL, "");
138-
memset(vcpu->guest_msrs, 0, msrs_count * sizeof(uint64_t));
138+
(void)memset(vcpu->guest_msrs, 0, msrs_count * sizeof(uint64_t));
139139
}
140140

141141
int rdmsr_vmexit_handler(struct vcpu *vcpu)

hypervisor/arch/x86/io.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int io_instr_vmexit_handler(struct vcpu *vcpu)
113113
if (status != 0) {
114114
uint64_t *rax = &cur_context->guest_cpu_regs.regs.rax;
115115

116-
memset(&vcpu->req, 0, sizeof(struct vhm_request));
116+
(void)memset(&vcpu->req, 0, sizeof(struct vhm_request));
117117
dm_emulate_pio_pre(vcpu, exit_qual, sz, *rax);
118118
status = acrn_insert_request_wait(vcpu, &vcpu->req);
119119
}
@@ -220,12 +220,12 @@ void setup_io_bitmap(struct vm *vm)
220220
(vm->arch_vm.iobitmap[1] != NULL), "");
221221

222222
if (is_vm0(vm)) {
223-
memset(vm->arch_vm.iobitmap[0], 0x00, CPU_PAGE_SIZE);
224-
memset(vm->arch_vm.iobitmap[1], 0x00, CPU_PAGE_SIZE);
223+
(void)memset(vm->arch_vm.iobitmap[0], 0x00, CPU_PAGE_SIZE);
224+
(void)memset(vm->arch_vm.iobitmap[1], 0x00, CPU_PAGE_SIZE);
225225
} else {
226226
/* block all IO port access from Guest */
227-
memset(vm->arch_vm.iobitmap[0], 0xFF, CPU_PAGE_SIZE);
228-
memset(vm->arch_vm.iobitmap[1], 0xFF, CPU_PAGE_SIZE);
227+
(void)memset(vm->arch_vm.iobitmap[0], 0xFF, CPU_PAGE_SIZE);
228+
(void)memset(vm->arch_vm.iobitmap[1], 0xFF, CPU_PAGE_SIZE);
229229
}
230230
}
231231

0 commit comments

Comments
 (0)