From: Michael Buesch <mb@bu3sch.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: John Linville <linville@tuxdriver.com>,
Aurelien Jarno <aurelien@aurel32.net>,
linux-wireless@vger.kernel.org,
Gary Zambrano <zambrano@broadcom.com>
Subject: Re: [patch 1/2] Merge the Sonics Silicon Backplane subsystem
Date: Fri, 13 Jul 2007 00:10:58 +0200 [thread overview]
Message-ID: <200707130010.58338.mb@bu3sch.de> (raw)
In-Reply-To: <20070712145347.ab861215.akpm@linux-foundation.org>
On Thursday 12 July 2007 23:53, Andrew Morton wrote:
> On Thu, 12 Jul 2007 23:42:26 +0200
> Michael Buesch <mb@bu3sch.de> wrote:
>
> > > > +#define assert(cond) do { \
> > > > + if (unlikely(!(cond))) { \
> > > > + ssb_dprintk(KERN_ERR PFX "BUG: Assertion failed (%s) " \
> > > > + "at: %s:%d:%s()\n", \
> > > > + #cond, __FILE__, __LINE__, __func__); \
> > > > + } \
> > > > + } while (0)
> > >
> > > Odd. One would normally expect an assert() to terminate execution in some
> > > fashion if it fails. In-kernel that means BUG. But this assert() just
> > > whines and continues.
> >
> > An assertion failure is not a fatal bug, so we continue execution.
> > We do the same in bcm43xx and I really think we mustn't BUG on an
> > assertion failure, as people would already have killed me.
> > Additionally to that, I insert really lots of assert()s into the code.
> > I don't want all these to be WARN_ONs or BUGs, as it would bloat the
> > kernel a lot. In the places where I want runtime checks in nondebug
> > builds, I already use WARN_ON.
>
> Do `man 3 assert'. The reader of your code will expect that an assert()
> will "terminate the program" (or the kernel equivalent) if the assertion
> fails.
>
> So the principle of least surprise tells us "this shouldn't be called
> assert()".
Well, I do know that userspace assert() terminates the program.
But, in the kernel we use BUG() for this.
So let's better rename BUG() to assert() ;)
No just kidding.
IMO the word "assert" is short and to the point what this code
is actually doing. It asserts that a condition is true and
complains otherwise.
Let's make a deal, Andrew.
As I almost always do assert(0), I will remove the assert() macro
and introduce a macro SSB_CAN_NOT_REACH() or something like that
to mark codepaths that can not be reached.
I'll replace the rest of the assert()s that check an actual condition
with WARN_ON.
OK?
next prev parent reply other threads:[~2007-07-12 22:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-12 8:54 [patch 0/2] Merge the SSB subsystem mb
2007-07-12 8:54 ` [patch 2/2] ssb: Add a driver for the Broadcom OHCI core mb
2007-07-12 16:04 ` Randy Dunlap
2007-07-12 16:08 ` Greg KH
2007-07-12 17:49 ` Andrew Morton
2007-07-12 20:57 ` Michael Buesch
[not found] ` <20070712085744.604965000@bu3sch.de>
2007-07-12 18:27 ` [patch 1/2] Merge the Sonics Silicon Backplane subsystem Andrew Morton
2007-07-12 21:42 ` Michael Buesch
2007-07-12 21:53 ` Andrew Morton
2007-07-12 22:10 ` Michael Buesch [this message]
2007-07-12 22:25 ` Andrew Morton
2007-07-13 6:11 ` Aurelien Jarno
2007-07-13 7:09 ` Holger Schurig
2007-07-13 10:22 ` Michael Buesch
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=200707130010.58338.mb@bu3sch.de \
--to=mb@bu3sch.de \
--cc=akpm@linux-foundation.org \
--cc=aurelien@aurel32.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=zambrano@broadcom.com \
/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;
as well as URLs for NNTP newsgroup(s).