From: Alexander Beregalov <a.beregalov@gmail.com>
To: arnd@arndb.de
Cc: linux-kernel@vger.kernel.org, David Miller <davem@davemloft.net>,
sam@ravnborg.org, dhowells@redhat.com,
Alexander Beregalov <a.beregalov@gmail.com>
Subject: [PATCH] BUG(): CONFIG_BUG=n version of BUG() should be unreachable()
Date: Wed, 23 Dec 2009 04:17:12 +0300 [thread overview]
Message-ID: <1261531032-15225-1-git-send-email-a.beregalov@gmail.com> (raw)
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
next reply other threads:[~2009-12-23 1:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-23 1:17 Alexander Beregalov [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1261531032-15225-1-git-send-email-a.beregalov@gmail.com \
--to=a.beregalov@gmail.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®