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:
Huihuang Shi 2018-11-28 10:21:09 +08:00 committed by lijinxia
parent a1ac585b85
commit ab3d7c87fd
2 changed files with 10 additions and 7 deletions

View File

@ -162,17 +162,20 @@ static void *get_rsdp(void)
return rsdp;
}
static int
static bool
probe_table(uint64_t address, const char *sig)
{
void *va = hpa2hva(address);
struct acpi_table_header *table = (struct acpi_table_header *)va;
bool ret;
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)
@ -198,7 +201,7 @@ static void *get_acpi_tbl(const char *sig)
sizeof(uint64_t);
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];
break;
}
@ -212,7 +215,7 @@ static void *get_acpi_tbl(const char *sig)
sizeof(uint32_t);
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];
break;
}

View File

@ -149,10 +149,10 @@ static void *get_kernel_load_addr(void *kernel_src_addr)
*/
zeropage = (struct zero_page *)kernel_src_addr;
if (zeropage->hdr.relocatable_kernel != 0U) {
return (void *)zeropage->hdr.pref_addr;
zeropage = (void *)zeropage->hdr.pref_addr;
}
return kernel_src_addr;
return zeropage;
}
/**