[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3] arm: address violations of MISRA C Rule 2.1


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Wed, 24 Sep 2025 20:35:40 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sB0+C1pxh8R+Ds/c0r1Xd+nU31NJsXRp6/WwQyk7idg=; b=Aus6GIuejqWCT1gEhNkSPCsbia1/Jhh29dfnqGzKLYkBZuJ/5+MLuP2BTZM7V+rIUWBW+ulwdxT/3gNA3Ar2oLBl75FZdLAXyVblzkkPIGH+57ZHcmnpeY5XlqteGpkn0K0l74a5iUSTQGE2BvA32+uHDEGniIvB43Ts50iWjzkLMvSIEp5dFsxzomyTBQ3GIRyl8wazmroL3QW2dnRbNrzOvG/EJNd++K7uOqGwO/PfPDsLagoOgX8JRYukym2Awq1fXngbfo/ATCxaCo02jmISYc5yjU0q05L2Vln+ScPxkM6aV9gLtODAteXPSfiA5PmgNnOz7uIk/YY2o4BMbg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XpgIu36CfE41baqJK7QWmOs9J5+os3jDk+Bwm83O2f2WVQdHBUihMyn/7Ne/bM6+mPcWnB8w6yc/1jUz/RC1ahOrK11p9ARrPDMc9QlJOvrq6D4vG1JxGgjNbnCOshTdzFbU5wsYWjPpvCrze/oZkBiy/vHfzeq9RG0YF19PqNmU6p6sqTuhuDCer/+m1xRG5ckeKCXsERRtxY3ST1s6nlErxkezhW/67gy6NpfG5Ag7bM4/Dq+V2M9314Wz/t7omb7ezQ2nLgXzwhvB0AsNK3d6Iln9NcfiQdB3f6lnZ3yOKN7tiHdYAxj4DGboNFAWEAUBzhT61VlPVgZmbVWesg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 24 Sep 2025 20:36:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcLZLK+ABBtomrNE+mTHydZzSxzQ==
  • Thread-topic: [PATCH v3] arm: address violations of MISRA C Rule 2.1

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@xxxxxxxx>
---
Link to v2:
https://patchew.org/Xen/0adc0a8f75cb88b0b26d38289d1dd5823386290d.1758024454.git.dmytro._5Fprokopchuk1@xxxxxxxx/

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.