aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-07-06 12:50:09 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-06 12:50:09 -0400
commit43a73a50b352cd3df25b3ced72033942a6a0f919 (patch)
treed197a4aede4273b31697b8ff11286ded7966bf48 /kernel
parente3f5a5f27153228569f3396049838e9727dae86e (diff)
kmsg: add the facility number to the syslog prefix
After the recent split of facility and level into separate variables, we miss the facility value (always 0 for kernel-originated messages) in the syslog prefix. On Tue, Jul 3, 2012 at 12:45 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote: > Static checkers complain about the impossible condition here. > > In 084681d14e ('printk: flush continuation lines immediately to > console'), we changed msg->level from being a u16 to being an unsigned > 3 bit bitfield. Cc: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Kay Sievers <kay@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/printk.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 505863aa3a7f..37cde752cb8a 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -818,15 +818,18 @@ static size_t print_time(u64 ts, char *buf)
818static size_t print_prefix(const struct log *msg, bool syslog, char *buf) 818static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
819{ 819{
820 size_t len = 0; 820 size_t len = 0;
821 unsigned int prefix = (msg->facility << 3) | msg->level;
821 822
822 if (syslog) { 823 if (syslog) {
823 if (buf) { 824 if (buf) {
824 len += sprintf(buf, "<%u>", msg->level); 825 len += sprintf(buf, "<%u>", prefix);
825 } else { 826 } else {
826 len += 3; 827 len += 3;
827 if (msg->level > 9) 828 if (prefix > 999)
828 len++; 829 len += 3;
829 if (msg->level > 99) 830 else if (prefix > 99)
831 len += 2;
832 else if (prefix > 9)
830 len++; 833 len++;
831 } 834 }
832 } 835 }