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

[XEN PATCH] misra: merge the two R14.3 invariant-condition deviations


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Shuaidong Chen <shuaidong.chen@xxxxxxx>
  • Date: Mon, 26 Oct 2026 11:03:09 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=9GijEse6hff60BEqBgFxft9+bDZ0t5yGKOBH3CY1qHc=; b=jX51cplIU/1bvb1IwtwhKH9XPMjeMOt/kIubIp5YWWo9VloldsGzbkKw7ju7PraoR1HXN45C008MeO8NGs0hPDC8NjSBYDSZOfELa7WbQORM0MqVVFTc+bNqeRGJG9Jd9vTnCJOoPPlwNrhA6T3cva1lQljpyrhyTptsKGNxk4Yyz2214B9BQ0N7Rk+FSs1TNVQMwTzXw40Be3jz8Dz8ohmwYNWyeVmArcZ5DPDtPBFiMAAp6nNTGz2J9ZDMBsxmH8tsiu/BPxf4VXdKooEx536XsMDCOV6uFeL6j6x2dh/2xINDYix6pbNaCJ7iOfsa0wEnUyw00ETEw411JbMiZg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ASDKMIqi6o8V7hMwuWJhFwXzE8jBxeuk2x1ndRPCBorlCCgiYSg8KsiujrMFZCet0NjvHmRq5l/PCAk6ZIanbxTbGdQ/U61N6mJACHm/a9WgLB0iqBvOoIWS5BSAnZkx5RTL3py300FOOCugrkYYdpPyO3T1XQe8n2f+O3ENSym3P0/JriLkEJb4d+eqkmRxg5At9VKDP15eX9AmTwCvqutQwtwKA9GJ1b2ohGHWVRTbK4nLUYLJ2yJ0XNO9eQ+n2KIKCESyzh8YNgnFW3p3jbHEhfE9rjFjSIG5A4tPQyhHEB0BCTSVOZ37w3kFoieJw1l+evlHk+Fx9iTMKwYAzg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Anthony PERARD" <anthony.perard@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>, Ray Huang <Ray.Huang@xxxxxxx>, Shuaidong Chen <shuaidong.chen@xxxxxxx>
  • Delivery-date: Mon, 26 Oct 2026 03:03:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

MC3A2.R14.3 ("Controlling expressions shall not be invariant") is
deviated by two separate entries.  One covers 'if' statements and
conditional operators and places no restriction on where the invariant
condition comes from.  The other covers 'switch' statements, but only
when the controlling expression is a 'sizeof' operator.

The rationale recorded for the two is the same: the condition is
deliberate.  Nothing about a 'switch' makes an invariant condition less
deliberate than the same condition in an 'if', so the 'sizeof'
restriction reads as an artefact of that entry having been added for
read_atomic() and friends in arch/x86/include/asm/atomic.h rather than
as a considered limit.

Fold switch_stmt into the general entry and drop the 'sizeof'-restricted
one, which the general predicate now subsumes.  Invariant 'switch'
conditions that are not a 'sizeof' become deliberate as a result; that
is the intent.

Signed-off-by: Shuaidong Chen <shuaidong.chen@xxxxxxx>
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 8 ++------
 docs/misra/deviations.rst                        | 8 ++------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 7f3fd35a33d..08a88ddfa62 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -472,12 +472,8 @@ activity."
 -config=MC3A2.R14.2,reports+={disapplied,"any()"}
 -doc_end
 
--doc_begin="The XEN team relies on the fact that invariant conditions of 'if' 
statements and conditional operators are deliberate"
--config=MC3A2.R14.3,statements+={deliberate, 
"wrapped(any(),node(if_stmt||conditional_operator||binary_conditional_operator))"
 }
--doc_end
-
--doc_begin="Switches having a 'sizeof' operator as the condition are 
deliberate and have limited scope."
--config=MC3A2.R14.3,statements+={deliberate, 
"wrapped(any(),node(switch_stmt)&&child(cond, operator(sizeof)))" }
+-doc_begin="The XEN team relies on the fact that invariant conditions of 'if' 
statements, conditional operators and 'switch' statements are deliberate"
+-config=MC3A2.R14.3,statements+={deliberate, 
"wrapped(any(),node(if_stmt||conditional_operator||binary_conditional_operator||switch_stmt))"
 }
 -doc_end
 
 -doc_begin="The use of an invariant size argument in {put,get}_unsafe_size and 
array_access_ok, as defined in arch/x86(_64)?/include/asm/uaccess.h is 
deliberate and is deemed safe."
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 32713172067..99a1b2332c2 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -458,12 +458,8 @@ Deviations related to MISRA C:2012 Rules:
 
    * - R14.3
      - The Xen team relies on the fact that invariant conditions of 'if'
-       statements and conditional operators are deliberate.
-     - Tagged as `deliberate` for ECLAIR.
-
-   * - R14.3
-     - Switches having a 'sizeof' operator as the condition are deliberate and
-       have limited scope.
+       statements, conditional operators and 'switch' statements are
+       deliberate.
      - Tagged as `deliberate` for ECLAIR.
 
    * - R14.3
-- 
2.34.1




 


Rackspace

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