mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cesar Eduardo Barros <cesarb@cesarb.net>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Roland Dreier <rolandd@cisco.com>,
	Cesar Eduardo Barros <cesarb@cesarb.net>,
	Daniel Walker <dwalker@fifo99.com>
Subject: [PATCH] WARN_ONCE(): use bool for condition
Date: Sun, 27 Sep 2009 15:25:12 -0300	[thread overview]
Message-ID: <1254075912-17557-1-git-send-email-cesarb@cesarb.net> (raw)
In-Reply-To: <4ABFAB27.1040608@cesarb.net>

Use the type bool for __ret_warn_once and __ret_warn_on, instead of int
with a double negation. This matches the intent of the code better and
should allow the compiler to generate better code, like in commit
70867453092297be9afb2249e712a1f960ec0a09. However, some versions of gcc
seems to pessimize the code instead when the condition is not trivial.

Cc: Daniel Walker <dwalker@fifo99.com>
Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
---
 arch/avr32/include/asm/bug.h    |    2 +-
 arch/blackfin/include/asm/bug.h |    2 +-
 arch/parisc/include/asm/bug.h   |    2 +-
 arch/powerpc/include/asm/bug.h  |    2 +-
 arch/s390/include/asm/bug.h     |    2 +-
 arch/sh/include/asm/bug.h       |    4 ++--
 include/asm-generic/bug.h       |   12 ++++++------
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/avr32/include/asm/bug.h b/arch/avr32/include/asm/bug.h
index 331d45b..c636fec 100644
--- a/arch/avr32/include/asm/bug.h
+++ b/arch/avr32/include/asm/bug.h
@@ -57,7 +57,7 @@
 
 #define WARN_ON(condition)							\
 	({								\
-		int __ret_warn_on = !!(condition);			\
+		bool __ret_warn_on = (condition);			\
 		if (unlikely(__ret_warn_on))				\
 			_BUG_OR_WARN(BUGFLAG_WARNING);			\
 		unlikely(__ret_warn_on);				\
diff --git a/arch/blackfin/include/asm/bug.h b/arch/blackfin/include/asm/bug.h
index 655e495..3584d52 100644
--- a/arch/blackfin/include/asm/bug.h
+++ b/arch/blackfin/include/asm/bug.h
@@ -46,7 +46,7 @@
 
 #define WARN_ON(condition)							\
 	({								\
-		int __ret_warn_on = !!(condition);			\
+		bool __ret_warn_on = (condition);			\
 		if (unlikely(__ret_warn_on))				\
 			_BUG_OR_WARN(BUGFLAG_WARNING);			\
 		unlikely(__ret_warn_on);				\
diff --git a/arch/parisc/include/asm/bug.h b/arch/parisc/include/asm/bug.h
index 8cfc553..373e16a 100644
--- a/arch/parisc/include/asm/bug.h
+++ b/arch/parisc/include/asm/bug.h
@@ -74,7 +74,7 @@
 
 
 #define WARN_ON(x) ({						\
-	int __ret_warn_on = !!(x);				\
+	bool __ret_warn_on = (x);				\
 	if (__builtin_constant_p(__ret_warn_on)) {		\
 		if (__ret_warn_on)				\
 			__WARN();				\
diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 64e1fdc..eda46ac 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -95,7 +95,7 @@
 } while (0)
 
 #define WARN_ON(x) ({						\
-	int __ret_warn_on = !!(x);				\
+	bool __ret_warn_on = (x);				\
 	if (__builtin_constant_p(__ret_warn_on)) {		\
 		if (__ret_warn_on)				\
 			__WARN();				\
diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h
index 7efd0ab..577b6d1 100644
--- a/arch/s390/include/asm/bug.h
+++ b/arch/s390/include/asm/bug.h
@@ -53,7 +53,7 @@
 } while (0)
 
 #define WARN_ON(x) ({					\
-	int __ret_warn_on = !!(x);			\
+	bool __ret_warn_on = (x);			\
 	if (__builtin_constant_p(__ret_warn_on)) {	\
 		if (__ret_warn_on)			\
 			__EMIT_BUG(BUGFLAG_WARNING);	\
diff --git a/arch/sh/include/asm/bug.h b/arch/sh/include/asm/bug.h
index d02c01b..7a7872c 100644
--- a/arch/sh/include/asm/bug.h
+++ b/arch/sh/include/asm/bug.h
@@ -62,7 +62,7 @@ do {							\
 } while (0)
 
 #define WARN_ON(x) ({						\
-	int __ret_warn_on = !!(x);				\
+	bool __ret_warn_on = (x);				\
 	if (__builtin_constant_p(__ret_warn_on)) {		\
 		if (__ret_warn_on)				\
 			__WARN();				\
@@ -87,7 +87,7 @@ do {							\
 } while (0)
 
 #define UNWINDER_BUG_ON(x) ({					\
-	int __ret_unwinder_on = !!(x);				\
+	bool __ret_unwinder_on = (x);				\
 	if (__builtin_constant_p(__ret_unwinder_on)) {		\
 		if (__ret_unwinder_on)				\
 			UNWINDER_BUG();				\
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 18c435d..9eb001e 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -71,7 +71,7 @@ extern void warn_slowpath_null(const char *file, const int line);
 
 #ifndef WARN_ON
 #define WARN_ON(condition) ({						\
-	int __ret_warn_on = !!(condition);				\
+	bool __ret_warn_on = (condition);				\
 	if (unlikely(__ret_warn_on))					\
 		__WARN();						\
 	unlikely(__ret_warn_on);					\
@@ -80,7 +80,7 @@ extern void warn_slowpath_null(const char *file, const int line);
 
 #ifndef WARN
 #define WARN(condition, format...) ({						\
-	int __ret_warn_on = !!(condition);				\
+	bool __ret_warn_on = (condition);				\
 	if (unlikely(__ret_warn_on))					\
 		__WARN_printf(format);					\
 	unlikely(__ret_warn_on);					\
@@ -98,14 +98,14 @@ extern void warn_slowpath_null(const char *file, const int line);
 
 #ifndef HAVE_ARCH_WARN_ON
 #define WARN_ON(condition) ({						\
-	int __ret_warn_on = !!(condition);				\
+	bool __ret_warn_on = (condition);				\
 	unlikely(__ret_warn_on);					\
 })
 #endif
 
 #ifndef WARN
 #define WARN(condition, format...) ({					\
-	int __ret_warn_on = !!(condition);				\
+	bool __ret_warn_on = (condition);				\
 	unlikely(__ret_warn_on);					\
 })
 #endif
@@ -114,7 +114,7 @@ extern void warn_slowpath_null(const char *file, const int line);
 
 #define WARN_ON_ONCE(condition)	({				\
 	static bool __warned;					\
-	int __ret_warn_once = !!(condition);			\
+	bool __ret_warn_once = (condition);			\
 								\
 	if (unlikely(__ret_warn_once))				\
 		if (WARN_ON(!__warned)) 			\
@@ -124,7 +124,7 @@ extern void warn_slowpath_null(const char *file, const int line);
 
 #define WARN_ONCE(condition, format...)	({			\
 	static bool __warned;					\
-	int __ret_warn_once = !!(condition);			\
+	bool __ret_warn_once = (condition);			\
 								\
 	if (unlikely(__ret_warn_once))				\
 		if (WARN(!__warned, format)) 			\
-- 
1.6.4.4


  reply	other threads:[~2009-09-27 18:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-27 13:53 [PATCH] WARN_ONCE(): use bool for boolean flag Cesar Eduardo Barros
2009-09-27 14:03 ` Daniel Walker
2009-09-27 15:56   ` Cesar Eduardo Barros
2009-09-27 16:52     ` Daniel Walker
2009-09-27 17:24       ` Cesar Eduardo Barros
2009-09-27 17:32         ` Daniel Walker
2009-09-27 17:48           ` Cesar Eduardo Barros
2009-09-27 18:12             ` Cesar Eduardo Barros
2009-09-27 18:25               ` Cesar Eduardo Barros [this message]
2009-09-27 18:28                 ` [PATCH] WARN_ONCE(): use bool for condition Daniel Walker
2009-09-27 18:55                   ` Cesar Eduardo Barros
2009-09-27 19:03                     ` Daniel Walker
2009-09-29 20:59                 ` Andrew Morton
2009-09-29 23:11                   ` Cesar Eduardo Barros
2009-09-29 23:12                     ` [PATCH] WARN_ONCE(): use bool for boolean flag Cesar Eduardo Barros
2009-09-30  0:17                       ` Andrew Morton
2009-09-30  0:37                         ` Cesar Eduardo Barros
2009-09-29 23:18                     ` [PATCH] WARN_ONCE(): use bool for condition Cesar Eduardo Barros

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=1254075912-17557-1-git-send-email-cesarb@cesarb.net \
    --to=cesarb@cesarb.net \
    --cc=akpm@linux-foundation.org \
    --cc=dwalker@fifo99.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rolandd@cisco.com \
    /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®