All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <Julien.Grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: "Artem_Mygaiev@epam.com" <Artem_Mygaiev@epam.com>,
	"Andrii_Anisov@epam.com" <Andrii_Anisov@epam.com>,
	Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>,
	Oleksandr Andrushchenko <andr2000@gmail.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	nd <nd@arm.com>
Subject: Re: [RFC PATCH 0/4] Add missing default labels to switch statements
Date: Fri, 22 Feb 2019 23:11:38 +0000	[thread overview]
Message-ID: <c9abf6b0-4875-19ec-e83d-cecbcce7ad2a@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1902221416190.30151@sstabellini-ThinkPad-X260>

Hi,

On 22/02/2019 22:34, Stefano Stabellini wrote:
> On Fri, 22 Feb 2019, Julien Grall wrote:
>> Hi Stefano,
>>
>> On 22/02/2019 21:58, Stefano Stabellini wrote:
>>> On Fri, 22 Feb 2019, Andrew Cooper wrote:
>>>> On 22/02/2019 21:00, Stefano Stabellini wrote:
>>>>> On Fri, 22 Feb 2019, Julien Grall wrote:
>>>>>>>>> BTW, I checked the series with -Wswitch-default:
>>>>>>>>> -Wswitch-default
>>>>>>>>> Warn whenever a switch statement does not have a default case.
>>>>>>>>>> Furthermore, using BUG() is a pretty bad idea in switch.
>>>>>>>>> It is and not only in the switch. The reason I put BUG is that I tried
>>>>>>>>> to follow
>>>>>>>>> the existing "error handling" at those places.
>>>>>>>> It is not because BUG() is been used today in some places that we need to
>>>>>>>> continue to spread it.
>>>>>>>>
>>>>>>>>> Use of BUG() itself is another topic which will also need to be
>>>>>>>>> addressed
>>>>>>>> So we should not add more of them...
>>>>>>> Again, I see this as a dedicated change. So, in the current series I think
>>>>>>> it is
>>>>>>> acceptable to use the existing way of error handling if any at all.
>>>>>> That's not how it works in upstream. If you know some constructs are wrong, it
>>>>>> is best to try to address partially the problem directly then having so you
>>>>>> reduce the amounts of change afterwards.
>>>>>>
>>>>>> So please try to not introduce more BUG() in the code base.
>>>>> Hi Oleksandr, Julien,
>>>>>
>>>>> Julien's right that we should not introduce any more BUG()s. In fact,
>>>>> each of them makes the code less safe, not more safe! The purpose of
>>>>> MISRAC 16.4 is "defensive programming": write the code in a way that is
>>>>> more (not less!) resilient to failure.
>>>>>
>>>>> So, I think it is a good idea to introduce a default label because it
>>>>> can help us spot unexpected issues. Instead of calling BUG() in the
>>>>> default handler, which is detrimental, we should return an error when
>>>>> possible, or just print a warning.
>>>>
>>>> domain_crash() is almost always better than BUG().  It is very obvious
>>>> if it gets hit, and wont crash Xen.
>>>
>>> That's a good suggestion.
>>>
>>>
>>>>> As 16.4 clearly state, even a simple comment would be enough to address
>>>>> the rule. We just need to explain why a default label is not needed.
>>>>> Such as:
>>>>>
>>>>>     default:
>>>>>     /* unreachable because blah and blah */
>>>>
>>>> What a simple comment doesn't do is avoid breaking -Wswitch.
>>>
>>> I don't know how to reconcile 16.4 with -Wswitch. One could argue that
>>> -Wswitch could be a good way to address 16.4, but then we introduce a
>>> compiler specific requirement. Typically gcc is not the compiler of
>>> choice for these environments, unfortunately forcing gcc is not an
>>> option.
>>
>> Well, you could build with GCC and then build with your custom
>> compiler...
> 
> This suggestion is problematic: as an individual interested in MISRA-C
> compliance, I only have the MISRA-C rules in my hands. I don't know how
> to deal with suggestions like this one, that don't comply to the Rules,
> but it tries to address the same issue in a different manner.

Are you suggesting we will have to abide to all the rules even if they 
doesn't make things worst? I was under the impression we don't necessary 
need to follow a rule if we have justification for it.

> 
> I cannot rule out that it wouldn't work, but also I cannot be sure that
> it would work. In short, I have no way to make progress or to find out
> how to move forward. I guess as a contributor I would be forced to go
> back to the MISRAC compliance experts and ask for their opinion. (One
> non-technical issue is who is going to pay them for spending their time
> on this.) But what if they say it is not acceptable for compliance?
> 
> This is a great topic to discuss in March and decide what to do in these
> situations.
> 
> 
>> But, GCC is pretty much the only choice for Xen on Arm today
>> as we don't build with clang and I pretty doubt we can build with compcert.
> 
> Obviously, this has to change if we want to make progress on safety
> certifications.

I am curious to know what is plan for this. I mean that if no-one is 
planning to make Xen build with other compilers. Then what would be the 
benefits of this?

Cheers,

