diff mbox series

[XEN,v2,5/9] xen/domctl: address violations of MISRA C Rule 16.2

Message ID 5ba6dafed08ca148f7ea92e4c8f7fc947f825cd0.1712305581.git.nicola.vetrini@bugseng.com (mailing list archive)
State Superseded
Headers show
Series address violations of MISRA C Rule 16.2 | expand

Commit Message

Nicola Vetrini April 5, 2024, 9:14 a.m. UTC
Refactor the first clauses so that a violation of
MISRA C Rule 16.2 is resolved (a switch label should be immediately
enclosed in the compound statement of the switch).
Note that the switch clause ending with the pseudo
keyword "fallthrough" is an allowed exception to Rule 16.3.

Convert fallthrough comments in other clauses to the pseudo-keyword
while at it.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 xen/common/domctl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Jan Beulich April 8, 2024, 7:53 a.m. UTC | #1
On 05.04.2024 11:14, Nicola Vetrini wrote:
> Refactor the first clauses so that a violation of
> MISRA C Rule 16.2 is resolved (a switch label should be immediately
> enclosed in the compound statement of the switch).
> Note that the switch clause ending with the pseudo
> keyword "fallthrough" is an allowed exception to Rule 16.3.
> 
> Convert fallthrough comments in other clauses to the pseudo-keyword
> while at it.
> 
> No functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
preferably ...

> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -293,6 +293,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>  
>      switch ( op->cmd )
>      {
> +    case XEN_DOMCTL_createdomain:
> +        d = NULL;
> +        break;
>      case XEN_DOMCTL_assign_device:

... again with a blank line added above this last one (even if this switch()
isn't all so big).

Jan
diff mbox series

Patch

diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index f2e0e36a17c3..cad0ff9d2ec0 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -293,6 +293,9 @@  long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 
     switch ( op->cmd )
     {
+    case XEN_DOMCTL_createdomain:
+        d = NULL;
+        break;
     case XEN_DOMCTL_assign_device:
     case XEN_DOMCTL_deassign_device:
         if ( op->domain == DOMID_IO )
@@ -302,16 +305,15 @@  long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
         }
         else if ( op->domain == DOMID_INVALID )
             return -ESRCH;
-        /* fall through */
+        fallthrough;
     case XEN_DOMCTL_test_assign_device:
     case XEN_DOMCTL_vm_event_op:
         if ( op->domain == DOMID_INVALID )
         {
-    case XEN_DOMCTL_createdomain:
             d = NULL;
             break;
         }
-        /* fall through */
+        fallthrough;
     default:
         d = rcu_lock_domain_by_id(op->domain);
         if ( !d )