Skip to content

Commit a0cba21

Browse files
committed
Revert "printk: create pr_<level> functions"
This reverts commit 874f9c7. Geert Uytterhoeven reports: "This change seems to have an (unintendent?) side-effect. Before, pr_*() calls without a trailing newline characters would be printed with a newline character appended, both on the console and in the output of the dmesg command. After this commit, no new line character is appended, and the output of the next pr_*() call of the same type may be appended, like in: - Truncating RAM at 0x0000000040000000-0x00000000c0000000 to -0x0000000070000000 - Ignoring RAM at 0x0000000200000000-0x0000000240000000 (!CONFIG_HIGHMEM) + Truncating RAM at 0x0000000040000000-0x00000000c0000000 to -0x0000000070000000Ignoring RAM at 0x0000000200000000-0x0000000240000000 (!CONFIG_HIGHMEM)" Joe Perches says: "No, that is not intentional. The newline handling code inside vprintk_emit is a bit involved and for now I suggest a revert until this has all the same behavior as earlier" Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Requested-by: Joe Perches <joe@perches.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 84bd8d3 commit a0cba21

File tree

4 files changed

+26
-76
lines changed

4 files changed

+26
-76
lines changed

include/linux/printk.h

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -266,39 +266,21 @@ extern asmlinkage void dump_stack(void) __cold;
266266
* and other debug macros are compiled out unless either DEBUG is defined
267267
* or CONFIG_DYNAMIC_DEBUG is set.
268268
*/
269-
270-
#ifdef CONFIG_PRINTK
271-
272-
asmlinkage __printf(1, 2) __cold void __pr_emerg(const char *fmt, ...);
273-
asmlinkage __printf(1, 2) __cold void __pr_alert(const char *fmt, ...);
274-
asmlinkage __printf(1, 2) __cold void __pr_crit(const char *fmt, ...);
275-
asmlinkage __printf(1, 2) __cold void __pr_err(const char *fmt, ...);
276-
asmlinkage __printf(1, 2) __cold void __pr_warn(const char *fmt, ...);
277-
asmlinkage __printf(1, 2) __cold void __pr_notice(const char *fmt, ...);
278-
asmlinkage __printf(1, 2) __cold void __pr_info(const char *fmt, ...);
279-
280-
#define pr_emerg(fmt, ...) __pr_emerg(pr_fmt(fmt), ##__VA_ARGS__)
281-
#define pr_alert(fmt, ...) __pr_alert(pr_fmt(fmt), ##__VA_ARGS__)
282-
#define pr_crit(fmt, ...) __pr_crit(pr_fmt(fmt), ##__VA_ARGS__)
283-
#define pr_err(fmt, ...) __pr_err(pr_fmt(fmt), ##__VA_ARGS__)
284-
#define pr_warn(fmt, ...) __pr_warn(pr_fmt(fmt), ##__VA_ARGS__)
285-
#define pr_notice(fmt, ...) __pr_notice(pr_fmt(fmt), ##__VA_ARGS__)
286-
#define pr_info(fmt, ...) __pr_info(pr_fmt(fmt), ##__VA_ARGS__)
287-
288-
#else
289-
290-
#define pr_emerg(fmt, ...) printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
291-
#define pr_alert(fmt, ...) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
292-
#define pr_crit(fmt, ...) printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
293-
#define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
294-
#define pr_warn(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
295-
#define pr_notice(fmt, ...) printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
296-
#define pr_info(fmt, ...) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
297-
298-
#endif
299-
300-
#define pr_warning pr_warn
301-
269+
#define pr_emerg(fmt, ...) \
270+
printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
271+
#define pr_alert(fmt, ...) \
272+
printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
273+
#define pr_crit(fmt, ...) \
274+
printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
275+
#define pr_err(fmt, ...) \
276+
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
277+
#define pr_warning(fmt, ...) \
278+
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
279+
#define pr_warn pr_warning
280+
#define pr_notice(fmt, ...) \
281+
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
282+
#define pr_info(fmt, ...) \
283+
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
302284
/*
303285
* Like KERN_CONT, pr_cont() should only be used when continuing
304286
* a line with no newline ('\n') enclosed. Otherwise it defaults

kernel/printk/internal.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
*/
1717
#include <linux/percpu.h>
1818

19-
typedef __printf(2, 0) int (*printk_func_t)(int level, const char *fmt,
20-
va_list args);
19+
typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
2120

