[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20240308144146.7875c1a3092846111c6ca690@kernel.org>
Date: Fri, 8 Mar 2024 14:41:46 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Masami Hiramatsu
<mhiramat@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bootconfig: do not put quotes on cmdline items unless
necessary
On Thu, 7 Mar 2024 09:18:17 +0100
Rasmus Villemoes <linux@...musvillemoes.dk> 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@...nel.org>
Powered by blists - more mailing lists