From: Federico Serafini <federico.seraf...@bugseng.com>

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 <federico.seraf...@bugseng.com>
Signed-off-by: Victor Lira <victorm.l...@amd.com>
---
Cc: Andrew Cooper <andrew.coop...@citrix.com>
Cc: Anthony PERARD <anthony.per...@vates.tech>
Cc: Michal Orzel <michal.or...@amd.com>
Cc: Jan Beulich <jbeul...@suse.com>
Cc: Julien Grall <jul...@xen.org>
Cc: Roger Pau Monné <roger....@citrix.com>
Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Nicola Vetrini <nicola.vetr...@bugseng.com>
Cc: Federico Serafini <federico.seraf...@bugseng.com>
Cc: Bertrand Marquis <bertrand.marq...@arm.com>
---

 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