From: Federico Serafini <[email protected]>

MISRA C Rule 14.3 states that "Controlling expressions shall not be
invariant".

Add a SAF comment to deviate the rule for build configurations without
CONFIG_LLC_COLORING enabled.

Signed-off-by: Federico Serafini <[email protected]>
Signed-off-by: Victor Lira <[email protected]>
---
Cc: Andrew Cooper <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Michal Orzel <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Roger Pau MonnĂ© <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Nicola Vetrini <[email protected]>
Cc: Federico Serafini <[email protected]>
Cc: Bertrand Marquis <[email protected]>
---

 docs/misra/safe.json    | 8 ++++++++
 xen/common/page_alloc.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index e3489dba8e..9438815d19 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -116,6 +116,14 @@
         },
         {
             "id": "SAF-14-safe",
+            "analyser": {
+                  "eclair": "MC3A2.R14.3"
+            },
+            "name": "Rule 14.3: loop controlling expression is invariant due 
to the build configuration",
+            "text": "The controlling expression of a loop can be invariant in 
a specific build configuration."
+        },
+        {
+            "id": "SAF-15-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index bd4538c28d..6d6ca7ca50 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -2038,6 +2038,7 @@ static struct page_info *alloc_color_heap_page(unsigned 
int memflags,

     spin_lock(&heap_lock);

+    /* SAF-14-safe MISRA C R14.3 condition always false without LLC_COLORING */
     for ( i = 0; i < domain_num_llc_colors(d); i++ )
     {
         unsigned long free = free_colored_pages[domain_llc_color(d, i)];
--
2.47.0

Reply via email to