[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231026163317.4516369a@gandalf.local.home>
Date: Thu, 26 Oct 2023 16:33:17 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Kees Cook <keescook@...omium.org>, "Matthew Wilcox (Oracle)"
<willy@...radead.org>, Christoph Hellwig <hch@....de>, Justin Stitt
<justinstitt@...gle.com>, Kent Overstreet <kent.overstreet@...ux.dev>, Petr
Mladek <pmladek@...e.com>, Rasmus Villemoes <linux@...musvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@...omium.org>, Masami Hiramatsu
<mhiramat@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arnd Bergmann <arnd@...db.de>, Jonathan Corbet <corbet@....net>, Yun Zhou
<yun.zhou@...driver.com>, Jacob Keller <jacob.e.keller@...el.com>, Zhen Lei
<thunder.leizhen@...wei.com>, linux-trace-kernel@...r.kernel.org, Yosry
Ahmed <yosryahmed@...gle.com>, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH v2] seq_buf: Introduce DECLARE_SEQ_BUF and seq_buf_str()
On Thu, 26 Oct 2023 23:20:15 +0300
Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:
> > +#define DECLARE_SEQ_BUF(NAME, SIZE) \
> > + char __ ## NAME ## _buffer[SIZE] = ""; \
> > + struct seq_buf NAME = { .buffer = &__ ## NAME ## _buffer, \
> > + .size = SIZE }
>
> Hmm... Wouldn't be more readable to have it as
>
> #define DECLARE_SEQ_BUF(NAME, SIZE) \
> char __ ## NAME ## _buffer[SIZE] = ""; \
> struct seq_buf NAME = { \
> .buffer = &__ ## NAME ## _buffer, \
> .size = SIZE, \
> }
>
> ?
I agree with the above.
>
> ...
>
> > +static inline char *seq_buf_str(struct seq_buf *s)
> > {
> > if (WARN_ON(s->size == 0))
> > - return;
> > + return "";
>
> I'm wondering why it's a problem to have an empty string?
Not sure what you mean? With s->size = 0, s->buffer may not have been
assigned. That shouldn't be the case, but it does make it more robust.
-- Steve
>
> > if (seq_buf_buffer_left(s))
> > s->buffer[s->len] = 0;
> > else
> > s->buffer[s->size - 1] = 0;
> > +
> > + return s->buffer;
> > }
>
Powered by blists - more mailing lists