From: Steven Rostedt <rostedt@goodmis.org>
To: Sergey Senozhatsky <senozhatsky@chromium.org>,
Petr Mladek <pmladek@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Yosry Ahmed <yosryahmed@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2] seq_buf: add seq_buf_do_printk() helper
Date: Sat, 15 Apr 2023 03:43:40 -0400 [thread overview]
Message-ID: <352F1D7E-35E2-4FDF-A88F-01E106537279@goodmis.org> (raw)
In-Reply-To: <20230415070406.GJ25053@google.com>
On April 15, 2023 3:04:06 AM EDT, Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
>On (23/04/14 11:00), Petr Mladek wrote:
>> > +void seq_buf_do_printk(struct seq_buf *s, const char *lvl)
>> > +{
>> > + const char *start, *lf;
>> > + int len;
>> > +
>> > + if (s->size == 0 || s->len == 0)
>> > + return;
>> > +
>> > + seq_buf_terminate(s);
>> > +
>> > + start = s->buffer;
>> > + while ((lf = strchr(start, '\n'))) {
>> > + len = lf - start + 1;
>> > + printk("%s%.*s", lvl, len, start);
>> > + start = ++lf;
>> > + }
>> > +
>> > + /* No trailing LF */
>> > + if (start < s->buffer + s->len) {
>> > + len = s->buffer + s->len - start;
>> > + printk("%s%.*s\n", lvl, len, start);
>>
>> We know that the string is '\0' terminated, so the last print
>> might be easier:
>>
>> if (start < s->buffer + s->len)
>> printk("%s%s\n", lvl, start);
>
>Indeed. Steven, let me know if you'd prefer a v3.
Sure. Why not.
-- Steve
>
>> Anyway, it looks good. With or without this change:
>>
>> Reviewed-by: Petr Mladek <pmladek@suse.com>
>
>Thanks Petr!
--
Sent from my Android device with K-9 Mail. Please excuse my brevity and top posting.
prev parent reply other threads:[~2023-04-15 8:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 14:38 Sergey Senozhatsky
2023-04-12 2:46 ` Steven Rostedt
2023-04-12 3:07 ` Sergey Senozhatsky
2023-04-12 3:14 ` Yosry Ahmed
2023-04-14 9:00 ` Petr Mladek
2023-04-15 7:04 ` Sergey Senozhatsky
2023-04-15 7:43 ` Steven Rostedt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=352F1D7E-35E2-4FDF-A88F-01E106537279@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=senozhatsky@chromium.org \
--cc=yosryahmed@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®