Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1430466
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/3] printk: Make the printk*once() variants return a value |
| Date | 2016-06-24 10:40 +0200 |
| Message-ID | <rNuOB-5IF-17@gated-at.bofh.it> (permalink) |
| References | <rNuOB-5IF-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Borislav Petkov <bp@suse.de>
Have printk*once() return a bool which denotes whether the string was
printed or not so that calling code can react accordingly.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/printk.h | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index f4da695fd615..464fcdddb359 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -108,11 +108,14 @@ struct va_format {
* Dummy printk for disabled debugging statements to use whilst maintaining
* gcc's format checking.
*/
-#define no_printk(fmt, ...) \
-do { \
- if (0) \
- printk(fmt, ##__VA_ARGS__); \
-} while (0)
+#define no_printk(fmt, ...) \
+({ \
+ do { \
+ if (0) \
+ printk(fmt, ##__VA_ARGS__); \
+ } while (0); \
+ 0; \
+})
#ifdef CONFIG_EARLY_PRINTK
extern asmlinkage __printf(1, 2)
@@ -309,20 +312,24 @@ extern asmlinkage void dump_stack(void) __cold;
#define printk_once(fmt, ...) \
({ \
static bool __print_once __read_mostly; \
+ bool __ret_print_once = !__print_once; \
\
if (!__print_once) { \
__print_once = true; \
printk(fmt, ##__VA_ARGS__); \
} \
+ __ret_print_once; \
})
#define printk_deferred_once(fmt, ...) \
({ \
static bool __print_once __read_mostly; \
+ bool __ret_print_once = !__print_once; \
\
if (!__print_once) { \
__print_once = true; \
printk_deferred(fmt, ##__VA_ARGS__); \
} \
+ __ret_print_once; \
})
#else
#define printk_once(fmt, ...) \
--
2.8.4
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH 2/3] printk: Make the printk*once() variants return a value Borislav Petkov <bp@alien8.de> - 2016-06-24 10:40 +0200
Re: [PATCH 2/3] printk: Make the printk*once() variants return a value Joe Perches <joe@perches.com> - 2016-06-24 15:50 +0200
Re: [PATCH 2/3] printk: Make the printk*once() variants return a value Borislav Petkov <bp@alien8.de> - 2016-06-25 13:10 +0200
[PATCH -v2 2/3] printk: Make the printk*once() variants return a value Borislav Petkov <bp@alien8.de> - 2016-06-27 11:20 +0200
csiph-web