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

Re: [XEN PATCH v2 7/9] xen/xsm: address violation of MISRA C Rule 16.2



On Fri, 5 Apr 2024, Nicola Vetrini wrote:
> 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@xxxxxxxxxxx>

I had to read this a few times, but it is correct

Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>


> ---
> The second switch is not the best in terms of readability, so it may
> be best to deviate this particular instance.
> ---
>  xen/include/xsm/dummy.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
> index 88039fdd227c..84d3a8ed1c94 100644
> --- a/xen/include/xsm/dummy.h
> +++ b/xen/include/xsm/dummy.h
> @@ -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;
> -- 
> 2.34.1
> 



 


Rackspace

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