Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43a73a50 authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman
Browse files

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 084681d1 ('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: default avatarKay Sievers <kay@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e3f5a5f2
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -818,15 +818,18 @@ static size_t print_time(u64 ts, char *buf)
static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
{
{
	size_t len = 0;
	size_t len = 0;
	unsigned int prefix = (msg->facility << 3) | msg->level;


	if (syslog) {
	if (syslog) {
		if (buf) {
		if (buf) {
			len += sprintf(buf, "<%u>", msg->level);
			len += sprintf(buf, "<%u>", prefix);
		} else {
		} else {
			len += 3;
			len += 3;
			if (msg->level > 9)
			if (prefix > 999)
				len++;
				len += 3;
			if (msg->level > 99)
			else if (prefix > 99)
				len += 2;
			else if (prefix > 9)
				len++;
				len++;
		}
		}
	}
	}