From: Herbert Xu <herbert@gondor.apana.org.au>
To: Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] Make WARN_ON/WARN_ON_ONCE no-ops when CONFIG_BUG is off
Date: Fri, 14 Dec 2007 21:27:55 +0800 [thread overview]
Message-ID: <20071214132755.GA18309@gondor.apana.org.au> (raw)
Hi:
[PATCH] Make WARN_ON/WARN_ON_ONCE no-ops when CONFIG_BUG is off
The description of CONFIG_BUG clearly states that both BUG and
WARN_ON may be skipped. However, our actual implementation still
checks the condition on WARN_ON if it's used as part of an if
statement or such.
This patch makes it return 0 after evaluating the expression
if CONFIG_BUG is disabled. This is consistent with the spirit
of the CONFIG_BUG option.
The same change is made to WARN_ON_ONCE.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index d56fedb..3e74278 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -43,6 +43,16 @@ struct bug_entry {
})
#endif
+#define WARN_ON_ONCE(condition) ({ \
+ static int __warned; \
+ int __ret_warn_once = !!(condition); \
+ \
+ if (unlikely(__ret_warn_once)) \
+ if (WARN_ON(!__warned)) \
+ __warned = 1; \
+ unlikely(__ret_warn_once); \
+})
+
#else /* !CONFIG_BUG */
#ifndef HAVE_ARCH_BUG
#define BUG()
@@ -53,22 +63,11 @@ struct bug_entry {
#endif
#ifndef HAVE_ARCH_WARN_ON
-#define WARN_ON(condition) ({ \
- int __ret_warn_on = !!(condition); \
- unlikely(__ret_warn_on); \
-})
-#endif
+#define WARN_ON(condition) ((condition), 0)
#endif
-#define WARN_ON_ONCE(condition) ({ \
- static int __warned; \
- int __ret_warn_once = !!(condition); \
- \
- if (unlikely(__ret_warn_once)) \
- if (WARN_ON(!__warned)) \
- __warned = 1; \
- unlikely(__ret_warn_once); \
-})
+#define WARN_ON_ONCE(condition) ((condition), 0)
+#endif
#ifdef CONFIG_SMP
# define WARN_ON_SMP(x) WARN_ON(x)
next reply other threads:[~2007-12-14 13:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 13:27 Herbert Xu [this message]
2007-12-14 18:02 ` [PATCH] Make WARN_ON/WARN_ON_ONCE no-ops when CONFIG_BUG is off Matt Mackall
2007-12-15 4:16 ` Herbert Xu
2007-12-15 5:52 ` Matt Mackall
2007-12-15 6:04 ` Herbert Xu
2007-12-15 6:12 ` Matt Mackall
2007-12-15 6:31 ` Herbert Xu
2007-12-15 6:52 ` Herbert Xu
2007-12-15 17:54 ` Matt Mackall
2007-12-15 6:45 ` Dave Jones
2007-12-15 6:22 ` Benjamin Herrenschmidt
2007-12-15 6:31 ` Benjamin Herrenschmidt
2007-12-15 6:34 ` Herbert Xu
2007-12-15 18:12 ` Matt Mackall
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=20071214132755.GA18309@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).