From ab3d7c87fdc44fdbdd9c92b16379767a2fcfe55e Mon Sep 17 00:00:00 2001 From: Huihuang Shi Date: Wed, 28 Nov 2018 10:21:09 +0800 Subject: [PATCH] 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 Acked-by: Eddie Dong --- hypervisor/boot/acpi.c | 13 ++++++++----- hypervisor/boot/sbl/multiboot.c | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hypervisor/boot/acpi.c b/hypervisor/boot/acpi.c index 34f4ae939..d9752eae4 100644 --- a/hypervisor/boot/acpi.c +++ b/hypervisor/boot/acpi.c @@ -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; } diff --git a/hypervisor/boot/sbl/multiboot.c b/hypervisor/boot/sbl/multiboot.c index 9066b6bca..d6a010fc0 100644 --- a/hypervisor/boot/sbl/multiboot.c +++ b/hypervisor/boot/sbl/multiboot.c @@ -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; } /**