All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Andrew <nick@nick-andrew.net>
To: Valdis.Kletnieks@vt.edu
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v1 3/3] Sample refactor of socket.c to use	recursive printk
Date: Sat, 6 Dec 2008 18:40:58 +1100	[thread overview]
Message-ID: <20081206074058.GE5957@mail.local.tull.net> (raw)
In-Reply-To: <24518.1228547914@turing-police.cc.vt.edu>

On Sat, Dec 06, 2008 at 02:18:34AM -0500, Valdis.Kletnieks@vt.edu wrote:
> On Sat, 06 Dec 2008 18:00:23 +1100, Nick Andrew said:
> > Sample refactor of socket.c to use recursive printk
> 
> I think we'd all appreciate it a lot if, instead of pointless code churn
> in socket.c, you used it to fix an *actual* problem - like any of the
> many places where we have issues with interleaved output in dmesg because
> a function had to use 2 or 3 printk calls to build up a line.

Fair enough, socket.c was only how I tested if it works, I never intended
it to be committed anywhere.

> In your 0/3 you point at sound/core/misc.c and drivers/cpufreq/cpufreq.c,
> both of those would be better than socket.c

Ok. This is how those two files would change, after Matt Mackall's patch
is applied. In each case we end up with a single printk, no interleaved
output, the code's smaller, still readable.

Nick.
---

 drivers/cpufreq/cpufreq.c |    3 +--
 sound/core/misc.c         |   14 +++++---------
 2 files changed, 6 insertions(+), 11 deletions(-)


diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index bc8bebc..27b323f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -234,8 +234,7 @@ void cpufreq_debug_printk(unsigned int type, const char *prefix,
 		spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
 
 		va_start(args, fmt);
-		printk(KERN_DEBUG "%s: ", prefix);
-		vprintk(fmt, args);
+		printk(KERN_DEBUG "%s: %v", prefix, fmt, args);
 		va_end(args);
 	}
 }
diff --git a/sound/core/misc.c b/sound/core/misc.c
index 38524f6..ba9655f 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -39,16 +39,14 @@ void snd_verbose_printk(const char *file, int line, const char *format, ...)
 {
 	va_list args;
 	
+	va_start(args, format);
 	if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') {
 		char tmp[] = "<0>";
 		tmp[1] = format[1];
-		printk("%sALSA %s:%d: ", tmp, file, line);
-		format += 3;
+		printk("%sALSA %s:%d: %v", tmp, file, line, format + 3, args);
 	} else {
-		printk("ALSA %s:%d: ", file, line);
+		printk("ALSA %s:%d: %v", file, line, format, args);
 	}
-	va_start(args, format);
-	vprintk(format, args);
 	va_end(args);
 }
 
@@ -60,16 +58,14 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
 {
 	va_list args;
 	
+	va_start(args, format);
 	if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') {
 		char tmp[] = "<0>";
 		tmp[1] = format[1];
-		printk("%sALSA %s:%d: ", tmp, file, line);
-		format += 3;
+		printk("%sALSA %s:%d: %v", tmp, file, line, format + 3, args);
 	} else {
 		printk(KERN_DEBUG "ALSA %s:%d: ", file, line);
 	}
-	va_start(args, format);
-	vprintk(format, args);
 	va_end(args);
 
 }

  reply	other threads:[~2008-12-06  7:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-06  6:59 [RFC] Recursive printk Nick Andrew
2008-12-06  6:59 ` [RFC PATCH v1 1/3] Split the vsnprintf function into two parts Nick Andrew
2008-12-06  7:00 ` [RFC PATCH v1 2/3] Add %v support to vsnprintf() Nick Andrew
2008-12-06 17:27   ` Linus Torvalds
2008-12-06  7:00 ` [RFC PATCH v1 3/3] Sample refactor of socket.c to use recursive printk Nick Andrew
2008-12-06  7:03   ` David Miller
2008-12-06  7:18   ` Valdis.Kletnieks
2008-12-06  7:40     ` Nick Andrew [this message]
2008-12-06  7:20 ` [RFC] Recursive printk Andrew Morton
2008-12-06  7:33   ` Willy Tarreau
2008-12-06  7:41     ` Andrew Morton
2008-12-06  8:16       ` Willy Tarreau
2008-12-06  9:43       ` Takashi Iwai
2008-12-06  7:42   ` Joe Perches
2008-12-06  8:40     ` Nick Andrew
2008-12-06  9:11       ` Joe Perches
2008-12-06 23:16         ` Nick Andrew
2008-12-06 23:24           ` Linus Torvalds
2008-12-06 19:35       ` Al Viro
2008-12-06  8:30   ` Nick Andrew
2008-12-08  1:42     ` Tejun Heo

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=20081206074058.GE5957@mail.local.tull.net \
    --to=nick@nick-andrew.net \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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.