All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen: address violation of MISRA C Rule 11.1
@ 2024-12-11 11:02 Alessandro Zucchelli
  2024-12-11 11:17 ` Jan Beulich
  0 siblings, 1 reply; 10+ messages in thread
From: Alessandro Zucchelli @ 2024-12-11 11:02 UTC (permalink / raw)
  To: xen-devel
  Cc: consulting, Alessandro Zucchelli, Stefano Stabellini,
	Julien Grall, Bertrand Marquis, Michal Orzel, Volodymyr Babchuk,
	Jan Beulich, Andrew Cooper, Roger Pau Monné

Rule 11.1 states as following: "Conversions shall not be performed
between a pointer to a function and any other type".

Functions "__machine_restart" and "__machine_halt" in "x86/shutdown.c"
and "halt_this_cpu" in "arm/shutdown.c" are defined as noreturn
functions and subsequently passed as parameters to function calls.
This violates the rule in Clang, where the "noreturn" attribute is
considered part of the function"s type. By removing the "noreturn"
attribbute and replacing it with uses of the ASSERT_UNREACHABLE macro,
these violations are addressed.

Signed-off-by: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com>
---
 xen/arch/arm/shutdown.c | 3 ++-
 xen/arch/x86/shutdown.c | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/shutdown.c b/xen/arch/arm/shutdown.c
index c9778e5786..e679ae8d72 100644
--- a/xen/arch/arm/shutdown.c
+++ b/xen/arch/arm/shutdown.c
@@ -8,7 +8,7 @@
 #include <asm/platform.h>
 #include <asm/psci.h>
 
-static void noreturn halt_this_cpu(void *arg)
+static void halt_this_cpu(void *arg)
 {
     local_irq_disable();
     /* Make sure the write happens before we sleep forever */
@@ -38,6 +38,7 @@ void machine_halt(void)
     /* Alternative halt procedure */
     platform_poweroff();
     halt_this_cpu(NULL);
+    ASSERT_UNREACHABLE();
 }
 
 void machine_restart(unsigned int delay_millisecs)
diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c
index 902076cf67..b684e19754 100644
--- a/xen/arch/x86/shutdown.c
+++ b/xen/arch/x86/shutdown.c
@@ -118,7 +118,7 @@ static inline void kb_wait(void)
             break;
 }
 
-static void noreturn cf_check __machine_halt(void *unused)
+static void cf_check __machine_halt(void *unused)
 {
     local_irq_disable();
 
@@ -127,6 +127,7 @@ static void noreturn cf_check __machine_halt(void *unused)
 
     for ( ; ; )
         halt();
+    ASSERT_UNREACHABLE();
 }
 
 void machine_halt(void)
@@ -141,6 +142,7 @@ void machine_halt(void)
     }
 
     __machine_halt(NULL);
+    ASSERT_UNREACHABLE();
 }
 
 static void default_reboot_type(void)
@@ -520,9 +522,10 @@ static int __init cf_check reboot_init(void)
 }
 __initcall(reboot_init);
 
-static void cf_check noreturn __machine_restart(void *pdelay)
+static void cf_check __machine_restart(void *pdelay)
 {
     machine_restart(*(unsigned int *)pdelay);
+    ASSERT_UNREACHABLE();
 }
 
 void machine_restart(unsigned int delay_millisecs)
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-12-18 11:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11 11:02 [PATCH] xen: address violation of MISRA C Rule 11.1 Alessandro Zucchelli
2024-12-11 11:17 ` Jan Beulich
2024-12-12  2:27   ` Stefano Stabellini
2024-12-12 10:32     ` Jan Beulich
2024-12-13  0:53       ` Stefano Stabellini
2024-12-13 10:08         ` Jan Beulich
2024-12-13 14:02           ` Alessandro Zucchelli
2024-12-13 21:34             ` Stefano Stabellini
2024-12-16  7:26             ` Jan Beulich
2024-12-18 11:16               ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.