]> xenbits.xensource.com Git - xen.git/commitdiff
automation/eclair: configure Rule 13.6 and custom service B.UNEVALEFF
authorFederico Serafini <federico.serafini@bugseng.com>
Mon, 24 Jun 2024 09:18:32 +0000 (11:18 +0200)
committerStefano Stabellini <stefano.stabellini@amd.com>
Tue, 25 Jun 2024 20:41:05 +0000 (13:41 -0700)
Rule 13.6 states that "The operand of the `sizeof' operator shall not
contain any expression which has potential side effects".

Define service B.UNEVALEFF as an extension of Rule 13.6 to
check for unevalued side effects also for typeof and alignof operators.

Update ECLAIR configuration to deviate uses of BUILD_BUG_ON and
alternative_v?call[0-9] for both Rule 13.6 and B.UNEVALEFF.

Add service B.UNEVALEFF to the accepted.ecl guidelines to check
"violations" in the weekly analysis.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-By: Oleksii Kurochko <oleksii.kurochko@gmail.com>
automation/eclair_analysis/ECLAIR/B.UNEVALEFF.ecl [new file with mode: 0644]
automation/eclair_analysis/ECLAIR/accepted_guidelines.sh
automation/eclair_analysis/ECLAIR/analysis.ecl
automation/eclair_analysis/ECLAIR/deviations.ecl
docs/misra/deviations.rst

diff --git a/automation/eclair_analysis/ECLAIR/B.UNEVALEFF.ecl b/automation/eclair_analysis/ECLAIR/B.UNEVALEFF.ecl
new file mode 100644 (file)
index 0000000..92d8db8
--- /dev/null
@@ -0,0 +1,10 @@
+-clone_service=MC3R1.R13.6,B.UNEVALEFF
+
+-config=B.UNEVALEFF,summary="The operand of the `alignof' and `typeof'  operators shall not contain any expression which has potential side effects"
+-config=B.UNEVALEFF,stmt_child_matcher=
+{"stmt(node(utrait_expr)&&operator(alignof))", expr, 0, "stmt(any())", {}},
+{"stmt(node(utrait_type)&&operator(alignof))", type, 0, "stmt(any())", {}},
+{"stmt(node(utrait_expr)&&operator(preferred_alignof))", expr, 0, "stmt(any())", {}},
+{"stmt(node(utrait_type)&&operator(preferred_alignof))", type, 0, "stmt(any())", {}},
+{"type(node(typeof_expr))", expr, 0, "stmt(any())", {}},
+{"type(node(typeof_type))", type, 0, "stmt(any())", {}}
index b308bd4cda339c9adc286ecea09d78bed9491386..368135122c2d1c2a54b581cbda8bf663f9a0670e 100755 (executable)
@@ -11,3 +11,5 @@ accepted_rst=$1
 
 grep -Eo "\`(Dir|Rule) [0-9]+\.[0-9]+" ${accepted_rst} \
      | sed -e 's/`Rule /MC3R1.R/' -e  's/`Dir /MC3R1.D/' -e 's/.*/-enable=&/' > ${script_dir}/accepted.ecl
+
+echo "-enable=B.UNEVALEFF" >> ${script_dir}/accepted.ecl
index 9134e596172c6db739ce4375f7910750c3e434ae..df0b5518122028e445ce93122f8f30d3d9e10c7a 100644 (file)
@@ -52,6 +52,7 @@ their Standard Library equivalents."
 -eval_file=adopted.ecl
 -eval_file=out_of_scope.ecl
 
+-eval_file=B.UNEVALEFF.ecl
 -eval_file=deviations.ecl
 -eval_file=call_properties.ecl
 -eval_file=tagging.ecl
index ae2eaf50f753bcb3b36f0d6467b01ffc90925bf1..8f13dabeb10259ce78f48bc5b32d0d19f3c71923 100644 (file)
@@ -344,6 +344,16 @@ of the short-circuit evaluation strategy of such logical operators."
 -config=MC3R1.R13.5,reports+={disapplied,"any()"}
 -doc_end
 
+-doc_begin="Macros alternative_v?call[0-9] use sizeof and typeof to check that the argument types match the corresponding parameter ones."
+-config=MC3R1.R13.6,reports+={deliberate,"any_area(any_loc(any_exp(macro(^alternative_vcall[0-9]$))&&file(^xen/arch/x86/include/asm/alternative\\.h*$)))"}
+-config=B.UNEVALEFF,reports+={deliberate,"any_area(any_loc(any_exp(macro(^alternative_v?call[0-9]$))&&file(^xen/arch/x86/include/asm/alterantive\\.h*$)))"}
+-doc_end
+
+-doc_begin="Anything, no matter how complicated, inside the BUILD_BUG_ON macro is subject to a compile-time evaluation without relevant side effects."
+-config=MC3R1.R13.6,reports+={safe,"any_area(any_loc(any_exp(macro(name(BUILD_BUG_ON)))))"}
+-config=B.UNEVALEFF,reports+={safe,"any_area(any_loc(any_exp(macro(name(BUILD_BUG_ON)))))"}
+-doc_end
+
 #
 # Series 14
 #
index 16fc345756fde10aa8adf579d5e407998cc71dca..c6a2affc6a0b6580a7068a7061267457417af057 100644 (file)
@@ -300,6 +300,16 @@ Deviations related to MISRA C:2012 Rules:
        the short-circuit evaluation strategy for logical operators.
      - Project-wide deviation; tagged as `disapplied` for ECLAIR.
 
+   * - R13.6
+     - On x86, macros alternative_v?call[0-9] use sizeof and typeof to check
+       that the argument types match the corresponding parameter ones.
+     - Tagged as `deliberate` for ECLAIR.
+
+   * - R13.6
+     - Anything, no matter how complicated, inside the BUILD_BUG_ON macro is
+       subject to a compile-time evaluation without relevant side effects."
+     - Tagged as `safe` for ECLAIR.
+
    * - R14.2
      - The severe restrictions imposed by this rule on the use of 'for'
        statements are not counterbalanced by the presumed facilitation of the