[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1477583574-30988-5-git-send-email-pmladek@suse.com>
Date: Thu, 27 Oct 2016 17:52:54 +0200
From: Petr Mladek <pmladek@...e.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Joe Perches <joe@...ches.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Jason Wessel <jason.wessel@...driver.com>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, Chris Mason <clm@...com>,
Josef Bacik <jbacik@...com>, David Sterba <dsterba@...e.com>,
linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.com>
Subject: [PATCH 4/4] printk/sound: Handle more message headers
The commit 4bcc595ccd80decb4245096e ("printk: reinstate KERN_CONT for
printing continuation lines") allows to define more message headers
for a single message. The motivation is that continuous lines might
get mixed. Therefore it make sense to define the right log level
for every piece of a cont line.
This patch tries to copy the entire header. Well, it limits it
to 4 bytes because it does not make sense to combine more message
headers except for KERN_CONT and some real level.
Signed-off-by: Petr Mladek <pmladek@...e.com>
---
sound/core/misc.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/sound/core/misc.c b/sound/core/misc.c
index f2e8226c88fb..52b719cc875d 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -68,9 +68,10 @@ void __snd_printk(unsigned int level, const char *path, int line,
{
va_list args;
#ifdef CONFIG_SND_VERBOSE_PRINTK
- int kern_level;
struct va_format vaf;
- char verbose_fmt[] = KERN_DEFAULT "ALSA %s:%d %pV";
+ char header[5] = KERN_DEFAULT;
+ const char *end_of_header;
+ size_t size_of_header;
#endif
#ifdef CONFIG_SND_DEBUG
@@ -83,15 +84,18 @@ void __snd_printk(unsigned int level, const char *path, int line,
vaf.fmt = format;
vaf.va = &args;
- kern_level = printk_get_level(format);
- if (kern_level) {
- const char *end_of_header = printk_skip_level(format);
- memcpy(verbose_fmt, format, end_of_header - format);
+ end_of_header = printk_skip_headers(format);
+ size_of_header = min((size_t)(end_of_header - format),
+ sizeof(header) - 1);
+ if (size_of_header) {
+ memcpy(header, format, size_of_header);
+ header[size_of_header] = '\0';
vaf.fmt = end_of_header;
- } else if (level)
- memcpy(verbose_fmt, KERN_DEBUG, sizeof(KERN_DEBUG) - 1);
- printk(verbose_fmt, sanity_file_name(path), line, &vaf);
+ } else if (level) {
+ memcpy(header, KERN_DEBUG, sizeof(KERN_DEBUG) - 1);
+ }
+ printk("%sALSA %s:%d %pV", header, sanity_file_name(path), line, &vaf);
#else
vprintk(format, args);
#endif
--
1.8.5.6
Powered by blists - more mailing lists