-- 
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-02-22 23:11 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22  9:57 [RFC PATCH 0/4] Add missing default labels to switch statements Oleksandr Andrushchenko
2019-02-22  9:57 ` [RFC PATCH 1/4] cert:arch/arm: " Oleksandr Andrushchenko
2019-02-22 18:24   ` Julien Grall
2019-02-22  9:57 ` [RFC PATCH 2/4] cert:xen/common: " Oleksandr Andrushchenko
2019-02-22  9:57 ` [RFC PATCH 3/4] cert:xen/drivers: " Oleksandr Andrushchenko
2019-02-22  9:57 ` [RFC PATCH 4/4] cert:xen/xsm/flask: " Oleksandr Andrushchenko
2019-02-22 10:27 ` [RFC PATCH 0/4] " Andrew Cooper
2019-02-22 11:05   ` Julien Grall
2019-02-22 11:13     ` Oleksandr Andrushchenko
2019-02-22 11:27       ` Julien Grall
2019-02-22 12:01         ` Oleksandr Andrushchenko
2019-02-22 13:27           ` Julien Grall
2019-02-22 21:00             ` Stefano Stabellini
2019-02-22 21:33               ` Andrew Cooper
2019-02-22 21:58                 ` Stefano Stabellini
2019-02-22 22:11                   ` Julien Grall
2019-02-22 22:34                     ` Stefano Stabellini
2019-02-22 23:11                       ` Julien Grall [this message]
2019-02-25 17:38                         ` Stefano Stabellini
2019-02-22 23:13                       ` Julien Grall
2019-02-25 10:27                         ` Oleksandr Andrushchenko
2019-02-25 10:57                           ` Julien Grall
2019-02-22 22:34                     ` Andrew Cooper
2019-02-22 22:38                       ` Stefano Stabellini
2019-02-22 23:34                         ` Julien Grall
2019-02-25 10:00                           ` Oleksandr Andrushchenko
2019-02-25 11:08                             ` Julien Grall
2019-02-25 11:37                               ` Oleksandr Andrushchenko
2019-02-22 23:22                       ` Julien Grall
2019-02-22 23:41                         ` Andrew Cooper
2019-02-25 10:06                           ` Oleksandr Andrushchenko
2019-02-25 11:10                             ` Julien Grall
2019-02-25 11:43                               ` Oleksandr Andrushchenko
2019-02-25  9:50                 ` Oleksandr Andrushchenko
2019-02-25 11:23                   ` Julien Grall
2019-02-25 11:49                     ` Oleksandr Andrushchenko
2019-02-25 12:11                       ` Jan Beulich
2019-02-25 12:32                         ` Oleksandr Andrushchenko
2019-02-25 12:15                       ` Julien Grall
2019-02-25 12:38                         ` Oleksandr Andrushchenko
2019-02-25 12:50                           ` Julien Grall
2019-02-25 13:06                             ` Oleksandr Andrushchenko
2019-02-25 13:22                               ` Julien Grall
2019-02-25 13:32                                 ` Oleksandr Andrushchenko
2019-02-25 13:40                                   ` Julien Grall
2019-02-25 13:47                                     ` Oleksandr Andrushchenko
2019-02-25 15:54                                       ` Lars Kurth
2019-02-25 17:42                                         ` Stefano Stabellini
2019-02-25 11:40                 ` Jan Beulich
2019-02-25 16:58                   ` George Dunlap
2019-02-25 17:47                     ` Stefano Stabellini
2019-02-25 18:20                       ` Julien Grall
2019-02-25 21:13                         ` Stefano Stabellini
2019-02-25 21:34                           ` Julien Grall
2019-02-26  7:43                             ` Oleksandr Andrushchenko
2019-02-26 11:20                             ` Jan Beulich
2019-02-26 11:33                               ` Oleksandr Andrushchenko
2019-02-26 11:47                                 ` Jan Beulich
2019-02-26 12:20                                   ` Oleksandr Andrushchenko
2019-02-26 18:27                                   ` Stefano Stabellini
2019-02-27  9:23                                     ` Lars Kurth
2019-02-27 10:16                                       ` Jan Beulich
2019-02-27 17:34                                         ` Lars Kurth
2019-02-27 23:45                                           ` Stefano Stabellini
2019-02-28 10:30                                           ` Jan Beulich
2019-02-26 21:10                             ` Stefano Stabellini
2019-02-26 21:31                               ` Julien Grall
2019-02-26 11:14                       ` Jan Beulich
2019-02-22 22:08               ` Julien Grall
2019-02-25 10:11                 ` Oleksandr Andrushchenko
2019-02-25 11:47                   ` Julien Grall
2019-02-25 11:59                     ` Oleksandr Andrushchenko
2019-02-25 12:10                     ` Jan Beulich
2019-02-22 11:20   ` Andrii Anisov
2019-02-22 11:21   ` Andrii Anisov
2019-02-22 11:30     ` Julien Grall
2019-02-22 11:32       ` Julien Grall
2019-02-22 11:53       ` Andrii Anisov
2019-02-22 13:30         ` Julien Grall
2019-02-25 11:43   ` Julien Grall
2019-02-25 12:00     ` Oleksandr Andrushchenko

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=c9abf6b0-4875-19ec-e83d-cecbcce7ad2a@arm.com \
    --to=julien.grall@arm.com \
    --cc=Andrii_Anisov@epam.com \
    --cc=Artem_Mygaiev@epam.com \
    --cc=andr2000@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=nd@arm.com \
    --cc=oleksandr_andrushchenko@epam.com \
    --cc=sstabellini@kernel.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.