[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200108141700.425599efe7ab0ac7c4329661@kernel.org>
Date: Wed, 8 Jan 2020 14:17:00 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Frank Rowand <frowand.list@...il.com>,
Ingo Molnar <mingo@...hat.com>,
Randy Dunlap <rdunlap@...radead.org>,
Namhyung Kim <namhyung@...nel.org>,
Tim Bird <Tim.Bird@...y.com>, Jiri Olsa <jolsa@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Tom Zanussi <tom.zanussi@...ux.intel.com>,
Rob Herring <robh+dt@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Alexey Dobriyan <adobriyan@...il.com>,
Jonathan Corbet <corbet@....net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
linux-doc@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 01/22] bootconfig: Add Extra Boot Config support
Hi Steve,
On Tue, 7 Jan 2020 20:59:45 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> On Thu, 26 Dec 2019 23:04:00 +0900
> Masami Hiramatsu <mhiramat@...nel.org> wrote:
>
>
> > +/**
> > + * xbc_node_is_value() - Test the node is a value node
> > + * @node: An XBC node.
> > + *
> > + * Test the @node is a value node and return true if a value node, false if not.
> > + */
> > +static inline __init bool xbc_node_is_value(struct xbc_node *node)
> > +{
> > + return !!(node->data & XBC_VALUE);
>
> The "!!" is not needed, as this is a static inline bool function. The
> compiler will make this a 1 or 0 without it.
>
> return node->data & XBC_VALUE;
>
> is sufficient.
OK.
>
> > +}
> > +
> > +/**
> > + * xbc_node_is_key() - Test the node is a key node
> > + * @node: An XBC node.
> > + *
> > + * Test the @node is a key node and return true if a key node, false if not.
> > + */
> > +static inline __init bool xbc_node_is_key(struct xbc_node *node)
> > +{
> > + return !(node->data & XBC_VALUE);
> > +}
> > +
Maybe this is better use xbc_node_is_value()
return !xbc_node_is_value();
Right?
> > +
> > +/*
> > + * Return delimiter or error, no node added. As same as lib/cmdline.c,
> > + * you can use " around spaces, but can't escape " for value.
> > + */
> > +static int __init __xbc_parse_value(char **__v, char **__n)
> > +{
> > + char *p, *v = *__v;
> > + int c, quotes = 0;
> > +
> > + v = skip_spaces(v);
> > + while (*v == '#') {
> > + v = skip_comment(v);
> > + v = skip_spaces(v);
> > + }
> > + if (*v == '"' || *v == '\'') {
> > + quotes = *v;
> > + v++;
> > + }
> > + p = v - 1;
> > + while ((c = *++p)) {
> > + if (!isprint(c) && !isspace(c))
> > + return xbc_parse_error("Non printable value", p);
> > + if (quotes) {
> > + if (c != quotes)
> > + continue;
> > + quotes = 0;
> > + *p++ = '\0';
> > + p = skip_spaces(p);
>
> Hmm, if p here == " \0" then skip_spaces() will make p == "\0"
>
> > + c = *p;
> > + if (c && !strchr(",;\n#}", c))
> > + return xbc_parse_error("No value delimiter", p);
> > + p++;
>
> Now p == one passed "\0" which is in unknown territory.
Ah, right!
>
> > + break;
> > + }
> > + if (strchr(",;\n#}", c)) {
>
> Also, why are we looking at '\n'? as wouldn't that get skipped by
> skip_spaces() too?
I forgot that '\n' is also isspace() true...
Thank you!
>
> -- Steve
>
> > + v = strim(v);
> > + *p++ = '\0';
> > + break;
> > + }
> > + }
> > + if (quotes)
> > + return xbc_parse_error("No closing quotes", p);
> > + if (c == '#') {
> > + p = skip_comment(p);
> > + c = *p;
> > + }
> > + *__n = p;
> > + *__v = v;
> > +
> > + return c;
> > +}
> > +
--
Masami Hiramatsu <mhiramat@...nel.org>
Powered by blists - more mailing lists