Re: [PATCH] seq_buf: add seq_buf_printk() helper
From: Sergey Senozhatsky
Date: Tue Apr 11 2023 - 10:28:39 EST
On (23/04/11 10:10), Steven Rostedt wrote:
[..]
> seq_buf came from trace_seq to become more generic. trace_seq is also part
> of the libtraceevent library, and there we have:
>
> trace_seq_do_printf()
>
> https://www.trace-cmd.org/Documentation/libtraceevent/libtraceevent-tseq.html
>
> That is to differentiate the trace_seq_printf() function. And does what
> this function is doing (dumping the buffer).
>
> Perhaps we should use the precedence of that function and have:
>
> seq_buf_do_printk()
OK, I'll rename the helper to seq_buf_do_printk().
> > We should rather use strnchr(). It seems that the trailing '\0' is
> > not guaranteed. For example, seq_buf_putc() just adds the given
> > character at the end.
>
> I think we should add a seq_buf_terminate() that adds the '\0' to the
> buffer. There's one for user space (trace_seq_terminate()).
>
> It's a nop if it already has the '\0'.
>
> I think we should add that first, and then we can use that when entering
> this function.
Sounds good. This also should address Petr's concern.