Skip to content

Commit a7398e8

Browse files
Shawnshhlijinxia
authored andcommitted
hv: hypercall: general 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. V1->V2: update the git comment to describe why comply with the rule(function's return entry should be only one). V2->V3: update the git comment title to give a scope declaration of this patch. Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent b627c2c commit a7398e8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

hypervisor/common/hypercall.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
bool is_hypercall_from_ring0(void)
1616
{
1717
uint16_t cs_sel;
18+
bool ret;
1819

1920
cs_sel = exec_vmread16(VMX_GUEST_CS_SEL);
2021
/* cs_selector[1:0] is CPL */
2122
if ((cs_sel & 0x3U) == 0U) {
22-
return true;
23+
ret = true;
24+
} else {
25+
ret = false;
2326
}
2427

25-
return false;
28+
return ret;
2629
}
2730

2831
/**
@@ -76,13 +79,16 @@ int32_t hcall_get_api_version(struct acrn_vm *vm, uint64_t param)
7679

7780
version.major_version = HV_API_MAJOR_VERSION;
7881
version.minor_version = HV_API_MINOR_VERSION;
82+
int32_t ret;
7983

8084
if (copy_to_gpa(vm, &version, param, sizeof(version)) != 0) {
8185
pr_err("%s: Unable copy param to vm\n", __func__);
82-
return -1;
86+
ret = -1;
87+
} else {
88+
ret = 0;
8389
}
8490

85-
return 0;
91+
return ret;
8692
}
8793

8894
/**

0 commit comments

Comments
 (0)