halt/reset on assert?

Benjamin Herrenschmidt benh at kernel.crashing.org
Fri Apr 8 07:48:09 EST 2011


On Thu, 2011-04-07 at 12:04 -0500, kevin diggs wrote:
> On Thu, Apr 7, 2011 at 2:55 AM, Benjamin Herrenschmidt
> <benh at kernel.crashing.org> 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.




More information about the Linuxppc-dev mailing list