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

Re: [RFC PATCH] x86/vlapic: address a violation of MISRA C:2012 Rule 16.2


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 25 Oct 2023 15:44:49 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DjILXGLgkVcQ6YUxi+f72Areck7H5HhId2ONxK1ilTI=; b=UUs99f4Qz7SKsT9ZZ3pjObM7osCzOCIVuuKjvnYKWNURc1wiwR+OTTGw0T8NEW4j8o63YrQqTqgh0N8h8QUuOe6diB5XD/N3fIDp6dMuMz+y9rtqp7HHkSmFMUgShPKuLusfu3yqfjL2E+inZTvsoaqKAVzlz0A/c5/4qXv5+SWaSeDze0xM6o7UE3wkpEe57zAf9pkBJxYjFbZtQHROPWWjAdE4M5NMhsOKqfnIj7kz4lPQMTXrwz/WQPbfeyx7crBobshQz/zW29M44OaYKfqNJztHpdx4VmaS+bU+gP5OeZ/FdTzbzZTpifUUebE+42TYzsMfwNUY975tmjagFw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lKb4IBSM1JgkurihWas2cwNY2hGa7j9F3AdIBDomV1m8KgDcMKT5idjT2d0rTtUyA36s80TGiMrKbRJ34E9QRdg9lCEPKpXRQvfU4+VKEKcnh+w8qT37NDNVoMNT/c4/1PE77BZAVfqmGn5Gjo/eeK6O8A2XYC8F6lPVH8VSAurlBL08k4Bf8TfeBh1dxeHYgf5WWH86+nsW9YY+FA9RFesoNVBScUe942O/8ZEFMOUSK72BEJuHyRl0AbTogAyAS2aJ6R7PzszkHqDZAnIY7FzphEVAGMJP/p6beb3z8b2xHLqYg6fmsKxIZwZQ8L0WmHyar5EcpNadyU3/S0yk9w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: sstabellini@xxxxxxxxxx, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 25 Oct 2023 13:45:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25.10.2023 15:22, Nicola Vetrini wrote:
> The clauses of a switch should be enclosed directly by a switch
> statement to make the code more easily understandable and less
> prone to errors.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
> ---
> This patch is mainly indended to probe how the community, especially the
> maintainers, would receive such modifications to the code, and whether there
> would be consensus on the rule's adoption. Anyone is welcome to
> give feedback on this, especially on the x86 side, where this pattern
> is used more frequently.

The chosen instance (below) is one where it is relatively easy to argue
that putting the default label in an inner scope isn't much of a
difference as far as overall code size / redundancy is concerned. But
there are (perhaps many) other cases where the gains of using what
Misra dislikes are much higher.

This is another one of the various more recently discussed rules where
I think Misra is just going too far, dictating various aspects of style
for - in my personal view - no real gain. Furthermore, if you could
pick some more involved example (arch/x86/x86_emulate/x86_emulate.c may
yield a few "good" examples), I'd like to learn how you propose to
change such code, with two up-front constraints:
- no added redundancy,
- no new goto.
Either of them in replacement code would go against what the description
above states as a goal.

Jan

> --- a/xen/arch/x86/hvm/vlapic.c
> +++ b/xen/arch/x86/hvm/vlapic.c
> @@ -1034,10 +1034,10 @@ int guest_wrmsr_x2apic(struct vcpu *v, uint32_t msr, 
> uint64_t val)
>      case APIC_EOI:
>      case APIC_ESR:
>          if ( val )
> -        {
> -    default:
>              return X86EMUL_EXCEPTION;
> -        }
> +        break;
> +    default:
> +        return X86EMUL_EXCEPTION;
>      }
>  
>      vlapic_reg_write(v, array_index_nospec(offset, PAGE_SIZE), val);




 


Rackspace

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