From: Roland Dreier <rdreier@cisco.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Use bool for boolean flag in printk_once()
Date: Thu, 13 Aug 2009 13:48:26 -0700 [thread overview]
Message-ID: <adak5174ezp.fsf@cisco.com> (raw)
Using the type bool (instead of int) for the __print_once flag in the
printk_once() macro matches the intent of the code better, and allows
the compiler to generate smaller code; eg a typical callsite with gcc
4.3.3 on i386:
add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6 (-6)
function old new delta
static.__print_once 4 1 -3
get_cpu_vendor 146 143 -3
Saving 6 bytes of object size per callsite by slightly improving the
readability of the source seems like a win to me.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
include/linux/kernel.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d6320a3..f828ce9 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -249,10 +249,10 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
* Print a one-time message (analogous to WARN_ONCE() et al):
*/
#define printk_once(x...) ({ \
- static int __print_once = 1; \
+ static bool __print_once = true; \
\
if (__print_once) { \
- __print_once = 0; \
+ __print_once = false; \
printk(x); \
} \
})
next reply other threads:[~2009-08-13 20:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-13 20:48 Roland Dreier [this message]
2009-08-13 21:21 ` [PATCH] Use bool for boolean flag in printk_once() Andrew Morton
2009-08-13 21:33 ` Joe Perches
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=adak5174ezp.fsf@cisco.com \
--to=rdreier@cisco.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.