hv:fixed several return value violations

-- change two timer callbacks to void type
-- ignore the return value for add_timer
-- add (void) before several functions(memset/memcpy/
   vcpu_get_xxx)

v1-->v2:
   ignore the return value for add_timer
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Mingqiang Chi 2018-08-16 16:10:46 +08:00 committed by lijinxia
parent b37008d74e
commit 40fd8893b4
7 changed files with 32 additions and 23 deletions

View File

@ -96,7 +96,7 @@ apicv_batch_set_tmr(struct acrn_vlapic *vlapic);
*/
static void vlapic_set_error(struct acrn_vlapic *vlapic, uint32_t mask);
static int vlapic_timer_expired(void *data);
static void vlapic_timer_expired(void *data);
static struct acrn_vlapic *
vm_lapic_from_vcpu_id(struct vm *vm, uint16_t vcpu_id)
@ -394,7 +394,11 @@ static void vlapic_icrtmr_write_handler(struct acrn_vlapic *vlapic)
del_timer(&vtimer->timer);
if (set_expiration(vlapic)) {
add_timer(&vtimer->timer);
/* vlapic_create_timer has been called,
* and timer->fire_tsc is not 0, here
* add_timer should not return error
*/
(void)add_timer(&vtimer->timer);
}
}
@ -428,8 +432,11 @@ static void vlapic_set_tsc_deadline_msr(struct acrn_vlapic *vlapic,
/* transfer guest tsc to host tsc */
val -= exec_vmread64(VMX_TSC_OFFSET_FULL);
timer->fire_tsc = val;
add_timer(timer);
/* vlapic_create_timer has been called,
* and timer->fire_tsc is not 0,here
* add_timer should not return error
*/
(void)add_timer(timer);
} else {
timer->fire_tsc = 0UL;
}
@ -1311,7 +1318,11 @@ vlapic_svr_write_handler(struct acrn_vlapic *vlapic)
dev_dbg(ACRN_DBG_LAPIC, "vlapic is software-enabled");
if (vlapic_lvtt_period(vlapic)) {
if (set_expiration(vlapic)) {
add_timer(&vlapic->vtimer.timer);
/* vlapic_create_timer has been called,
* and timer->fire_tsc is not 0,here
* add_timer should not return error
*/
(void)add_timer(&vlapic->vtimer.timer);
}
}
}
@ -1883,7 +1894,7 @@ vlapic_intr_msi(struct vm *vm, uint64_t addr, uint64_t msg)
}
/* interrupt context */
static int vlapic_timer_expired(void *data)
static void vlapic_timer_expired(void *data)
{
struct vcpu *vcpu = (struct vcpu *)data;
struct acrn_vlapic *vlapic;
@ -1900,8 +1911,6 @@ static int vlapic_timer_expired(void *data)
if (!vlapic_lvtt_period(vlapic)) {
vlapic->vtimer.timer.fire_tsc = 0UL;
}
return 0;
}
int

View File

