public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] BUG(): CONFIG_BUG=n version of BUG() should be unreachable()
@ 2009-12-23  1:17 Alexander Beregalov
  2009-12-23  1:26 ` David Daney
  2009-12-26 18:47 ` Sam Ravnborg
  0 siblings, 2 replies; 9+ messages in thread
From: Alexander Beregalov @ 2009-12-23  1:17 UTC (permalink / raw)
  To: arnd; +Cc: linux-kernel, David Miller, sam, dhowells, Alexander Beregalov

Previouss definition of BUG() as 'do {} while(0)' produced compilation
warnings when BUG() was used in default branch of switch() statement
(control reaches end of non-void function).

Example:
unsigned long function()
{
	switch() {
	case 1:
		return 1;
	case 2:
		return 2;
	default:
		BUG();
}

Using unreachable() fixes the problem.

Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 18c435d..1106439 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -89,7 +89,7 @@ extern void warn_slowpath_null(const char *file, const int line);
 
 #else /* !CONFIG_BUG */
 #ifndef HAVE_ARCH_BUG
-#define BUG() do {} while(0)
+#define BUG() unreachable() 
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
-- 
1.6.6.rc4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-01-05 18:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-23  1:17 [PATCH] BUG(): CONFIG_BUG=n version of BUG() should be unreachable() Alexander Beregalov
2009-12-23  1:26 ` David Daney
2009-12-23  1:37   ` David Daney
2009-12-30 19:12     ` Arnd Bergmann
2010-01-04 18:06       ` David Daney
2010-01-05 11:35         ` Arnd Bergmann
2009-12-26 18:47 ` Sam Ravnborg
2010-01-05 17:58   ` David Howells
2010-01-05 18:30     ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox