From: "Michal Suchánek" <msuchanek@suse.de>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Tamara Diaconita <diaconitatamara@gmail.com>,
Baoquan He <bhe@redhat.com>,
Kamlakant Patel <kamlakant.patel@broadcom.com>,
Jonathan Corbet <corbet@lwn.net>,
Jani Nikula <jani.nikula@intel.com>,
Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>,
Trond Myklebust <trond.myklebust@primarydata.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Nicholas Piggin <npiggin@gmail.com>,
Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>,
Andrew Morton <akpm@linux-foundation.org>,
Paul Mackerras <paulus@samba.org>,
Hari Bathini <hbathini@linux.vnet.ibm.com>,
Ilya Matveychikov <matvejchikov@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linuxppc-dev@lists.ozlabs.org, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing.
Date: Mon, 25 Sep 2017 20:39:01 +0200 [thread overview]
Message-ID: <20170925203901.0009b327@naga> (raw)
In-Reply-To: <20170915192856.1d5708b6@kitsune.suse.cz>
On Fri, 15 Sep 2017 19:28:56 +0200
Michal Such=C3=A1nek <msuchanek@suse.de> wrote:
> On Fri, 15 Sep 2017 18:14:09 +0100
> Al Viro <viro@ZenIV.linux.org.uk> wrote:
>=20
> > On Fri, Sep 15, 2017 at 07:02:46PM +0200, Michal Suchanek wrote:
> > =20
> > > for (i =3D 0; args[i]; i++) {
> > > - if (isspace(args[i]) && !in_quote)
> > > + if (isspace(args[i]) && !in_quote && !backslash)
> > > break;
> > > - if (equals =3D=3D 0) {
> > > - if (args[i] =3D=3D '=3D')
> > > - equals =3D i;
> > > +
> > > + if ((equals =3D=3D 0) && (args[i] =3D=3D '=3D'))
> > > + equals =3D i;
> > > +
> > > + if (!backslash) {
> > > + if ((args[i] =3D=3D '"') || (args[i] =3D=3D
> > > '\\')) {
> > > + if (args[i] =3D=3D '"')
> > > + in_quote =3D !in_quote;
> > > + if (args[i] =3D=3D '\\')
> > > + backslash =3D 1;
> > > +
> > > + memmove(args + 1, args, i);
> > > + args++;
> > > + i--;
> > > + }
> > > + } else {
> > > + backslash =3D 0;
> > > }
> > > - if (args[i] =3D=3D '"')
> > > - in_quote =3D !in_quote;
> > > } =20
> >=20
> > ... and that makes for Unidiomatic Work With Strings Award for this
> > September. Using memmove() for string rewrite is almost always bad
> > taste; in this case it's also (as usual) broken. =20
>=20
> Care to share how it is broken?
Guess not. I will assume it is perfectly fine then. It works perfectly
fine in my testing.
Using memmove for string rewrite is not a matter of taste. It is the
only library function with sane semantics for rewrite of anything. Then
again open-coding it is always an option and maybe in better taste for
some :->
Michal
WARNING: multiple messages have this Message-ID (diff)
From: "Michal Suchánek" <msuchanek@suse.de>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Tamara Diaconita <diaconitatamara@gmail.com>,
Baoquan He <bhe@redhat.com>,
Kamlakant Patel <kamlakant.patel@broadcom.com>,
Jonathan Corbet <corbet@lwn.net>,
Jani Nikula <jani.nikula@intel.com>,
Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>,
Trond Myklebust <trond.myklebust@primarydata.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Nicholas Piggin <npiggin@gmail.com>,
Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>,
Andrew Morton <akpm@linux-foundation.org>,
Paul Mackerras <paulus@samba.org>,
Hari Bathini <hbathini@linux.vnet.ibm.com>,
Ilya Matveychikov <matvejchikov@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linuxppc-dev@lists.ozlabs.org, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing.
Date: Mon, 25 Sep 2017 20:39:01 +0200 [thread overview]
Message-ID: <20170925203901.0009b327@naga> (raw)
In-Reply-To: <20170915192856.1d5708b6@kitsune.suse.cz>
On Fri, 15 Sep 2017 19:28:56 +0200
Michal Suchánek <msuchanek@suse.de> wrote:
> On Fri, 15 Sep 2017 18:14:09 +0100
> Al Viro <viro@ZenIV.linux.org.uk> wrote:
>
> > On Fri, Sep 15, 2017 at 07:02:46PM +0200, Michal Suchanek wrote:
> >
> > > for (i = 0; args[i]; i++) {
> > > - if (isspace(args[i]) && !in_quote)
> > > + if (isspace(args[i]) && !in_quote && !backslash)
> > > break;
> > > - if (equals == 0) {
> > > - if (args[i] == '=')
> > > - equals = i;
> > > +
> > > + if ((equals == 0) && (args[i] == '='))
> > > + equals = i;
> > > +
> > > + if (!backslash) {
> > > + if ((args[i] == '"') || (args[i] ==
> > > '\\')) {
> > > + if (args[i] == '"')
> > > + in_quote = !in_quote;
> > > + if (args[i] == '\\')
> > > + backslash = 1;
> > > +
> > > + memmove(args + 1, args, i);
> > > + args++;
> > > + i--;
> > > + }
> > > + } else {
> > > + backslash = 0;
> > > }
> > > - if (args[i] == '"')
> > > - in_quote = !in_quote;
> > > }
> >
> > ... and that makes for Unidiomatic Work With Strings Award for this
> > September. Using memmove() for string rewrite is almost always bad
> > taste; in this case it's also (as usual) broken.
>
> Care to share how it is broken?
Guess not. I will assume it is perfectly fine then. It works perfectly
fine in my testing.
Using memmove for string rewrite is not a matter of taste. It is the
only library function with sane semantics for rewrite of anything. Then
again open-coding it is always an option and maybe in better taste for
some :->
Michal
next prev parent reply other threads:[~2017-09-25 18:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-12 16:01 [PATCH v8 1/6] powerpc/fadump: reduce memory consumption for capture kernel Michal Suchanek
2017-09-12 16:01 ` [PATCH v8 2/6] powerpc/fadump: update documentation about 'fadump_extra_args=' parameter Michal Suchanek
2017-09-12 16:01 ` [PATCH v8 3/6] lib/cmdline.c: Remove quotes symmetrically Michal Suchanek
2017-09-12 16:01 ` [PATCH v8 4/6] powerpc/fadump: update the dequoting logic to match lib/cmdline.c Michal Suchanek
2017-09-12 16:01 ` [PATCH v8 5/6] boot/param: add pointer to current and next argument to unknown parameter callback Michal Suchanek
2017-09-12 16:01 ` [PATCH v8 6/6] powerpc/fadump: use the new parse_args callback arguments Michal Suchanek
2017-09-15 17:02 ` [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing Michal Suchanek
2017-09-15 17:14 ` Al Viro
2017-09-15 17:28 ` Michal Suchánek
2017-09-25 18:39 ` Michal Suchánek [this message]
2017-09-25 18:39 ` Michal Suchánek
2017-09-15 17:02 ` [PATCH 2/6] Documentation/admin-guide: backslash support in commandline Michal Suchanek
2017-09-15 17:02 ` [PATCH 3/6] powerpc/fadump: stop removing quotes in argument parsing Michal Suchanek
2017-09-15 17:02 ` [PATCH 4/6] powerpc/fadump: Update fadump ducumentation on quoting arguments Michal Suchanek
2017-09-15 17:02 ` [PATCH 5/6] lib/cmdline.c: Implement single quotes in commandline argument parsing Michal Suchanek
2017-09-15 17:02 ` [PATCH 6/6] Documentation/admin-guide: single quotes in kernel arguments Michal Suchanek
2017-09-15 17:59 ` Randy Dunlap
2017-09-25 18:40 ` Michal Suchánek
2017-09-29 13:00 ` [PATCH v8 6/6] powerpc/fadump: use the new parse_args callback arguments Hari Bathini
2017-09-27 10:31 ` [PATCH v8 1/6] powerpc/fadump: reduce memory consumption for capture kernel Hari Bathini
2017-09-27 10:45 ` Hari Bathini
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=20170925203901.0009b327@naga \
--to=msuchanek@suse.de \
--cc=akpm@linux-foundation.org \
--cc=bamvor.zhangjian@linaro.org \
--cc=bhe@redhat.com \
--cc=corbet@lwn.net \
--cc=diaconitatamara@gmail.com \
--cc=hbathini@linux.vnet.ibm.com \
--cc=jani.nikula@intel.com \
--cc=kamlakant.patel@broadcom.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mahesh@linux.vnet.ibm.com \
--cc=matvejchikov@gmail.com \
--cc=mchehab@kernel.org \
--cc=mingo@kernel.org \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
--cc=trond.myklebust@primarydata.com \
--cc=viro@ZenIV.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.