[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XEN PATCH] automation/eclair_analysis: fix MISRA Rule 20.7 regression in self-tests.h
Prior to bd1664db7b7d ("xen/bitops: Introduce a multiple_bits_set() helper") the definition of {COMPILE,RUNTIME}_CHECK was fully compliant with respect to MISRA C Rule 20.7: "Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses." However, to allow testing function-like macros, parentheses on the "fn" parameter were removed and thus new violations of the rule have been introduced. Given the usefulness of this functionality, it is deemed ok to deviate these two macros for this rule, because their scope of (direct) usage is limited to just the file where they are defined, and the possibility of misuses is unlikely. No functional change. Fixes: bd1664db7b7d ("xen/bitops: Introduce a multiple_bits_set() helper") Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> --- automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++ docs/misra/deviations.rst | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl index 9051f4160282..ed80ac795851 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -581,6 +581,12 @@ of this macro do not lead to developer confusion, and can thus be deviated." -config=MC3R1.R20.7,reports+={safe, "any_area(any_loc(any_exp(macro(^count_args_$))))"} -doc_end +-doc_begin="The argument \"fn\" in macros {COMPILE,RUNTIME}_CHECK is not parenthesized +on purpose, to be able to test function-like macros. Given the specialized and limited +use of this macro, it is deemed ok to deviate them." +-config=MC3R1.R20.7,reports+={deliberate, "any_area(any_loc(any_exp(macro(^(COMPILE_CHECK|RUNTIME_CHECK)$))))"} +-doc_end + -doc_begin="Uses of variadic macros that have one of their arguments defined as a macro and used within the body for both ordinary parameter expansion and as an operand to the # or ## operators have a behavior that is well-understood and diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index b66c271c4e7c..b020144a3254 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -533,6 +533,14 @@ Deviations related to MISRA C:2012 Rules: to incur in the risk of being misused or lead to developer confusion, and refactoring it to add parentheses breaks its functionality. - Tagged as `safe` for ECLAIR. + + * - R20.7 + - The macros `{COMPILE,RUNTIME}_CHECK` defined in + `xen/include/xen/self-tests.h` are allowed not to parenthesize their + arguments, to allow function-like macros to be tested as well as + functions. Given the specialized use of these macros and their limited + usage scope, omitting parentheses is deemed unlikely to cause issues. + - Tagged as `deliberate` for ECLAIR. * - R20.12 - Variadic macros that use token pasting often employ the gcc extension -- 2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |