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

[xen master] automation/eclair: address violations of MISRA C Rule 20.7



commit 0dca0f2b9a7e05a4f3b982e260352e405eb405f8
Author:     Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Thu Jun 27 13:45:18 2024 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jun 27 13:45:18 2024 +0200

    automation/eclair: address violations of MISRA C Rule 20.7
    
    MISRA C Rule 20.7 states: "Expressions resulting from the expansion
    of macro parameters shall be enclosed in parentheses".
    
    The helper macro bitmap_switch has parameters that cannot be parenthesized
    in order to comply with the rule, as that would break its functionality.
    Moreover, the risk of misuse due developer confusion is deemed not
    substantial enough to warrant a more involved refactor, thus the macro
    is deviated for this rule.
    
    No functional change.
    
    Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
    Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
 docs/misra/safe.json     | 8 ++++++++
 xen/include/xen/bitmap.h | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index c213e0a0be..3f18ef401c 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -60,6 +60,14 @@
         },
         {
             "id": "SAF-7-safe",
+            "analyser": {
+                "eclair": "MC3R1.R20.7"
+            },
+            "name": "MC3R1.R20.7: deliberately non-parenthesized macro 
argument",
+            "text": "A macro parameter expands to an expression that is 
non-parenthesized, as doing so would break the functionality."
+        },
+        {
+            "id": "SAF-8-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
index b9f980e919..6ee39aa35a 100644
--- a/xen/include/xen/bitmap.h
+++ b/xen/include/xen/bitmap.h
@@ -103,10 +103,13 @@ extern int bitmap_allocate_region(unsigned long *bitmap, 
int pos, int order);
 #define bitmap_switch(nbits, zero, small, large)                         \
        unsigned int n__ = (nbits);                                       \
        if (__builtin_constant_p(nbits) && !n__) {                        \
+               /* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
                zero;                                                     \
        } else if (__builtin_constant_p(nbits) && n__ <= BITS_PER_LONG) { \
+               /* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
                small;                                                    \
        } else {                                                          \
+               /* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
                large;                                                    \
        }
 
--
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®.