lkml.org 
[lkml]   [2019]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation
On (06/19/19 00:12), John Ogness wrote:
> On 2019-06-18, Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:
> >> + struct prb_reserved_entry e;
> >> + char *s;
> >> +
> >> + s = prb_reserve(&e, &rb, 32);
> >> + if (s) {
> >> + sprintf(s, "Hello, world!");
> >> + prb_commit(&e);
> >> + }
> >
> > A nit: snprintf().
> >
> > sprintf() is tricky, it may write "slightly more than was
> > anticipated" bytes - all those string_nocheck(" disabled"),
> > error_string("pK-error"), etc.
>
> Agreed. Documentation should show good examples.

In vprintk_emit(), are we going to always reserve 1024-byte
records, since we don't know the size in advance, e.g.

printk("%pS %s\n", regs->ip, current->name)
prb_reserve(&e, &rb, ????);

or are we going to run vscnprintf() on a NULL buffer first,
then reserve the exactly required number of bytes and afterwards
vscnprintf(s) -> prb_commit(&e)?

-ss

\
 
 \ /
  Last update: 2019-06-25 08:47    [W:0.069 / U:19.632 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site