Re: [PATCH] BUG(): CONFIG_BUG=n version of BUG() should be unreachable()

From: Arnd Bergmann
Date: Tue Jan 05 2010 - 06:36:12 EST


On Monday 04 January 2010, David Daney wrote:
> Arnd Bergmann wrote:
> > The alternative "do { } while (1)" is not ideal, because an
> > endless loop still requires more code (typically one instruction)
> > than doing nothing at all.
> >
>
> Well "do { } while (1)" is exactly the expansion of unreachable() for
> GCC < 4.5. Since GCC-4.5 has not been released yet, most people will
> get these extra looping instructions if you change BUG in this way.

Yes, that is why I wrote the final paragraph, saying

> > If there are only than a handful of places that actually cause a warning,
> > using "do { } while (0)" (or __builtin_unreachable where available) and
> > fixing up the code using it might be better.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/