All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misra: deviate explicit cast for Rule 11.1
@ 2025-07-27 20:27 Dmytro Prokopchuk1
  2025-07-28  9:56 ` Jan Beulich
  0 siblings, 1 reply; 11+ messages in thread
From: Dmytro Prokopchuk1 @ 2025-07-27 20:27 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Dmytro Prokopchuk1, Andrew Cooper, Anthony PERARD, Michal Orzel,
	Jan Beulich, Julien Grall, Roger Pau Monné,
	Stefano Stabellini, Bertrand Marquis, Volodymyr Babchuk

Explicitly cast 'halt_this_cpu' when passing it
to 'smp_call_function' to match the required
function pointer type '(void (*)(void *info))'.

Document and justify a MISRA C R11.1 deviation
(explicit cast).

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
 docs/misra/safe.json    | 8 ++++++++
 xen/arch/arm/shutdown.c | 6 ++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index 3584cb90c6..26a04ec521 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -124,6 +124,14 @@
         },
         {
             "id": "SAF-15-safe",
+            "analyser": {
+                "eclair": "MC3A2.R11.1"
+            },
+            "name": "Rule 11.1: conversions shall not be performed between a pointer to a function and any other type",
+            "text": "The explicit cast from 'void noreturn (*)(void *)' to 'void (*)(void *)' is safe because the semantics of the 'noreturn' attribute do not alter the calling convention or behavior of the resulting code."
+        },
+        {
+            "id": "SAF-16-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
diff --git a/xen/arch/arm/shutdown.c b/xen/arch/arm/shutdown.c
index c9778e5786..57a5583820 100644
--- a/xen/arch/arm/shutdown.c
+++ b/xen/arch/arm/shutdown.c
@@ -25,7 +25,8 @@ void machine_halt(void)
     watchdog_disable();
     console_start_sync();
     local_irq_enable();
-    smp_call_function(halt_this_cpu, NULL, 0);
+    /* SAF-15-safe */
+    smp_call_function((void (*)(void *))halt_this_cpu, NULL, 0);
     local_irq_disable();
 
     /* Wait at most another 10ms for all other CPUs to go offline. */
@@ -50,7 +51,8 @@ void machine_restart(unsigned int delay_millisecs)
     spin_debug_disable();
 
     local_irq_enable();
-    smp_call_function(halt_this_cpu, NULL, 0);
+    /* SAF-15-safe */
+    smp_call_function((void (*)(void *))halt_this_cpu, NULL, 0);
     local_irq_disable();
 
     mdelay(delay_millisecs);
-- 
2.43.0


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

end of thread, other threads:[~2025-07-29 11:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-27 20:27 [PATCH] misra: deviate explicit cast for Rule 11.1 Dmytro Prokopchuk1
2025-07-28  9:56 ` Jan Beulich
2025-07-28 10:49   ` Andrew Cooper
2025-07-28 17:43     ` Nicola Vetrini
2025-07-28 18:03       ` Dmytro Prokopchuk1
2025-07-28 18:58         ` Dmytro Prokopchuk1
2025-07-28 19:17           ` Nicola Vetrini
2025-07-29  7:26             ` Jan Beulich
2025-07-29 11:03               ` Nicola Vetrini
2025-07-28 13:09   ` Dmytro Prokopchuk1
2025-07-28 13:23     ` Jan Beulich

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.