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

Re: [XEN PATCH 12/12] xen/pci: address a violation of MISRA C Rule 16.3



On 10/09/24 16:59, Jan Beulich wrote:
On 10.09.2024 16:57, Jan Beulich wrote:
On 10.09.2024 12:09, Federico Serafini wrote:
Address violations of MISRA C:2012 Rule 16.3:
"An unconditional `break' statement shall terminate every
switch-clause".

Since in our interpretation "return" is okay too, why is not sufficient to
simply ...

--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -170,8 +170,10 @@ static int __init cf_check parse_phantom_dev(const char 
*str)
      {
      case 1: case 2: case 4:
          if ( *s )
-    default:
              return -EINVAL;
+        break;

... insert just this one line here?

I guess the problem is with the description: It's un-annotated fall-through
in this case, not so much the lack of a break (or alike).

Jan

+    default:
+        return -EINVAL;
      }
phantom_devs[nr_phantom_devs++] = phantom;



Do you prefer this?

case 1: case 2: case 4:
    if ( *s )
        fallthrough;
    break;
default:
    return -EINVAL;


--
Federico Serafini, M.Sc.

Software Engineer, BUGSENG (http://bugseng.com)



 


Rackspace

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