mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 12:12:16 +00:00
hv: boot: 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: change the probe_table return value to bool type 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:
parent
a1ac585b85
commit
ab3d7c87fd
@ -162,17 +162,20 @@ static void *get_rsdp(void)
|
|||||||
return rsdp;
|
return rsdp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
probe_table(uint64_t address, const char *sig)
|
probe_table(uint64_t address, const char *sig)
|
||||||
{
|
{
|
||||||
void *va = hpa2hva(address);
|
void *va = hpa2hva(address);
|
||||||
struct acpi_table_header *table = (struct acpi_table_header *)va;
|
struct acpi_table_header *table = (struct acpi_table_header *)va;
|
||||||
|
bool ret;
|
||||||
|
|
||||||
if (strncmp(table->signature, sig, ACPI_NAME_SIZE) != 0) {
|
if (strncmp(table->signature, sig, ACPI_NAME_SIZE) != 0) {
|
||||||
return 0;
|
ret = false;
|
||||||
|
} else {
|
||||||
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *get_acpi_tbl(const char *sig)
|
static void *get_acpi_tbl(const char *sig)
|
||||||
@ -198,7 +201,7 @@ static void *get_acpi_tbl(const char *sig)
|
|||||||
sizeof(uint64_t);
|
sizeof(uint64_t);
|
||||||
|
|
||||||
for (i = 0U; i < count; i++) {
|
for (i = 0U; i < count; i++) {
|
||||||
if (probe_table(xsdt->table_offset_entry[i], sig) != 0) {
|
if (probe_table(xsdt->table_offset_entry[i], sig)) {
|
||||||
addr = xsdt->table_offset_entry[i];
|
addr = xsdt->table_offset_entry[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -212,7 +215,7 @@ static void *get_acpi_tbl(const char *sig)
|
|||||||
sizeof(uint32_t);
|
sizeof(uint32_t);
|
||||||
|
|
||||||
for (i = 0U; i < count; i++) {
|
for (i = 0U; i < count; i++) {
|
||||||
if (probe_table(rsdt->table_offset_entry[i], sig) != 0) {
|
if (probe_table(rsdt->table_offset_entry[i], sig)) {
|
||||||
addr = rsdt->table_offset_entry[i];
|
addr = rsdt->table_offset_entry[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -149,10 +149,10 @@ static void *get_kernel_load_addr(void *kernel_src_addr)
|
|||||||
*/
|
*/
|
||||||
zeropage = (struct zero_page *)kernel_src_addr;
|
zeropage = (struct zero_page *)kernel_src_addr;
|
||||||
if (zeropage->hdr.relocatable_kernel != 0U) {
|
if (zeropage->hdr.relocatable_kernel != 0U) {
|
||||||
return (void *)zeropage->hdr.pref_addr;
|
zeropage = (void *)zeropage->hdr.pref_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return kernel_src_addr;
|
return zeropage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user