mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-07 17:46:15 +00:00
hv: cpu_state_tbl: fix multiple exits
This patch fixes the MISRA-C violations in arch/x86/cpu_state_tbl.c * make the function have only one exit point Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -106,19 +106,18 @@ static int32_t get_state_tbl_idx(const char *cpuname)
|
|||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
int32_t count = ARRAY_SIZE(cpu_state_tbl);
|
int32_t count = ARRAY_SIZE(cpu_state_tbl);
|
||||||
|
int32_t ret = -1;
|
||||||
|
|
||||||
if (cpuname == NULL) {
|
if (cpuname != NULL) {
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
if (strcmp((cpu_state_tbl[i].model_name),
|
if (strcmp((cpu_state_tbl[i].model_name), cpuname) == 0) {
|
||||||
cpuname) == 0) {
|
ret = i;
|
||||||
return i;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_cpu_state_data(void)
|
void load_cpu_state_data(void)
|
||||||
@@ -126,14 +125,12 @@ void load_cpu_state_data(void)
|
|||||||
int32_t tbl_idx;
|
int32_t tbl_idx;
|
||||||
const struct cpu_state_info *state_info;
|
const struct cpu_state_info *state_info;
|
||||||
|
|
||||||
(void)memset(&boot_cpu_data.state_info, 0U,
|
(void)memset(&boot_cpu_data.state_info, 0U, sizeof(struct cpu_state_info));
|
||||||
sizeof(struct cpu_state_info));
|
|
||||||
|
|
||||||
tbl_idx = get_state_tbl_idx(boot_cpu_data.model_name);
|
tbl_idx = get_state_tbl_idx(boot_cpu_data.model_name);
|
||||||
if (tbl_idx < 0) {
|
|
||||||
/* The state table is not found. */
|
if (tbl_idx >= 0) {
|
||||||
return;
|
/* The state table is found. */
|
||||||
}
|
|
||||||
|
|
||||||
state_info = &(cpu_state_tbl + tbl_idx)->state_info;
|
state_info = &(cpu_state_tbl + tbl_idx)->state_info;
|
||||||
|
|
||||||
@@ -156,5 +153,5 @@ void load_cpu_state_data(void)
|
|||||||
|
|
||||||
boot_cpu_data.state_info.cx_data = state_info->cx_data;
|
boot_cpu_data.state_info.cx_data = state_info->cx_data;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user