|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [RFC PATCH 0/4] Add missing default labels to switch statements
On 2/23/19 1:13 AM, Julien Grall wrote: 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 addressedSo 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. Good suggestion, but taking into account the number of possible changes this will finally become a fork of the existing Xen... And we all probably understand what it means to deviate from upstream... On the other hand what's wrong with the will to make the project benefit from more robust (as MISRA believes) and, yes, certified code? 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, _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |