automation/eclair: merge the two R14.3 invariant-condition deviations
PATCH 1/1 automation/eclair: merge the two R14.3 invariant-condition deviations
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.
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 8 ++------ docs/misra/deviations.rst | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-)
automation/eclair_analysis/ECLAIR/deviations.ecl +2 -6
@@ -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."
docs/misra/deviations.rst +2 -6
@@ -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
Signature · 1 line
2.34.1