All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Nicola Vetrini <nicola.vetrini@bugseng.com>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org, consulting@bugseng.com,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>
Subject: Re: [XEN PATCH 2/7] x86/mm: address MISRA C:2012 Rule 2.1
Date: Thu, 14 Dec 2023 08:57:52 +0100	[thread overview]
Message-ID: <21dae6f8-6f79-4952-94e0-1b7c13c7c1a6@suse.com> (raw)
In-Reply-To: <8a49facc4fbf4d3fefb91b9b5bef3305@bugseng.com>

On 13.12.2023 15:44, Nicola Vetrini wrote:
> On 2023-12-12 10:53, Jan Beulich wrote:
>> On 12.12.2023 10:12, Nicola Vetrini wrote:
>>> On 2023-12-12 02:42, Stefano Stabellini wrote:
>>>> On Mon, 11 Dec 2023, Nicola Vetrini wrote:
>>>>> The "return 0" after the swich statement in 'xen/arch/x86/mm.c'
>>>>> is unreachable because all switch clauses end with returns.
>>>>> However, some of them can be substituted with "break"s to allow
>>>>> the "return 0" outside the switch to be reachable.
>>>>>
>>>>> No functional changes.
>>>>
>>>> This is correct but makes the code inconsistent. I would either 
>>>> remove
>>>> the return 0; at the end of arch_memory_op, or do the following:
>>>>
>>>> - initialize rc to 0 at the beginning: int rc = 0;
>>>> - all switch clauses break instead of return;
>>>> - at the end: return rc;
>>>
>>> Given the feedback on the Arm side, the first solution is likely to be
>>> preferred.
>>
>> I wouldn't mind either option, with
>> - the former ensured to be okay with all compiler versions we (still)
>>   support,
> 
> I tested a stripped-down version of the switch on godbolt.org (as far 
> back as gcc-4.8.5) and it doesn't complain. It should be tested on a 
> real Xen build, though.

I didn't fear any issue when going back to just 4.8. Quoting ./README:

      - For x86:
        - GCC 4.1.2_20070115 or later

>> - the latter having the initialize rc to 0 part dropped; imo it's 
>> better
>>   if every case block makes sure to set the intended value explicitly.
> 
> This is a lot of churn, I'd rather avoid it.

Rant (sorry): There's already excessive churn for entirely benign issues
that Misra claims need adjusting.

Jan


  reply	other threads:[~2023-12-14  7:58 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 [this message]
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
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=21dae6f8-6f79-4952-94e0-1b7c13c7c1a6@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=consulting@bugseng.com \
    --cc=nicola.vetrini@bugseng.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --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.