@ -210,10 +210,10 @@ void destroy_secure_world(struct vm *vm, bool need_clr_mem)
static void save_world_ctx(struct vcpu *vcpu, struct ext_context *ext_ctx)
{
/* cache on-demand run_context for efer/rflags/rsp/rip */
vcpu_get_efer(vcpu);
vcpu_get_rflags(vcpu);
vcpu_get_rsp(vcpu);
vcpu_get_rip(vcpu);
(void)vcpu_get_efer(vcpu);
(void)vcpu_get_rflags(vcpu);
(void)vcpu_get_rsp(vcpu);
(void)vcpu_get_rip(vcpu);
/* VMCS GUEST field */
ext_ctx->vmx_cr0 = exec_vmread(VMX_GUEST_CR0);
@ -426,7 +426,7 @@ bool initialize_trusty(struct vcpu *vcpu, uint64_t param)
struct vm *vm = vcpu->vm;
struct trusty_boot_param boot_param;
memset(&boot_param, 0U, sizeof(boot_param));
(void)memset(&boot_param, 0U, sizeof(boot_param));
if (copy_from_gpa(vcpu->vm, &boot_param, param, sizeof(boot_param))) {
pr_err("%s: Unable to copy trusty_boot_param\n", __func__);
return false;
@ -497,7 +497,7 @@ void trusty_set_dseed(void *dseed, uint8_t dseed_num)
void save_sworld_context(struct vcpu *vcpu)
{
memcpy_s(&vcpu->vm->sworld_snapshot,
(void)memcpy_s(&vcpu->vm->sworld_snapshot,
sizeof(struct cpu_context),
&vcpu->arch_vcpu.contexts[SECURE_WORLD],
sizeof(struct cpu_context));
@ -513,7 +513,7 @@ void restore_sworld_context(struct vcpu *vcpu)
sworld_ctl->sworld_memory.length,
TRUSTY_EPT_REBASE_GPA);
memcpy_s(&vcpu->arch_vcpu.contexts[SECURE_WORLD],
(void)memcpy_s(&vcpu->arch_vcpu.contexts[SECURE_WORLD],
sizeof(struct cpu_context),
&vcpu->vm->sworld_snapshot,
sizeof(struct cpu_context));

View File

@ -219,7 +219,7 @@ uint64_t prepare_trampoline(void)
pr_dbg("trampoline code: %llx size %x", dest_pa, size);
/* Copy segment for AP initialization code below 1MB */
memcpy_s(HPA2HVA(dest_pa), (size_t)size, &_ld_trampoline_load,
(void)memcpy_s(HPA2HVA(dest_pa), (size_t)size, &_ld_trampoline_load,
(size_t)size);
update_trampoline_code_refs(dest_pa);
trampoline_start16_paddr = dest_pa;

View File

@ -177,7 +177,7 @@ static void *parse_image_boot_params(struct vm *vm, char *cmdline)
*/
arg_end = strchr(arg, ' ');
len = arg_end ? (uint32_t)(arg_end - arg) : strnlen_s(arg, MEM_2K);
memset(arg, ' ', len);
(void)memset(arg, ' ', len);
return (void *)boot_params;
@ -297,7 +297,7 @@ int init_vm_boot_info(struct vm *vm)
* kernel cmdline
*/
if (boot_params_addr != NULL) {
memset(buf, 0U, sizeof(buf));
(void)memset(buf, 0U, sizeof(buf));
snprintf(buf, MAX_BOOT_PARAMS_LEN, "%s0x%X ",
boot_params_arg,
HVA2GPA(vm, (uint64_t)boot_params_addr));

View File

@ -32,7 +32,7 @@ char console_getc(void)
return uart16550_getc();
}
static int console_timer_callback(__unused void *data)
static void console_timer_callback(__unused void *data)
{
struct vuart *vu;
@ -46,7 +46,6 @@ static int console_timer_callback(__unused void *data)
} else {
shell_kick();
}
return 0;
}
void console_setup_timer(void)

View File

@ -813,18 +813,19 @@ static int shell_show_vioapic_info(int argc, char **argv)
static int shell_show_ioapic_info(__unused int argc, __unused char **argv)
{
int err = 0;
char *temp_str = alloc_pages(2U);
if (temp_str == NULL) {
return -ENOMEM;
}
get_ioapic_info(temp_str, 2 * CPU_PAGE_SIZE);
err = get_ioapic_info(temp_str, 2 * CPU_PAGE_SIZE);
shell_puts(temp_str);
free(temp_str);
return 0;
return err;
}
static int shell_show_vmexit_profile(__unused int argc, __unused char **argv)

View File

@ -7,7 +7,7 @@
#ifndef TIMER_H
#define TIMER_H
typedef int (*timer_handle_t)(void *data);
typedef void (*timer_handle_t)(void *data);
enum tick_mode {
TICK_MODE_ONESHOT = 0,