xen/arch/arm/gic-v2.c | 2 +- xen/arch/arm/include/asm/gic_v3_its.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
MISRA C Rule 2.1 states: "A project shall not contain unreachable code."
The GIC LPI driver callbacks violate this due to the use of the BUG()
macro, which causes the function to never return.
Swap BUG() for ASSERT_UNREACHABLE() to satisfy the rule without needing
an additional deviation.
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
Changes in v2:
- replace the BUG with ASSERT_UNRECHEABLE
- drop SAF-based deviation
Link to v1:
https://patchew.org/Xen/b26772df8733dbd1ce6ea14a6e8b73f278db3a3d.1759174857.git.dmytro._5Fprokopchuk1@epam.com/
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2215606139
---
xen/arch/arm/gic-v2.c | 2 +-
xen/arch/arm/include/asm/gic_v3_its.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index b23e72a3d0..db8bc310ab 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -1308,7 +1308,7 @@ static int __init gicv2_init(void)
static void gicv2_do_LPI(unsigned int lpi)
{
/* No LPIs in a GICv2 */
- BUG();
+ ASSERT_UNREACHABLE();
}
static const struct gic_hw_operations gicv2_ops = {
diff --git a/xen/arch/arm/include/asm/gic_v3_its.h b/xen/arch/arm/include/asm/gic_v3_its.h
index fc5a84892c..09c1538b75 100644
--- a/xen/arch/arm/include/asm/gic_v3_its.h
+++ b/xen/arch/arm/include/asm/gic_v3_its.h
@@ -232,7 +232,7 @@ static inline unsigned int vgic_v3_its_count(const struct domain *d)
static inline void gicv3_do_LPI(unsigned int lpi)
{
/* We don't enable LPIs without an ITS. */
- BUG();
+ ASSERT_UNREACHABLE();
}
static inline int gicv3_lpi_init_rdist(void __iomem * rdist_base)
--
2.43.0
On 16/12/2025 09:22, Dmytro Prokopchuk1 wrote: > MISRA C Rule 2.1 states: "A project shall not contain unreachable code." > The GIC LPI driver callbacks violate this due to the use of the BUG() > macro, which causes the function to never return. > > Swap BUG() for ASSERT_UNREACHABLE() to satisfy the rule without needing > an additional deviation. > > Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com> Reviewed-by: Michal Orzel <michal.orzel@amd.com> ~Michal
© 2016 - 2025 Red Hat, Inc.