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

[PATCH v2] misra: add deviation of Rule 10.1 for unary minus


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Mon, 14 Jul 2025 11:24:12 +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=lSiss5N4njq5/aoD5rf7VSps8X0ONTOJ1RSXNW4dG08=; b=jmwZB9zsJB9yQWoXkyPdnWN1LGBdlmzk5ft97/8F53s/n59ducUrwN+/27zRMFZ193QSdh6aUv9s2xiF2HwZnTlSjUFxXb5GY723qDpJfKND76zHGupEbKPFQ4fjqLak7Ut/aiAxoGrW4okv1PCB7kQRxY5i6HpfrempGsWoBkMU9YDjhZBNOR3vh30PkiIdSt+vwkxosznA1E3oFewHYrDOldop/IG6UXyZdEU4gz+jSMPtzOse/awfSMcEHytvSJAB1WQoqJajMsDtZ/acSujGRkehSqLZlrbmI+02zEBnfGSFcyWcmZh+p+lAPSK4VsDiTda6Hs/i+rCeXuxYaw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q39ZVo/E9O1yw9KcPp1Quk3If3irPHK6coMyH/J5ZUutWjuMu1R7Yc0EfaWlshN2I1rOpQMhKkx2EZ9wXydZcecI3pnVPbX4F69dqQD0HFy8L1j/xg0K2luTY1ChR9uLqZxRzD/8bIECW/Tpq6wHOpTIJVaCO0ko9S8Mdk/2Qg+nBtkhcExZzhC/VMNkYGQbPdSNTYxV3b00aQVNjKndcl7Hx1Z77nVUxdNaCUQ+GZjh9U5XGueDCrvZmlNkX6u122OelcqHdZ6CIQLiDj3Y7p60tGnvryl3/dB6n3CQ90gSloYN0km34p8cMGAU2maJBQnWB4KRpPwXr0C64nQImQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, 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>, Federico Serafini <federico.serafini@xxxxxxxxxxx>, Victor Lira <victorm.lira@xxxxxxx>, Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Delivery-date: Mon, 14 Jul 2025 11:24:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHb9LHT5f+FQP4BXEObxG6jgdfhYw==
  • Thread-topic: [PATCH v2] misra: add deviation of Rule 10.1 for unary minus

From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>

MISRA C Rule 10.1 states:
"Operands shall not be of an inappropriate essential type"

The unary minus operator applied to an unsigned type(s) has
a semantics (wrap around) that is well-defined by the toolchains.
Thus, this operation is deemed safe.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
Signed-off-by: Federico Serafini <federico.serafini@xxxxxxxxxxx>
Signed-off-by: Victor Lira <victorm.lira@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
Changes v2:
- improve the wording
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++
 docs/misra/deviations.rst                        | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index e8f513fbc5..8504e850c1 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -342,6 +342,12 @@ constant expressions are required.\""
   "any()"}
 -doc_end
 
+-doc_begin="Unary minus operations on unsigned type(s) have a semantics (wrap 
around) that is well-defined by the toolchains."
+-config=MC3A2.R10.1,etypes+={safe,
+  "stmt(node(unary_operator)&&operator(minus))",
+  "src_expr(definitely_in(0..))"}
+-doc_end
+
 #
 # Series 11
 #
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 0d56d45b66..620e97f0bd 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -325,6 +325,12 @@ Deviations related to MISRA C:2012 Rules:
        If no bits are set, 0 is returned.
      - Tagged as `safe` for ECLAIR.
 
+   * - R10.1
+     - Applying the unary minus operator to unsigned type(s) has a
+       semantics (wrap around) that is well-defined by the toolchains.
+       For this reason, the operation is safe.
+     - Tagged as `safe` for ECLAIR.
+
    * - R11.1
      - The conversion from a function pointer to unsigned long or (void \*) 
does
        not lose any information, provided that the target type has enough bits
-- 
2.43.0



 


Rackspace

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