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

[PATCH] misra: deviate explicit cast for Rule 11.1


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Sun, 27 Jul 2025 20:27:06 +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=d7PKsoc0/AlChHS43x2lcSX826BmiABx1rjqCRh10r4=; b=WgD9qwVc1YlvkZGDoFCDmkhGg8v89pQSRjchISRqV9Sohx5mXyB9GeTKzPsimpjW2sH+KszOhOqdr/w5195mb7d40tz4O7gOfwFK6wvror/2SiKlDJD+76iQlJQ8m0uR4bwUaz/WRiwnJH/w+JUqz3vcUNTXH18FYh3giHLH+7dYvsPCNu+x17QBHxjRLrQLFPexP8ir0/LFOIs7mxCUtBKjX5QKi/v97RS7c1RMegYdsnlkdJ+72+M+Se5cOJjCGi8D+jkMioZbIkLCQxgDmhesB14hcGaV8CdkXArrXpjTnzu1sT/VOxPZwmXApqe30Gtl7IEc6Ru4hqh1mOSRMA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=my9TlKN+giDu8yCwVX6Sy70/Zc0EHdcDcBFdLgwFvGKnRIqu1Vw9Kn/Py+gBc2YDfWkH/tEY40/B/zv8R6VXz7n30eGCjTqaw0bwTgSVdKp7L8HWm54G2Dry1EFOa1+LxzeFb3lSRv+g7m+H77Clm5ILutmDNLh5AV6jQPRTDU86j5Yk5vmz93CX9ogKaI267q0SCwNVIuicYrtux24CGqNI7dxBvxhIy9qcrcN9dZYek8ZPFX2gAW7bFSDespDnBZdLVpU7ATlnosFbVCe8DiFguSnDp96YLDszq8h0vP70vufY19z665LUMEhzGFZm6/omsJFZmX6HCyUGSbzQ1Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Sun, 27 Jul 2025 20:27:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHb/zTS/PoTkNo+DkioPyw1aNE6Aw==
  • Thread-topic: [PATCH] misra: deviate explicit cast for Rule 11.1

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@xxxxxxxx>
---
 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



 


Rackspace

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