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

xen/x86: resolve the last 3 MISRA R16.6 violations



MISRA R16.6 states that "Every switch statement shall have at least two
switch-clauses". There are only 3 violations left on x86 (zero on ARM).

Two of them can be simply fixed.

One of them is only a violation depending on the kconfig configuration.
So deviate it instead with a SAF comment.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>

diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index b8a4f878ea..e1f950f7b1 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -92,6 +92,14 @@
         },
         {
             "id": "SAF-11-safe",
+            "analyser": {
+                "eclair": "MC3A2.R16.6"
+            },
+            "name": "Rule 16.6: single clause due to kconfig",
+            "text": "A switch statement with a single switch clause because 
other switch clauses are disabled in a given kconfig is allowed."
+        },
+        {
+            "id": "SAF-12-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 39e39ce4ce..c10c6bd833 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3797,22 +3797,14 @@ uint64_t hvm_get_reg(struct vcpu *v, unsigned int reg)
 {
     ASSERT(v == current || !vcpu_runnable(v));
 
-    switch ( reg )
-    {
-    default:
-        return alternative_call(hvm_funcs.get_reg, v, reg);
-    }
+    return alternative_call(hvm_funcs.get_reg, v, reg);
 }
 
 void hvm_set_reg(struct vcpu *v, unsigned int reg, uint64_t val)
 {
     ASSERT(v == current || !vcpu_runnable(v));
 
-    switch ( reg )
-    {
-    default:
-        return alternative_vcall(hvm_funcs.set_reg, v, reg, val);
-    }
+    return alternative_vcall(hvm_funcs.set_reg, v, reg, val);
 }
 
 static bool cf_check is_sysdesc_access(
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 87b30ce4df..dca11a613d 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -436,6 +436,7 @@ unsigned long get_stack_trace_bottom(unsigned long sp)
 
 static unsigned long get_shstk_bottom(unsigned long sp)
 {
+    /* SAF-11-safe */
     switch ( get_stack_page(sp) )
     {
 #ifdef CONFIG_XEN_SHSTK



 


Rackspace

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