]> xenbits.xensource.com Git - xen.git/commitdiff
xen/types: address Rule 10.1 for DECLARE_BITMAP use
authorNicola Vetrini <nicola.vetrini@bugseng.com>
Fri, 27 Oct 2023 13:34:14 +0000 (15:34 +0200)
committerStefano Stabellini <stefano.stabellini@amd.com>
Sat, 18 Nov 2023 02:04:40 +0000 (18:04 -0800)
Given its use in the declaration
'DECLARE_BITMAP(features, IOMMU_FEAT_count)' the argument
'bits' has essential type 'enum iommu_feature', which is not
allowed by the Rule as an operand to the addition operator
in macro 'BITS_TO_LONGS'.

This construct is deviated with a deviation comment.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
docs/misra/safe.json
xen/include/xen/iommu.h
xen/include/xen/types.h

index 39c5c056c7d4c8fd95d3ade6f2796db81001e322..952324f85cf95f8ed81bbbb1417cf6c47d110727 100644 (file)
         },
         {
             "id": "SAF-2-safe",
+            "analyser": {
+                "eclair": "MC3R1.R10.1"
+            },
+            "name": "MC3R1.R10.1: use of an enumeration constant in an arithmetic operation",
+            "text": "This violation can be fixed with a cast to (int) of the enumeration constant, but a deviation was chosen due to code readability (see also the comment in BITS_TO_LONGS)."
+        },
+        {
+            "id": "SAF-3-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
index 0e747b0bbc1c334537666770a6f99ee9de596b37..d5c25770915b8807a115056539ccf2f35a083bc5 100644 (file)
@@ -360,6 +360,7 @@ struct domain_iommu {
 #endif
 
     /* Features supported by the IOMMU */
+    /* SAF-2-safe enum constant in arithmetic operation */
     DECLARE_BITMAP(features, IOMMU_FEAT_count);
 
     /* Does the guest share HAP mapping with the IOMMU? */
index aea259db1ef26f7b7c17c166a230955aa2502c09..64e75674da4fd3d37cd2aea3cd1785c5b4b40b04 100644 (file)
@@ -22,6 +22,11 @@ typedef signed long ssize_t;
 
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
 
+/*
+ * Users of this macro are expected to pass a positive value.
+ *
+ * XXX: should become an unsigned quantity
+ */
 #define BITS_TO_LONGS(bits) \
     (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
 #define DECLARE_BITMAP(name,bits) \