[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <201001051930.23532.arnd@arndb.de>
Date: Tue, 5 Jan 2010 19:30:23 +0100
From: Arnd Bergmann <arnd@...db.de>
To: David Howells <dhowells@...hat.com>
Cc: Sam Ravnborg <sam@...nborg.org>,
Alexander Beregalov <a.beregalov@...il.com>,
linux-kernel@...r.kernel.org, David Miller <davem@...emloft.net>,
David Daney <ddaney@...iumnetworks.com>
Subject: Re: [PATCH] BUG(): CONFIG_BUG=n version of BUG() should be unreachable()
On Tuesday 05 January 2010, David Howells wrote:
> Sam Ravnborg <sam@...nborg.org> wrote:
>
> > +#define BUG() do { \
> > + for (;;) \
> > + /* endless loop*/; \
> > + unreachable(); \
> > +} while(0)
>
> Can you not do:
>
> #define BUG() do { \
> unreachable(); \
> } while(1)
>
> instead? If the compiler is interpreting unreachable() to really mean that
> what comes after will not be reached, then the condition/loop at the end of
> the block should be optimised away.
Forcing the loop here is really wrong because it needlessly
causes extra code to be emitted. We don't really want controlled
error handling here (that is the definition of CONFIG_BUG=n),
so this is only about shutting up the compiler warning.
I guess the best would be something like
#if defined (__GNUC__) && (__GNUC_MAJOR__ == 4) && (__GNUC_MINOR__ >= 5)
#define BUG() __builtin_unreachable()
#else
#define BUG() do { } while (0) /* this may cause a warning */
#endif
I still haven't found out how many warnings we are talking about
here, maybe we can just silence them by adding individual
unreachable() statements after BUG();
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists