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

[xen master] automation/eclair_analysis: fix MISRA Rule 20.7 regression in self-tests.h



commit 4b3f30ea3059cd9000af853541354548bbb612db
Author:     Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Sun Sep 8 15:27:57 2024 +0200
Commit:     Stefano Stabellini <stefano.stabellini@xxxxxxx>
CommitDate: Wed Sep 11 17:10:27 2024 -0700

    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>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 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 9051f41602..ed80ac7958 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 b66c271c4e..74bb815bf0 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -534,6 +534,14 @@ Deviations related to MISRA C:2012 Rules:
        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 the "fn"
+       argument, 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
        `ext_paste_comma`, as detailed in `C-language-toolchain.rst`, which is
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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