Re: [PATCH] bootconfig: do not put quotes on cmdline items unless necessary
From: Google
Date: Fri Mar 08 2024 - 00:41:58 EST
On Thu, 7 Mar 2024 09:18:17 +0100
Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> wrote:
> On 07/03/2024 09.10, Rasmus Villemoes wrote:
>
> >>> +static int has_space(const char *v)
> >>> +{
> >>> + for (; *v; v++)
> >>> + if (isspace(*v))
> >>> + return 1;
> >>> + return 0;
> >>> +}
> >>
> >> Do we already have something which does this?
> >
> > Well, 'value[strcspn(value, " \t\r\n")] ? "\"" : ""' would be a
> > oneliner, but not particularly readable. Also that list of characters
> > doesn't necessarily match isspace(), see below.
>
> I didn't look close enough. We do have strpbrk(), so strpbrk(value, "
> \t\r\n") ? .. : .. , but that still leaves the question of just what set
> of characters to search for. But there's no harm in just making it "
> \t\n\v\f\r\xa0" except it requires a comment saying "these are precisely
> the isspace() characters in the kernel's ctype".
I think strpbrk(" \t\r\n") is good enough. Some may not work in cmdline
but as you said, since next_arg()@lib/cmdline.c uses isspace() to separate
the argument, it is better to use the same rule.
Thank you,
>
> Rasmus
>
--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>