hv: other: fix "Procedure has more than one exit point"

IEC 61508,ISO 26262 standards highly recommend single-exit rule.

Reduce the count of the "return entries".
Fix the violations which is comply with the cases list below:
1.Function has 2 return entries.
2.The first return entry is used to return the error code of
checking variable whether is valid.

Fix the violations in "if else" format.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Huihuang Shi 2018-11-29 11:10:36 +08:00 committed by wenlingz
parent fe3de67906
commit 10bde520a5
4 changed files with 82 additions and 83 deletions

View File

@ -111,6 +111,5 @@ void setup_posted_intr_notification(void)
posted_intr_notification,
NULL, IRQF_NONE) < 0) {
pr_err("Failed to setup posted-intr notification");
return;
}
}

View File

@ -131,12 +131,7 @@ void enter_s3(struct acrn_vm *vm, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val)
/* We assume enter s3 success by default */
host_enter_s3_success = 1U;
if (vm->pm.sx_state_data == NULL) {
pr_err("No Sx state info avaiable. No Sx support");
host_enter_s3_success = 0U;
return;
}
if (vm->pm.sx_state_data != NULL) {
pause_vm(vm); /* pause vm0 before suspend system */
pcpu_id = get_cpu_id();
@ -191,6 +186,11 @@ void enter_s3(struct acrn_vm *vm, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val)
/* jump back to vm */
resume_vm_from_s3(vm, guest_wakeup_vec32);
} else {
pr_err("No Sx state info avaiable. No Sx support");
host_enter_s3_success = 0U;
}
return;
}

View File

@ -134,11 +134,7 @@ void destroy_secure_world(struct acrn_vm *vm, bool need_clr_mem)
uint64_t gpa_uos = vm->sworld_control.sworld_memory.base_gpa_in_uos;
uint64_t size = vm->sworld_control.sworld_memory.length;
if (vm->arch_vm.sworld_eptp == NULL) {
pr_err("sworld eptp is NULL, it's not created");
return;
}
if (vm->arch_vm.sworld_eptp != NULL) {
if (need_clr_mem) {
/* clear trusty memory space */
(void)memset(hpa2hva(hpa), 0U, (size_t)size);
@ -151,6 +147,9 @@ void destroy_secure_world(struct acrn_vm *vm, bool need_clr_mem)
/* Restore memory to guest normal world */
ept_mr_add(vm, vm->arch_vm.nworld_eptp, hpa, gpa_uos, size, EPT_RWX | EPT_WB);
} else {
pr_err("sworld eptp is NULL, it's not created");
}
}
static inline void save_fxstore_guest_area(struct ext_context *ext_ctx)
@ -497,13 +496,12 @@ void trusty_set_dseed(const void *dseed, uint8_t dseed_num)
g_key_info.num_seeds = 1U;
(void)memset(g_key_info.dseed_list[0].seed, 0xA5U,
sizeof(g_key_info.dseed_list[0].seed));
return;
}
} else {
g_key_info.num_seeds = dseed_num;
(void)memcpy_s(&g_key_info.dseed_list,
sizeof(struct seed_info) * dseed_num,
dseed, sizeof(struct seed_info) * dseed_num);
}
}
void save_sworld_context(struct acrn_vcpu *vcpu)

View File

@ -81,13 +81,15 @@ static inline void pio_write(uint32_t v, uint16_t addr, size_t sz)
static inline uint32_t pio_read(uint16_t addr, size_t sz)
{
uint32_t ret;
if (sz == 1U) {
return pio_read8(addr);
ret = pio_read8(addr);
} else if (sz == 2U) {
ret = pio_read16(addr);
} else {
ret = pio_read32(addr);
}
if (sz == 2U) {
return pio_read16(addr);
}
return pio_read32(addr);
return ret;
}
/** Writes a 64 bit value to a memory mapped IO device.