All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Nicola Vetrini <nicola.vetrini@bugseng.com>
Cc: xen-devel@lists.xenproject.org, consulting@bugseng.com,
	"Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>
Subject: Re: [XEN PATCH 7/7] x86/xstate: move BUILD_BUG_ON to address MISRA C:2012 Rule 2.1
Date: Mon, 11 Dec 2023 17:46:16 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2312111745280.1703076@ubuntu-linux-20-04-desktop> (raw)
In-Reply-To: <a969550faea681c69730c0968264781f7739670d.1702283415.git.nicola.vetrini@bugseng.com>

On Mon, 11 Dec 2023, Nicola Vetrini wrote:
> The string literal inside the expansion of BUILD_BUG_ON is considered
> unreachable code; however, such statement can be moved earlier
> with no functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> ---
> The motivation for this code movement is that keeping it inside the switch
> statement matches MISRA's definition of unreachable code, but does not fall into
> the category of declarations without initialization, which is already a deviated
> aspect. An alternative approach would be to deviate BUILD_BUG_ON as well.

I think that deviating BUILD_BUG_ON would be totally fine. But given
that this patch is obviously correct:

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/arch/x86/xstate.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c
> index cf94761d0542..99f0526c8988 100644
> --- a/xen/arch/x86/xstate.c
> +++ b/xen/arch/x86/xstate.c
> @@ -396,9 +396,10 @@ void xrstor(struct vcpu *v, uint64_t mask)
>       */
>      for ( prev_faults = faults = 0; ; prev_faults = faults )
>      {
> +        BUILD_BUG_ON(sizeof(faults) != 4); /* Clang doesn't support %z in asm. */
> +
>          switch ( __builtin_expect(ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET], 8) )
>          {
> -            BUILD_BUG_ON(sizeof(faults) != 4); /* Clang doesn't support %z in asm. */
>  #define _xrstor(insn) \
>          asm volatile ( "1: .byte " insn "\n" \
>                         "3:\n" \
> -- 
> 2.34.1
> 


  reply	other threads:[~2023-12-12  1:46 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 10:30 [XEN PATCH 0/7] address violations of MISRA C:2012 Rule 2.1 Nicola Vetrini
2023-12-11 10:30 ` [XEN PATCH 1/7] xen/shutdown: address " Nicola Vetrini
2023-12-12  1:39   ` Stefano Stabellini
2023-12-12  9:45   ` Jan Beulich
2023-12-12  9:53     ` Nicola Vetrini
2023-12-12 10:30       ` Jan Beulich
2023-12-11 10:30 ` [XEN PATCH 2/7] x86/mm: " Nicola Vetrini
2023-12-12  1:42   ` Stefano Stabellini
2023-12-12  9:12     ` Nicola Vetrini
2023-12-12  9:53       ` Jan Beulich
2023-12-13 14:44         ` Nicola Vetrini
2023-12-14  7:57           ` Jan Beulich
2023-12-14  8:52             ` Nicola Vetrini
2023-12-11 10:30 ` [XEN PATCH 3/7] xen/arm: " Nicola Vetrini
2023-12-11 12:29   ` Julien Grall
2023-12-11 13:06     ` Michal Orzel
2023-12-11 14:14       ` Julien Grall
2023-12-11 14:52         ` Nicola Vetrini
2023-12-11 10:30 ` [XEN PATCH 4/7] xen/sched: " Nicola Vetrini
2023-12-11 13:30   ` George Dunlap
2023-12-12  1:43   ` Stefano Stabellini
2023-12-11 10:30 ` [XEN PATCH 5/7] xen/arm: traps: add ASSERT_UNREACHABLE() where needed Nicola Vetrini
2023-12-11 12:32   ` Julien Grall
2023-12-11 14:54     ` Nicola Vetrini
2023-12-11 15:59       ` Julien Grall
2023-12-11 16:05         ` Julien Grall
2023-12-11 17:36           ` Nicola Vetrini
2023-12-12  1:36             ` Stefano Stabellini
2023-12-12  9:23               ` Julien Grall
2023-12-12 15:49     ` Julien Grall
2023-12-13 14:02       ` Nicola Vetrini
2023-12-14  9:42         ` Julien Grall
2023-12-14 22:32           ` Stefano Stabellini
2023-12-15 11:03             ` Nicola Vetrini
2023-12-15 14:08               ` Nicola Vetrini
2023-12-15 18:18                 ` Julien Grall
2023-12-15 21:02               ` Stefano Stabellini
2023-12-11 10:30 ` [XEN PATCH 6/7] x86/platform: removed break to address MISRA C:2012 Rule 2.1 Nicola Vetrini
2023-12-12  1:44   ` Stefano Stabellini
2023-12-12 10:13   ` Jan Beulich
2023-12-12 22:38     ` Stefano Stabellini
2023-12-13 10:43     ` Nicola Vetrini
2023-12-11 10:30 ` [XEN PATCH 7/7] x86/xstate: move BUILD_BUG_ON " Nicola Vetrini
2023-12-12  1:46   ` Stefano Stabellini [this message]
2023-12-12 10:04   ` Jan Beulich
2023-12-12 10:07     ` Jan Beulich
2023-12-12 13:38       ` Nicola Vetrini
2023-12-12 14:01         ` Jan Beulich
2023-12-12 14:05           ` Nicola Vetrini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2312111745280.1703076@ubuntu-linux-20-04-desktop \
    --to=sstabellini@kernel.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=consulting@bugseng.com \
    --cc=jbeulich@suse.com \
    --cc=nicola.vetrini@bugseng.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.