Subject: Re: halt/reset on assert?

From: Benjamin Herrenschmidt <[email-masked]>
Date: Fri, 08 Apr 2011 07:48:09 +1000

On Thu, 2011-04-07 at 12:04 -0500, kevin diggs wrote:
> On Thu, Apr 7, 2011 at 2:55 AM, Benjamin Herrenschmidt
> <[email-masked]> wrote:
> > On Wed, 2011-04-06 at 14:01 +0100, Evan Lavelle wrote:
> >> #define MY_ASSERT(expr) if(!(expr)) BUG()
> >
> > Make it
> >
> > #define MY_ASSERT(expr) do { if .... } while(0)
> >
> > To ensure it has proper single statement semantics in C.
> >
> So THAT'S why they do this!!!!!! Now I just have to figure out what
> 'proper single statement semantics' means!

Thing what happens without the do { ... } while(0) if you have code
that looks like:

	if (enable_debug)
		MY_ASSERT(foo);
	else
		something_else;

Ben.