Re: [PATCH] asm-generic: bug: add unlikely() to BUG_ON()

From: Arnd Bergmann
Date: Fri Sep 07 2018 - 16:41:46 EST


On Fri, Sep 7, 2018 at 9:21 PM Igor Stoppa <igor.stoppa@xxxxxxxxx> wrote:
>
> Add a hint to the compiler.
> If BUG_ON() is used instead of BUG(), it means that probably the
> preferred outcome is to not BUG().
>
> The optimization is disabled, in case CONFIG_PROFILE_ANNOTATED_BRANCHES
> is turned on.

This sounds like a good idea, as this is one of the more likely causes
of false-positive -Wmaybe-uninitialized warnings with
CONFIG_PROFILE_ANNOTATED_BRANCHES

Could you add a comment about -Wmaybe-uninitialized next to the definition?
Otherwise that is easily lost.

Also, I see that the file has two separate definitions of BUG_ON(), and the
other one does have an unlikely() in it already. Can you change both
to do the same thing with unlikely() or not unlikely()?

Arnd