hv: memory: 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:09:12 +08:00 committed by wenlingz
parent ddb548367a
commit 279808b202
2 changed files with 20 additions and 23 deletions

View File

@ -156,12 +156,10 @@ uint16_t allocate_vpid(void)
void flush_vpid_single(uint16_t vpid) void flush_vpid_single(uint16_t vpid)
{ {
if (vpid == 0U) { if (vpid != 0U) {
return;
}
local_invvpid(VMX_VPID_TYPE_SINGLE_CONTEXT, vpid, 0UL); local_invvpid(VMX_VPID_TYPE_SINGLE_CONTEXT, vpid, 0UL);
} }
}
void flush_vpid_global(void) void flush_vpid_global(void)
{ {

View File

@ -165,9 +165,7 @@ static void update_ept_mem_type(const struct acrn_vcpu *vcpu)
*/ */
if (!is_mtrr_enabled(vcpu) || !is_fixed_range_mtrr_enabled(vcpu)) { if (!is_mtrr_enabled(vcpu) || !is_fixed_range_mtrr_enabled(vcpu)) {
update_ept(vcpu->vm, 0U, MAX_FIXED_RANGE_ADDR, get_default_memory_type(vcpu)); update_ept(vcpu->vm, 0U, MAX_FIXED_RANGE_ADDR, get_default_memory_type(vcpu));
return; } else {
}
/* Deal with fixed-range MTRRs only */ /* Deal with fixed-range MTRRs only */
for (i = 0U; i < FIXED_RANGE_MTRR_NUM; i++) { for (i = 0U; i < FIXED_RANGE_MTRR_NUM; i++) {
type = vcpu->mtrr.fixed_range[i].type[0]; type = vcpu->mtrr.fixed_range[i].type[0];
@ -189,6 +187,7 @@ static void update_ept_mem_type(const struct acrn_vcpu *vcpu)
update_ept(vcpu->vm, start, size, type); update_ept(vcpu->vm, start, size, type);
} }
} }
}
void mtrr_wrmsr(struct acrn_vcpu *vcpu, uint32_t msr, uint64_t value) void mtrr_wrmsr(struct acrn_vcpu *vcpu, uint32_t msr, uint64_t value)
{ {