Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

From: David Miller
Date: Tue Oct 24 2017 - 04:48:51 EST


From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Oct 2017 11:53:20 +0800

> No your patch makes it worse. The original construct makes it
> clear that the conditional is real code and not just some debugging
> aid.
>
> With your patch, real code is now inside BUG_ON.

This discussion has happened before.

But I'll explain the conclusion here for your benefit.

BUG_ON() is a statement and everything inside of it will
always execute.

BUG_ON() is always preferred because it allows arch
specific code to pass the conditional result properly
into inline asm and builtins for optimal code generation.