22-
__printf(2, 0)
23-
int vprintk_default(int level, const char *fmt, va_list args);
21+
int __printf(1, 0) vprintk_default(const char *fmt, va_list args);
2422

2523
#ifdef CONFIG_PRINTK_NMI
2624

@@ -33,10 +31,9 @@ extern raw_spinlock_t logbuf_lock;
3331
* via per-CPU variable.
3432
*/
3533
DECLARE_PER_CPU(printk_func_t, printk_func);
36-
__printf(2, 0)
37-
static inline int vprintk_func(int level, const char *fmt, va_list args)
34+
static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
3835
{
39-
return this_cpu_read(printk_func)(level, fmt, args);
36+
return this_cpu_read(printk_func)(fmt, args);
4037
}
4138

4239
extern atomic_t nmi_message_lost;
@@ -47,10 +44,9 @@ static inline int get_nmi_message_lost(void)
4744

4845
#else /* CONFIG_PRINTK_NMI */
4946

50-
__printf(2, 0)
51-
static inline int vprintk_func(int level, const char *fmt, va_list args)
47+
static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
5248
{
53-
return vprintk_default(level, fmt, args);
49+
return vprintk_default(fmt, args);
5450
}
5551

5652
static inline int get_nmi_message_lost(void)

kernel/printk/nmi.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static DEFINE_PER_CPU(struct nmi_seq_buf, nmi_print_seq);
5858
* one writer running. But the buffer might get flushed from another
5959
* CPU, so we need to be careful.
6060
*/
61-
static int vprintk_nmi(int level, const char *fmt, va_list args)
61+
static int vprintk_nmi(const char *fmt, va_list args)
6262
{
6363
struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
6464
int add = 0;
@@ -79,16 +79,7 @@ static int vprintk_nmi(int level, const char *fmt, va_list args)
7979
if (!len)
8080
smp_rmb();
8181

82-
if (level != LOGLEVEL_DEFAULT) {
83-
add = snprintf(s->buffer + len, sizeof(s->buffer) - len,
84-
KERN_SOH "%c", '0' + level);
85-
add += vsnprintf(s->buffer + len + add,
86-
sizeof(s->buffer) - len - add,
87-
fmt, args);
88-
} else {
89-
add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len,
90-
fmt, args);
91-
}
82+
add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
9283

9384
/*
9485
* Do it once again if the buffer has been flushed in the meantime.

kernel/printk/printk.c

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,26 +1930,7 @@ asmlinkage int printk_emit(int facility, int level,
19301930
}
19311931
EXPORT_SYMBOL(printk_emit);
19321932

1933-
#define define_pr_level(func, loglevel) \
1934-
asmlinkage __visible void func(const char *fmt, ...) \
1935-
{ \
1936-
va_list args; \
1937-
\
1938-
va_start(args, fmt); \
1939-
vprintk_default(loglevel, fmt, args); \
1940-
va_end(args); \
1941-
} \
1942-
EXPORT_SYMBOL(func)
1943-
1944-
define_pr_level(__pr_emerg, LOGLEVEL_EMERG);
1945-
define_pr_level(__pr_alert, LOGLEVEL_ALERT);
1946-
define_pr_level(__pr_crit, LOGLEVEL_CRIT);
1947-
define_pr_level(__pr_err, LOGLEVEL_ERR);
1948-
define_pr_level(__pr_warn, LOGLEVEL_WARNING);
1949-
define_pr_level(__pr_notice, LOGLEVEL_NOTICE);
1950-
define_pr_level(__pr_info, LOGLEVEL_INFO);
1951-
1952-
int vprintk_default(int level, const char *fmt, va_list args)
1933+
int vprintk_default(const char *fmt, va_list args)
19531934
{
19541935
int r;
19551936

@@ -1959,7 +1940,7 @@ int vprintk_default(int level, const char *fmt, va_list args)
19591940
return r;
19601941
}
19611942
#endif
1962-
r = vprintk_emit(0, level, NULL, 0, fmt, args);
1943+
r = vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
19631944

19641945
return r;
19651946
}
@@ -1992,7 +1973,7 @@ asmlinkage __visible int printk(const char *fmt, ...)
19921973
int r;
19931974

19941975
va_start(args, fmt);
1995-
r = vprintk_func(LOGLEVEL_DEFAULT, fmt, args);
1976+
r = vprintk_func(fmt, args);
19961977
va_end(args);
19971978

19981979
return r;

0 commit comments

Comments
 (0)