[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180913122625.6ieyexpcmlc5z2it@pathway.suse.cz>
Date: Thu, 13 Sep 2018 14:26:25 +0200
From: Petr Mladek <pmladek@...e.com>
To: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc: Steven Rostedt <rostedt@...dmis.org>,
Alexander Potapenko <glider@...gle.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Dmitriy Vyukov <dvyukov@...gle.com>,
penguin-kernel@...ove.sakura.ne.jp,
kbuild test robot <fengguang.wu@...el.com>,
syzkaller <syzkaller@...glegroups.com>,
LKML <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] printk: inject caller information into the body of
message
On Thu 2018-09-13 16:12:54, Sergey Senozhatsky wrote:
> On (09/12/18 12:05), Steven Rostedt wrote:
> > > : Introduce a few helper functions for it:
> > > :
> > > : init_line_buffer(&buf);
> > > : print_line(&buf, fmt, args);
> > > : vprint_line(&buf, fmt, vararg);
> > > : finish_line(&buf);
> > > :
> >
> --- a/lib/seq_buf.c
> +++ b/lib/seq_buf.c
> @@ -324,3 +324,49 @@ int seq_buf_to_user(struct seq_buf *s, char __user *ubuf, int cnt)
> s->readpos += cnt;
> return cnt;
> }
> +
> +int vpr_line(struct pr_line *pl, const char *fmt, va_list args)
> +{
> + struct seq_buf *s = &pl->sb;
> + int ret, len;
> +
> + if (fmt[0] == '\n') {
> + pr_line_flush(pl);
> + return 0;
> + }
You would need to check if fmt[1] == '\0'. But then you would need
to be careful about a possible buffer overflow. I would personally
avoid this optimization.
> + ret = seq_buf_vprintf(s, fmt, args);
> +
> + len = seq_buf_used(s);
> + if (len && s->buffer[len - 1] == '\n')
> + pr_line_flush(pl);
This would cause that pr_line_flush() won't be strictly needed.
Also it would encourage people to use this feature a more
complicated way (for more lines). Do we really want this?
In general, I like this approach more than any attemps to handle
continuous lines transpatently. The other attemps were much more
complicated or were not reliable.
Best Regards,
Petr
Powered by blists - more mailing lists