From: Maria Celeste Cesario <maria.celeste.cesa...@bugseng.com>

The xen sources contain violations of MISRA C:2012 Rule 14.4 whose
headline states:
"The controlling expression of an if statement and the controlling
expression of an iteration-statement shall have essentially Boolean type".

Struct domain member is_dying is an anonymous enum designed to act as boolean.
Add deviation to mark its uses in controlling expressions as deliberate.

Signed-off-by: Maria Celeste Cesario <maria.celeste.cesa...@bugseng.com>
Signed-off-by: Simone Ballarin <simone.balla...@bugseng.com>
---
 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 b0c79741b5..683f2bbfe8 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -321,6 +321,12 @@ statements are deliberate"
 -config=MC3R1.R14.3,statements={deliberate , "wrapped(any(),node(if_stmt))" }
 -doc_end
 
+-doc_begin="The XEN team relies on the fact that the enum is_dying has the
+constant with assigned value 0 act as false and the other ones as true,
+therefore have the same behavior of a boolean"
+-config=MC3R1.R14.4,etypes+={deliberate, 
"stmt(child(cond,child(expr,ref(^<?domain>?::is_dying$))))","src_type(enum)"}
+-doc_end
+
 #
 # Series 20.
 #
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 6e7c4f25b8..eda3c8100c 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -270,6 +270,12 @@ Deviations related to MISRA C:2012 Rules:
        statements are deliberate.
      - Project-wide deviation; tagged as `disapplied` for ECLAIR.
 
+   * - R14.4
+     - The XEN team relies on the fact that the enum is_dying has the
+       constant with assigned value 0 act as false and the other ones as true,
+       therefore have the same behavior of a boolean.
+     - Project-wide deviation; tagged as `deliberate` for ECLAIR.
+
    * - R20.7
      - Code violating Rule 20.7 is safe when macro parameters are used:
        (1) as function arguments;
-- 
2.40.0


Reply via email to