[PATCH v4 1/2] arm/acpi: address violations of MISRA C Rule 2.1

Dmytro Prokopchuk1 posted 2 patches 5 days, 3 hours ago
[PATCH v4 1/2] arm/acpi: address violations of MISRA C Rule 2.1
Posted by Dmytro Prokopchuk1 5 days, 3 hours ago
MISRA C Rule 2.1 states: "A project shall not contain unreachable code".
In certain build configuration the following function 'prepare_acpi()' is
defined as inline function and contains the macro 'BUG()'. This resulted
in violation due to the function became non-returning.

To ensure compliance with MISRA C Rule 2.1 remove inline function and its
'BUG()'-based unreachable code. Provide unconditional function declaration
for 'prepare_acpi()'. Rely on the compiler's DCE to remove unused function
calls and use the compile-time constant predicate 'acpi_disabled', defined
as true when 'CONFIG_ACPI' is disabled, to statically resolve conditional
branches:
    if ( acpi_disabled )
    {
        ...
    }
    else
        rc = prepare_acpi(d, kinfo);

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
 xen/arch/arm/include/asm/domain_build.h | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include/asm/domain_build.h
index c6fec3168c..6674dac5e2 100644
--- a/xen/arch/arm/include/asm/domain_build.h
+++ b/xen/arch/arm/include/asm/domain_build.h
@@ -15,16 +15,7 @@ void evtchn_allocate(struct domain *d);
 void set_interrupt(gic_interrupt_t interrupt, unsigned int irq,
                    unsigned int cpumask, unsigned int level);
 
-#ifndef CONFIG_ACPI
-static inline int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
-{
-    /* Only booting with ACPI will hit here */
-    BUG();
-    return -EINVAL;
-}
-#else
 int prepare_acpi(struct domain *d, struct kernel_info *kinfo);
-#endif
 
 int add_ext_regions(unsigned long s_gfn, unsigned long e_gfn, void *data);
 
-- 
2.43.0