[{"id":1769318,"web_url":"http://patchwork.ozlabs.org/comment/1769318/","msgid":"<20170915171409.GZ5426@ZenIV.linux.org.uk>","date":"2017-09-15T17:14:09","subject":"Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel\n\tcommandline parsing.","submitter":{"id":583,"url":"http://patchwork.ozlabs.org/api/people/583/","name":"Al Viro","email":"viro@ZenIV.linux.org.uk"},"content":"On Fri, Sep 15, 2017 at 07:02:46PM +0200, Michal Suchanek wrote:\n\n>  \tfor (i = 0; args[i]; i++) {\n> -\t\tif (isspace(args[i]) && !in_quote)\n> +\t\tif (isspace(args[i]) && !in_quote && !backslash)\n>  \t\t\tbreak;\n> -\t\tif (equals == 0) {\n> -\t\t\tif (args[i] == '=')\n> -\t\t\t\tequals = i;\n> +\n> +\t\tif ((equals == 0) && (args[i] == '='))\n> +\t\t\tequals = i;\n> +\n> +\t\tif (!backslash) {\n> +\t\t\tif ((args[i] == '\"') || (args[i] == '\\\\')) {\n> +\t\t\t\tif (args[i] == '\"')\n> +\t\t\t\t\tin_quote = !in_quote;\n> +\t\t\t\tif (args[i] == '\\\\')\n> +\t\t\t\t\tbackslash = 1;\n> +\n> +\t\t\t\tmemmove(args + 1, args, i);\n> +\t\t\t\targs++;\n> +\t\t\t\ti--;\n> +\t\t\t}\n> +\t\t} else {\n> +\t\t\tbackslash = 0;\n>  \t\t}\n> -\t\tif (args[i] == '\"')\n> -\t\t\tin_quote = !in_quote;\n>  \t}\n\n... and that makes for Unidiomatic Work With Strings Award for this September.\nUsing memmove() for string rewrite is almost always bad taste; in this case\nit's also (as usual) broken.","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xv2C86QWxz9s7m\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 03:17:24 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xv2C84pxQzDrZh\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 03:17:24 +1000 (AEST)","from ZenIV.linux.org.uk (zeniv.linux.org.uk [195.92.253.2])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xv2833y0FzDq78\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat, 16 Sep 2017 03:14:43 +1000 (AEST)","from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat\n\tLinux)) id 1dsuBt-0007Lo-Uk; Fri, 15 Sep 2017 17:14:09 +0000"],"Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=ftp.linux.org.uk\n\t(client-ip=195.92.253.2; helo=zeniv.linux.org.uk;\n\tenvelope-from=viro@ftp.linux.org.uk; receiver=<UNKNOWN>)","Date":"Fri, 15 Sep 2017 18:14:09 +0100","From":"Al Viro <viro@ZenIV.linux.org.uk>","To":"Michal Suchanek <msuchanek@suse.de>","Subject":"Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel\n\tcommandline parsing.","Message-ID":"<20170915171409.GZ5426@ZenIV.linux.org.uk>","References":"<4fabdf584ad18d6aae61e331f783a5020567f634.1505231820.git.msuchanek@suse.de>\n\t<28da60231eb848981e858fa33e3b7e33f8547111.1505494668.git.msuchanek@suse.de>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<28da60231eb848981e858fa33e3b7e33f8547111.1505494668.git.msuchanek@suse.de>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Tamara Diaconita <diaconitatamara@gmail.com>, Baoquan He <bhe@redhat.com>,\n\tKamlakant Patel <kamlakant.patel@broadcom.com>,\n\tJonathan Corbet <corbet@lwn.net>, Jani Nikula <jani.nikula@intel.com>,\n\tTrond Myklebust <trond.myklebust@primarydata.com>,\n\tlinux-doc@vger.kernel.org, \n\tlinux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,\n\tIngo Molnar <mingo@kernel.org>,\n\tMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>, \n\tIlya Matveychikov <matvejchikov@gmail.com>,\n\tPaul Mackerras <paulus@samba.org>, \n\tHari Bathini <hbathini@linux.vnet.ibm.com>,\n\tAndrew Morton <akpm@linux-foundation.org>,\n\tMauro Carvalho Chehab <mchehab@kernel.org>,\n\tlinuxppc-dev@lists.ozlabs.org, \n\tBamvor Jian Zhang <bamvor.zhangjian@linaro.org>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}},{"id":1769321,"web_url":"http://patchwork.ozlabs.org/comment/1769321/","msgid":"<20170915192856.1d5708b6@kitsune.suse.cz>","date":"2017-09-15T17:28:56","subject":"Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel\n\tcommandline parsing.","submitter":{"id":70348,"url":"http://patchwork.ozlabs.org/api/people/70348/","name":"Michal Suchánek","email":"msuchanek@suse.de"},"content":"On Fri, 15 Sep 2017 18:14:09 +0100\nAl Viro <viro@ZenIV.linux.org.uk> wrote:\n\n> On Fri, Sep 15, 2017 at 07:02:46PM +0200, Michal Suchanek wrote:\n> \n> >  \tfor (i = 0; args[i]; i++) {\n> > -\t\tif (isspace(args[i]) && !in_quote)\n> > +\t\tif (isspace(args[i]) && !in_quote && !backslash)\n> >  \t\t\tbreak;\n> > -\t\tif (equals == 0) {\n> > -\t\t\tif (args[i] == '=')\n> > -\t\t\t\tequals = i;\n> > +\n> > +\t\tif ((equals == 0) && (args[i] == '='))\n> > +\t\t\tequals = i;\n> > +\n> > +\t\tif (!backslash) {\n> > +\t\t\tif ((args[i] == '\"') || (args[i] == '\\\\'))\n> > {\n> > +\t\t\t\tif (args[i] == '\"')\n> > +\t\t\t\t\tin_quote = !in_quote;\n> > +\t\t\t\tif (args[i] == '\\\\')\n> > +\t\t\t\t\tbackslash = 1;\n> > +\n> > +\t\t\t\tmemmove(args + 1, args, i);\n> > +\t\t\t\targs++;\n> > +\t\t\t\ti--;\n> > +\t\t\t}\n> > +\t\t} else {\n> > +\t\t\tbackslash = 0;\n> >  \t\t}\n> > -\t\tif (args[i] == '\"')\n> > -\t\t\tin_quote = !in_quote;\n> >  \t}  \n> \n> ... and that makes for Unidiomatic Work With Strings Award for this\n> September. Using memmove() for string rewrite is almost always bad\n> taste; in this case it's also (as usual) broken.\n\nCare to share how it is broken?\n\nThanks\n\nMichal","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xv2VW4xdDz9sPs\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 03:30:43 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xv2VW3Z7LzDqr8\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 03:30:43 +1000 (AEST)","from mx1.suse.de (mx2.suse.de [195.135.220.15])\n\t(using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xv2SZ73m7zDql9\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat, 16 Sep 2017 03:29:02 +1000 (AEST)","from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])\n\tby mx1.suse.de (Postfix) with ESMTP id 6891E5CB1C;\n\tFri, 15 Sep 2017 17:28:58 +0000 (UTC)"],"Authentication-Results":"ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=suse.de\n\t(client-ip=195.135.220.15; helo=mx1.suse.de;\n\tenvelope-from=msuchanek@suse.de; receiver=<UNKNOWN>)","X-Virus-Scanned":"by amavisd-new at test-mx.suse.de","Date":"Fri, 15 Sep 2017 19:28:56 +0200","From":"Michal =?utf-8?b?U3VjaMOhbmVr?= <msuchanek@suse.de>","To":"Al Viro <viro@ZenIV.linux.org.uk>","Subject":"Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel\n\tcommandline parsing.","Message-ID":"<20170915192856.1d5708b6@kitsune.suse.cz>","In-Reply-To":"<20170915171409.GZ5426@ZenIV.linux.org.uk>","References":"<4fabdf584ad18d6aae61e331f783a5020567f634.1505231820.git.msuchanek@suse.de>\n\t<28da60231eb848981e858fa33e3b7e33f8547111.1505494668.git.msuchanek@suse.de>\n\t<20170915171409.GZ5426@ZenIV.linux.org.uk>","X-Mailer":"Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu)","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Tamara Diaconita <diaconitatamara@gmail.com>, Baoquan He <bhe@redhat.com>,\n\tKamlakant Patel <kamlakant.patel@broadcom.com>,\n\tJonathan Corbet <corbet@lwn.net>, Jani Nikula <jani.nikula@intel.com>,\n\tMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>,\n\tTrond Myklebust <trond.myklebust@primarydata.com>,\n\tlinux-doc@vger.kernel.org, \n\tlinux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,\n\tBamvor Jian Zhang <bamvor.zhangjian@linaro.org>,\n\tAndrew Morton <akpm@linux-foundation.org>,\n\tPaul Mackerras <paulus@samba.org>, \n\tHari Bathini <hbathini@linux.vnet.ibm.com>,\n\tIlya Matveychikov <matvejchikov@gmail.com>,\n\tMauro Carvalho Chehab <mchehab@kernel.org>,\n\tlinuxppc-dev@lists.ozlabs.org, Ingo Molnar <mingo@kernel.org>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}},{"id":1774920,"web_url":"http://patchwork.ozlabs.org/comment/1774920/","msgid":"<20170925203901.0009b327@naga>","date":"2017-09-25T18:39:01","subject":"Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel\n\tcommandline parsing.","submitter":{"id":70348,"url":"http://patchwork.ozlabs.org/api/people/70348/","name":"Michal Suchánek","email":"msuchanek@suse.de"},"content":"On Fri, 15 Sep 2017 19:28:56 +0200\nMichal Suchánek <msuchanek@suse.de> wrote:\n\n> On Fri, 15 Sep 2017 18:14:09 +0100\n> Al Viro <viro@ZenIV.linux.org.uk> wrote:\n> \n> > On Fri, Sep 15, 2017 at 07:02:46PM +0200, Michal Suchanek wrote:\n> >   \n> > >  \tfor (i = 0; args[i]; i++) {\n> > > -\t\tif (isspace(args[i]) && !in_quote)\n> > > +\t\tif (isspace(args[i]) && !in_quote && !backslash)\n> > >  \t\t\tbreak;\n> > > -\t\tif (equals == 0) {\n> > > -\t\t\tif (args[i] == '=')\n> > > -\t\t\t\tequals = i;\n> > > +\n> > > +\t\tif ((equals == 0) && (args[i] == '='))\n> > > +\t\t\tequals = i;\n> > > +\n> > > +\t\tif (!backslash) {\n> > > +\t\t\tif ((args[i] == '\"') || (args[i] ==\n> > > '\\\\')) {\n> > > +\t\t\t\tif (args[i] == '\"')\n> > > +\t\t\t\t\tin_quote = !in_quote;\n> > > +\t\t\t\tif (args[i] == '\\\\')\n> > > +\t\t\t\t\tbackslash = 1;\n> > > +\n> > > +\t\t\t\tmemmove(args + 1, args, i);\n> > > +\t\t\t\targs++;\n> > > +\t\t\t\ti--;\n> > > +\t\t\t}\n> > > +\t\t} else {\n> > > +\t\t\tbackslash = 0;\n> > >  \t\t}\n> > > -\t\tif (args[i] == '\"')\n> > > -\t\t\tin_quote = !in_quote;\n> > >  \t}    \n> > \n> > ... and that makes for Unidiomatic Work With Strings Award for this\n> > September. Using memmove() for string rewrite is almost always bad\n> > taste; in this case it's also (as usual) broken.  \n> \n> Care to share how it is broken?\n\nGuess not. I will assume it is perfectly fine then. It works perfectly\nfine in my testing.\n\nUsing memmove for string rewrite is not a matter of taste. It is the\nonly library function with sane semantics for rewrite of anything. Then\nagain open-coding it is always an option and maybe in better taste for\nsome :->\n\nMichal","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y1Cbg6t5Mz9t5c\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 26 Sep 2017 04:41:35 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3y1Cbg5nFMzDsP7\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 26 Sep 2017 04:41:35 +1000 (AEST)","from mx1.suse.de (mx2.suse.de [195.135.220.15])\n\t(using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3y1CXv3crvzDsN9\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tTue, 26 Sep 2017 04:39:10 +1000 (AEST)","from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])\n\tby mx1.suse.de (Postfix) with ESMTP id 58960AD07;\n\tMon, 25 Sep 2017 18:39:04 +0000 (UTC)"],"Authentication-Results":"ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=suse.de\n\t(client-ip=195.135.220.15; helo=mx1.suse.de;\n\tenvelope-from=msuchanek@suse.de; receiver=<UNKNOWN>)","X-Virus-Scanned":"by amavisd-new at test-mx.suse.de","Date":"Mon, 25 Sep 2017 20:39:01 +0200","From":"Michal =?utf-8?b?U3VjaMOhbmVr?= <msuchanek@suse.de>","To":"Al Viro <viro@ZenIV.linux.org.uk>","Subject":"Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel\n\tcommandline parsing.","Message-ID":"<20170925203901.0009b327@naga>","In-Reply-To":"<20170915192856.1d5708b6@kitsune.suse.cz>","References":"<4fabdf584ad18d6aae61e331f783a5020567f634.1505231820.git.msuchanek@suse.de>\n\t<28da60231eb848981e858fa33e3b7e33f8547111.1505494668.git.msuchanek@suse.de>\n\t<20170915171409.GZ5426@ZenIV.linux.org.uk>\n\t<20170915192856.1d5708b6@kitsune.suse.cz>","X-Mailer":"Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-suse-linux-gnu)","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Tamara Diaconita <diaconitatamara@gmail.com>, Baoquan He <bhe@redhat.com>,\n\tKamlakant Patel <kamlakant.patel@broadcom.com>,\n\tJonathan Corbet <corbet@lwn.net>, Jani Nikula <jani.nikula@intel.com>,\n\tMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>,\n\tTrond Myklebust <trond.myklebust@primarydata.com>,\n\tlinux-doc@vger.kernel.org, \n\tlinux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,\n\tIngo Molnar <mingo@kernel.org>,\n\tIlya Matveychikov <matvejchikov@gmail.com>, \n\tPaul Mackerras <paulus@samba.org>,\n\tHari Bathini <hbathini@linux.vnet.ibm.com>, \n\tAndrew Morton <akpm@linux-foundation.org>,\n\tMauro Carvalho Chehab <mchehab@kernel.org>,\n\tlinuxppc-dev@lists.ozlabs.org, \n\tBamvor Jian Zhang <bamvor.zhangjian@linaro.org>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}}]