The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@fs.tum.de>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>, Jens Axboe <axboe@suse.de>,
	Matt Mackall <mpm@selenic.com>,
	linux-kernel@vger.kernel.org
Subject: Re: What policy for BUG_ON()?
Date: Tue, 31 Aug 2004 13:28:34 +0200	[thread overview]
Message-ID: <20040831112834.GC3466@fs.tum.de> (raw)
In-Reply-To: <Pine.LNX.4.58.0408301718040.2295@ppc970.osdl.org>

On Mon, Aug 30, 2004 at 05:25:52PM -0700, Linus Torvalds wrote:
> 
> 
> On Mon, 30 Aug 2004, Adrian Bunk wrote:
> >
> > Let me try to summarize the different options regarding BUG_ON, 
> > concerning whether the argument to BUG_ON might contain side effects, 
> > and whether it should be allowed in some "do this only if you _really_ 
> > know what you are doing" situations to let BUG_ON do nothing.
> > 
> > Options:
> > 1. BUG_ON must not be defined to do nothing
> > 1a. side effects are allowed in the argument of BUG_ON
> > 1b. side effects are not allowed in the argument of BUG_ON
> > 2. BUG_ON is allowed to be defined to do nothing
> > 2a. side effects are allowed in the argument of BUG_ON
> > 2b. side effects are not allowed in the argument of BUG_ON
> > 
> > It would be good if there was a decision which of the four choices 
> > should become documented policy.
> 
> I'd suggest we strongly discourage side-effects in BUG_ON(). 
> 
> That said, it might be safest to just go for 1b - we make side-effects of 
> BUG_ON() be _documented_ as a bug, but just for safety, I'd suggest doing
> 
> 	#define BUG_ON(x) (void)(x)
> 
> anyway, if somebody wants to compile without debugging. That will still 
> make the side-effects happen if somebody has them (and if there are none, 
> the compiler will not generate any code anyway).
>...

You say 1b but describe 2b...

The difference between 1b and 2b is that a patch to
  #define BUG_ON(x) (void)(x)
with an own option under EMBEDDED might be accepted into the kernel
with 2b, but not with 1b.

> 		Linus

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


  reply	other threads:[~2004-08-31 11:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-30 20:15 What policy for BUG_ON()? Adrian Bunk
2004-08-30 20:22 ` Arjan van de Ven
2004-08-31  6:28   ` Jens Axboe
2004-08-31 11:14     ` Paulo Marques
2004-08-31  0:25 ` Linus Torvalds
2004-08-31 11:28   ` Adrian Bunk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-08-31 15:06 Albert Cahalan
2004-08-31 16:52 ` Linus Torvalds
2004-08-31 17:39   ` Albert Cahalan
2004-08-31 21:30     ` Kyle Moffett
2004-08-31 22:16       ` Michael Buesch
2004-08-31 23:32         ` Kyle Moffett

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=20040831112834.GC3466@fs.tum.de \
    --to=bunk@fs.tum.de \
    --cc=akpm@osdl.org \
    --cc=axboe@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox