Re: [PATCH] Make WARN_ON/WARN_ON_ONCE no-ops when CONFIG_BUG is off

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

 



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 <[email protected]>

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.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux