[PATCH 1/7] printk: clean up return value
From: Alan Jenkins
Date: Wed Oct 07 2009 - 04:41:42 EST
Commit 5fd29d6 "printk: clean up handling of log-levels and newlines"
causes printk() to return the wrong number of characters.
It counts the first loglevel tag twice: once in the original message
string, and a second time when we actually print the loglevel.
We could fix this up, but it seems pointless. Callers don't really care
about the extra characters added by printk(). Instead, let's return the
length of the original message as formatted (and possibly truncated)
by vscnprintf().
Signed-off-by: Alan Jenkins <alan-jenkins@xxxxxxxxxxxxxx>
---
kernel/printk.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/printk.c b/kernel/printk.c
index f38b07f..9d3d594 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -669,7 +669,7 @@ static inline void printk_delay(void)
asmlinkage int vprintk(const char *fmt, va_list args)
{
- int printed_len = 0;
+ int message_len = 0;
int current_log_level = default_message_loglevel;
unsigned long flags;
int this_cpu;
@@ -708,11 +708,11 @@ asmlinkage int vprintk(const char *fmt, va_list args)
if (recursion_bug) {
recursion_bug = 0;
strcpy(printk_buf, recursion_bug_msg);
- printed_len = strlen(recursion_bug_msg);
+ message_len = strlen(recursion_bug_msg);
}
/* Emit the output into the temporary buffer */
- printed_len += vscnprintf(printk_buf + printed_len,
- sizeof(printk_buf) - printed_len, fmt, args);
+ message_len = vscnprintf(printk_buf + message_len,
+ sizeof(printk_buf) - message_len, fmt, args);
p = printk_buf;
@@ -796,7 +796,7 @@ out_restore_irqs:
raw_local_irq_restore(flags);
preempt_enable();
- return printed_len;
+ return message_len;
}
EXPORT_SYMBOL(printk);
EXPORT_SYMBOL(vprintk);
--
1.6.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/