xen/arch/arm/include/asm/domain_build.h | 9 --------- xen/arch/arm/include/asm/gic_v3_its.h | 11 ++--------- 2 files changed, 2 insertions(+), 18 deletions(-)
MISRA C Rule 2.1 states: "A project shall not contain unreachable code".
In certain build configurations the following functions 'prepare_acpi()'
and 'gicv3_its_setup_collection()' are defined as inline functions and
contain the macro 'BUG()'. This resulted in violations due to these
functions became non-returning.
To ensure compliance with MISRA C Rule 2.1 remove inline function
implementations and their 'BUG()'-based unreachable code. Provide
unconditional function declarations for 'gicv3_its_setup_collection()'
and 'prepare_acpi()'. Rely on the compiler's DCE to remove unused function
calls in builds where these configs 'CONFIG_ACPI' or 'CONFIG_HAS_ITS' are
not enabled.
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
Link to v2:
https://patchew.org/Xen/0adc0a8f75cb88b0b26d38289d1dd5823386290d.1758024454.git.dmytro._5Fprokopchuk1@epam.com/
Changes in v3:
- updated commit subject and message
- removed inline functions with unreachable code
- provided unconditional function declarations
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2060806048
---
xen/arch/arm/include/asm/domain_build.h | 9 ---------
xen/arch/arm/include/asm/gic_v3_its.h | 11 ++---------
2 files changed, 2 insertions(+), 18 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);
diff --git a/xen/arch/arm/include/asm/gic_v3_its.h b/xen/arch/arm/include/asm/gic_v3_its.h
index 0737e67aa6..fc5a84892c 100644
--- a/xen/arch/arm/include/asm/gic_v3_its.h
+++ b/xen/arch/arm/include/asm/gic_v3_its.h
@@ -131,6 +131,8 @@ struct host_its {
unsigned int flags;
};
+/* Map a collection for this host CPU to each host ITS. */
+int gicv3_its_setup_collection(unsigned int cpu);
#ifdef CONFIG_HAS_ITS
@@ -160,9 +162,6 @@ int gicv3_its_init(void);
void gicv3_set_redist_address(paddr_t address, unsigned int redist_id);
uint64_t gicv3_get_redist_address(unsigned int cpu, bool use_pta);
-/* Map a collection for this host CPU to each host ITS. */
-int gicv3_its_setup_collection(unsigned int cpu);
-
/* Initialize and destroy the per-domain parts of the virtual ITS support. */
int vgic_v3_its_init_domain(struct domain *d);
void vgic_v3_its_free_domain(struct domain *d);
@@ -256,12 +255,6 @@ static inline void gicv3_set_redist_address(paddr_t address,
{
}
-static inline int gicv3_its_setup_collection(unsigned int cpu)
-{
- /* We should never get here without an ITS. */
- BUG();
-}
-
static inline int vgic_v3_its_init_domain(struct domain *d)
{
return 0;
--
2.43.0
On 24.09.2025 22:35, Dmytro Prokopchuk1 wrote: > MISRA C Rule 2.1 states: "A project shall not contain unreachable code". > In certain build configurations the following functions 'prepare_acpi()' > and 'gicv3_its_setup_collection()' are defined as inline functions and > contain the macro 'BUG()'. This resulted in violations due to these > functions became non-returning. > > To ensure compliance with MISRA C Rule 2.1 remove inline function > implementations and their 'BUG()'-based unreachable code. Provide > unconditional function declarations for 'gicv3_its_setup_collection()' > and 'prepare_acpi()'. Rely on the compiler's DCE to remove unused function > calls in builds where these configs 'CONFIG_ACPI' or 'CONFIG_HAS_ITS' are > not enabled. Imo it would have helped if you had stated the respective predicates which end up compile-time constant. (Likely the two changes also could have been done separately, as they're entirely independent of one another afaict.) > Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Jan
© 2016 - 2025 Red Hat, Inc.