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

Re: [XEN PATCH 10/11] xen/sched: add ASSERT_UNREACHABLE() to address MISRA C:2012 Rule 2.1





On 08/08/2023 16:53, Nicola Vetrini wrote:


... "return" alone already tells the compiler that "break" is
unreachable. You don't need unreachable() for that. As said before,
"break" like this simply want purging (and Misra is wrong to demand
"break" everywhere - it should instead demand no [unannotated]
fall-through, which can also be achieved by return, continue, and
goto).

My suggestion was in the context of this series where we add
ASSERT_UNREACHABLE() before break. From my understanding, we don't
have a lot of leeway here because, from what Nicola wrote, rule 16.3
is mandatory.

So I think using unreachable is better if we every decide to use break
after return.

Cheers,

16.3 is not Mandatory, just Required.

Ah I misread what you wrote. In that case...

I was just reluctant to knowingly add one more violation while fixing another before submitting the patch. If indeed 16.3 won't likely be adopted by Xen,
then that break should indeed go away.

However, the main thing that's holding me back from doing a slimmed-down v2 here is that
evidently there's no consensus even on the ASSERT_UNREACHABLE() patches.

... I agree with the following statement from Jan:

"it should instead demand no [unannotated] fall-through, which can also be achieved by return, continue, and goto"

Cheers,

--
Julien Grall



 


Rackspace

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