mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 02:08:04 +00:00
hv:fix "missing for discarded return value" for memcpy_s and strcpy_s
It will print error information inside memcpy_s if the parameteter is invalid, the caller can not check the return value for memcpy_s/strcpy_s/strncpy_s 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>
This commit is contained in:
@@ -144,7 +144,7 @@ int64_t hcall_create_vm(struct vm *vm, uint64_t param)
|
||||
(void)memset(&vm_desc, 0, sizeof(vm_desc));
|
||||
vm_desc.sworld_enabled =
|
||||
(!!(cv.vm_flag & (SECURE_WORLD_ENABLED)));
|
||||
memcpy_s(&vm_desc.GUID[0], 16, &cv.GUID[0], 16);
|
||||
(void)memcpy_s(&vm_desc.GUID[0], 16, &cv.GUID[0], 16);
|
||||
ret = create_vm(&vm_desc, &target_vm);
|
||||
|
||||
if (ret != 0) {
|
||||
|
@@ -71,7 +71,7 @@ int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req)
|
||||
|
||||
/* ACRN insert request to VHM and inject upcall */
|
||||
cur = vcpu->vcpu_id;
|
||||
memcpy_s(&req_buf->req_queue[cur], sizeof(struct vhm_request),
|
||||
(void)memcpy_s(&req_buf->req_queue[cur], sizeof(struct vhm_request),
|
||||
req, sizeof(struct vhm_request));
|
||||
|
||||
/* pause vcpu, wait for VHM to handle the MMIO request.
|
||||
@@ -100,50 +100,50 @@ int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req)
|
||||
static void _get_req_info_(struct vhm_request *req, int *id, char *type,
|
||||
char *state, char *dir, long *addr, long *val)
|
||||
{
|
||||
strcpy_s(dir, 16, "NONE");
|
||||
(void)strcpy_s(dir, 16, "NONE");
|
||||
*addr = *val = 0;
|
||||
*id = req->client;
|
||||
|
||||
switch (req->type) {
|
||||
case REQ_PORTIO:
|
||||
strcpy_s(type, 16, "PORTIO");
|
||||
(void)strcpy_s(type, 16, "PORTIO");
|
||||
if (req->reqs.pio_request.direction == REQUEST_READ)
|
||||
strcpy_s(dir, 16, "READ");
|
||||
(void)strcpy_s(dir, 16, "READ");
|
||||
else
|
||||
strcpy_s(dir, 16, "WRITE");
|
||||
(void)strcpy_s(dir, 16, "WRITE");
|
||||
*addr = req->reqs.pio_request.address;
|
||||
*val = req->reqs.pio_request.value;
|
||||
break;
|
||||
case REQ_MMIO:
|
||||
case REQ_WP:
|
||||
strcpy_s(type, 16, "MMIO/WP");
|
||||
(void)strcpy_s(type, 16, "MMIO/WP");
|
||||
if (req->reqs.mmio_request.direction == REQUEST_READ)
|
||||
strcpy_s(dir, 16, "READ");
|
||||
(void)strcpy_s(dir, 16, "READ");
|
||||
else
|
||||
strcpy_s(dir, 16, "WRITE");
|
||||
(void)strcpy_s(dir, 16, "WRITE");
|
||||
*addr = req->reqs.mmio_request.address;
|
||||
*val = req->reqs.mmio_request.value;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
strcpy_s(type, 16, "UNKNOWN");
|
||||
(void)strcpy_s(type, 16, "UNKNOWN");
|
||||
}
|
||||
|
||||
switch (req->processed) {
|
||||
case REQ_STATE_SUCCESS:
|
||||
strcpy_s(state, 16, "SUCCESS");
|
||||
(void)strcpy_s(state, 16, "SUCCESS");
|
||||
break;
|
||||
case REQ_STATE_PENDING:
|
||||
strcpy_s(state, 16, "PENDING");
|
||||
(void)strcpy_s(state, 16, "PENDING");
|
||||
break;
|
||||
case REQ_STATE_PROCESSING:
|
||||
strcpy_s(state, 16, "PROCESS");
|
||||
(void)strcpy_s(state, 16, "PROCESS");
|
||||
break;
|
||||
case REQ_STATE_FAILED:
|
||||
strcpy_s(state, 16, "FAILED");
|
||||
(void)strcpy_s(state, 16, "FAILED");
|
||||
break;
|
||||
default:
|
||||
strcpy_s(state, 16, "UNKNOWN");
|
||||
(void)strcpy_s(state, 16, "UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,7 @@ static uint64_t create_zero_page(struct vm *vm)
|
||||
|
||||
/* copy part of the header into the zero page */
|
||||
hva = GPA2HVA(vm, (uint64_t)vm->sw.kernel_info.kernel_load_addr);
|
||||
memcpy_s(&(zeropage->hdr), sizeof(zeropage->hdr),
|
||||
(void)memcpy_s(&(zeropage->hdr), sizeof(zeropage->hdr),
|
||||
&(hva->hdr), sizeof(hva->hdr));
|
||||
|
||||
/* See if kernel has a RAM disk */
|
||||
@@ -140,7 +140,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
|
||||
hva = GPA2HVA(vm, (uint64_t)vm->sw.kernel_info.kernel_load_addr);
|
||||
|
||||
/* Copy the guest kernel image to its run-time location */
|
||||
memcpy_s((void *)hva, vm->sw.kernel_info.kernel_size,
|
||||
(void)memcpy_s((void *)hva, vm->sw.kernel_info.kernel_size,
|
||||
vm->sw.kernel_info.kernel_src_addr,
|
||||
vm->sw.kernel_info.kernel_size);
|
||||
|
||||
@@ -157,7 +157,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
|
||||
(uint64_t)vm->sw.linux_info.bootargs_load_addr);
|
||||
|
||||
/* Copy Guest OS bootargs to its load location */
|
||||
strcpy_s((char *)hva, MEM_2K,
|
||||
(void)strcpy_s((char *)hva, MEM_2K,
|
||||
vm->sw.linux_info.bootargs_src_addr);
|
||||
|
||||
#ifdef CONFIG_CMA
|
||||
@@ -166,7 +166,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
|
||||
snprintf(dyn_bootargs, 100, " cma=%dM@0x%llx",
|
||||
(e820_mem.max_ram_blk_size >> 20),
|
||||
e820_mem.max_ram_blk_base);
|
||||
strcpy_s((char *)hva
|
||||
(void)strcpy_s((char *)hva
|
||||
+vm->sw.linux_info.bootargs_size,
|
||||
100, dyn_bootargs);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
|
||||
snprintf(dyn_bootargs, 100,
|
||||
" hugepagesz=1G hugepages=%d",
|
||||
reserving_1g_pages);
|
||||
strcpy_s((char *)hva
|
||||
(void)strcpy_s((char *)hva
|
||||
+vm->sw.linux_info.bootargs_size,
|
||||
100, dyn_bootargs);
|
||||
}
|
||||
@@ -203,7 +203,8 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
|
||||
(uint64_t)vm->sw.linux_info.ramdisk_load_addr);
|
||||
|
||||
/* Copy RAM disk to its load location */
|
||||
memcpy_s((void *)hva, vm->sw.linux_info.ramdisk_size,
|
||||
(void)memcpy_s((void *)hva,
|
||||
vm->sw.linux_info.ramdisk_size,
|
||||
vm->sw.linux_info.ramdisk_src_addr,
|
||||
vm->sw.linux_info.ramdisk_size);
|
||||
|
||||
|
Reference in New Issue
Block a user