All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Make WARN_ON/WARN_ON_ONCE no-ops when CONFIG_BUG is off
Date: Sat, 15 Dec 2007 17:31:30 +1100	[thread overview]
Message-ID: <1197700290.6696.52.camel@pasglop> (raw)
In-Reply-To: <20071214132755.GA18309@gondor.apana.org.au>


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.



  parent reply	other threads:[~2007-12-15  6:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-14 13:27 [PATCH] Make WARN_ON/WARN_ON_ONCE no-ops when CONFIG_BUG is off Herbert Xu
2007-12-14 18:02 ` Matt Mackall
2007-12-15  4:16   ` Herbert Xu
2007-12-15  5:52     ` Matt Mackall
2007-12-15  6:04       ` Herbert Xu
2007-12-15  6:12         ` Matt Mackall
2007-12-15  6:31           ` Herbert Xu
2007-12-15  6:52         ` Herbert Xu
2007-12-15 17:54           ` Matt Mackall
2007-12-15  6:45       ` Dave Jones
2007-12-15  6:22   ` Benjamin Herrenschmidt
2007-12-15  6:31 ` Benjamin Herrenschmidt [this message]
2007-12-15  6:34   ` Herbert Xu
2007-12-15 18:12     ` Matt Mackall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1197700290.6696.52.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=akpm@linux-foundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.