lkml.org 
[lkml]   [2017]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing.
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.

\
 
 \ /
  Last update: 2017-09-15 19:14    [W:0.071 / U:2.444 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site