[U-Boot] [PATCH 4/5] treewide: convert assert() to BUG_ON()

Simon Glass sjg at chromium.org
Sat Dec 2 03:29:58 UTC 2017


On 29 November 2017 at 07:17, Masahiro Yamada
<yamada.masahiro at socionext.com> wrote:
> Hi Simon,
>
>
> 2017-11-29 22:08 GMT+09:00 Simon Glass <sjg at chromium.org>:
>> Hi Masahiro,
>>
>> On 28 November 2017 at 05:23, Masahiro Yamada
>> <yamada.masahiro at socionext.com> wrote:
>>> We do not need multiple ways to do the same thing.  Instead of
>>> assert(), use BUG_ON() from Linux.  The logic is opposite, but
>>> Coccinelle is of great help for such a conversion.  We could
>>> simply convert assert(x) to BUG_ON(!x) for all expressions "x",
>>> but I did a bit better job by converting assert(a == b) to
>>> BUG_ON(a != b), etc.
>>
>> My reading of BUG_ON() is that it does not compile to nothing when
>> DEBUG is not set, unlike assert(). So they do not seem to be
>> equivalent.
>>
>
>
> Tom suggested to add an option to make BUG_ON() to nothing by default:
> https://patchwork.ozlabs.org/cover/842165/
>
> With the option, they will be equivalent.

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list