lkml.org 
[lkml]   [2007]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] Make WARN_ON/WARN_ON_ONCE no-ops when CONFIG_BUG is off
From
Date

On Fri, 2007-12-14 at 21:27 +0800, Herbert Xu wrote:
> Hi:
>
> [PATCH] Make WARN_ON/WARN_ON_ONCE no-ops when CONFIG_BUG is off
>
> The description of CONFIG_BUG clearly states that both BUG and
> WARN_ON may be skipped. However, our actual implementation still
> checks the condition on WARN_ON if it's used as part of an if
> statement or such.
>
> This patch makes it return 0 after evaluating the expression
> if CONFIG_BUG is disabled. This is consistent with the spirit
> of the CONFIG_BUG option.
>
> The same change is made to WARN_ON_ONCE.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

That's something I've actually never quite liked... the fact that we
evaluate the expression anyway. I'm pretty happy with -not- evaluating
the expression when CONFIG_BUG is on most of the time since whatever is
in there is purely here for the sake of the BUG/WARN test.

I understand why some people may want it the other way around, but I
personally find it a very bad idea in the first place to write a normal
statement part of the program as

BUG_ON(do_something());

It's way clearer to me I believe to write:

rc = do_something();
BUG_ON(rc);

And thus, when I write:

BUG_ON(do_sanity_check());

I'm actually execting the function call to disappear when CONFIG_BUG
is turned off...

Cheers,
Ben.




\
 
 \ /
  Last update: 2007-12-15 07:35    [W:0.235 / U:0.612 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site