]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/xsm: address violation of MISRA C Rule 16.2
authorNicola Vetrini <nicola.vetrini@bugseng.com>
Fri, 5 Apr 2024 09:14:35 +0000 (11:14 +0200)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 11 Apr 2024 12:23:08 +0000 (13:23 +0100)
Refactor the switch so that a violation of
MISRA C Rule 16.2 is resolved (A switch label shall only be used
when the most closely-enclosing compound statement is the body of
a switch statement).
Note that the switch clause ending with the pseudo
keyword "fallthrough" is an allowed exception to Rule 16.3.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/include/xsm/dummy.h

index 88039fdd227cf54becdab8b075aa3bb77d76f389..00d2cbebf25aa021ce2f2cd11b7757afa81b390f 100644 (file)
@@ -83,17 +83,17 @@ static always_inline int xsm_default_action(
         return 0;
     case XSM_TARGET:
         if ( evaluate_nospec(src == target) )
-        {
             return 0;
+        fallthrough;
     case XSM_XS_PRIV:
-            if ( evaluate_nospec(is_xenstore_domain(src)) )
-                return 0;
-        }
-        /* fall through */
+        if ( action == XSM_XS_PRIV &&
+             evaluate_nospec(is_xenstore_domain(src)) )
+            return 0;
+        fallthrough;
     case XSM_DM_PRIV:
         if ( target && evaluate_nospec(src->target == target) )
             return 0;
-        /* fall through */
+        fallthrough;
     case XSM_PRIV:
         if ( is_control_domain(src) )
             return 0;