On (09/13/18 14:26), Petr Mladek wrote: > > + > > +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.
Good call. It was a fast path for pr_cont("\n"). But it made me wondering and I did some grepping arch/m68k/kernel/traps.c: pr_cont("\n "); arch/m68k/kernel/traps.c: pr_cont("\n "); kernel/trace/ftrace.c: pr_cont("\n expected tramp: %lx\n", ip); Lovely. It will take us some time. > > + 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? Not that I see any problems with pr_line_flush(). But can drop it, sure. pr_line() is a replacement for pr_cont() and as such it's not for multi-line buffering. -ss