From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bootconfig: do not put quotes on cmdline items unless necessary
Date: Fri, 8 Mar 2024 14:41:46 +0900 [thread overview]
Message-ID: <20240308144146.7875c1a3092846111c6ca690@kernel.org> (raw)
In-Reply-To: <40914a69-d4b7-4fdd-bc58-cf9b28271ac3@rasmusvillemoes.dk>
On Thu, 7 Mar 2024 09:18:17 +0100
Rasmus Villemoes <linux@rasmusvillemoes.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@kernel.org>
prev parent reply other threads:[~2024-03-08 5:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 12:24 Rasmus Villemoes
2024-03-06 20:42 ` Andrew Morton
2024-03-07 8:10 ` Rasmus Villemoes
2024-03-07 8:18 ` Rasmus Villemoes
2024-03-08 5:41 ` Masami Hiramatsu [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=20240308144146.7875c1a3092846111c6ca690@kernel.org \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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®