All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuntao Wang <ytcoode@gmail.com>
To: mhiramat@kernel.org
Cc: akpm@linux-foundation.org, arnd@arndb.de, changbin.du@huawei.com,
	christophe.leroy@csgroup.eu, geert@linux-m68k.org,
	jpoimboe@kernel.org, kjlx@templeofstupid.com,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	ndesaulniers@google.com, peterz@infradead.org,
	tglx@linutronix.de, tj@kernel.org, ytcoode@gmail.com
Subject: Re: [PATCH] init/main.c: Remove redundant space from saved_command_line
Date: Fri, 12 Apr 2024 09:46:34 +0800	[thread overview]
Message-ID: <20240412014642.290764-1-ytcoode@gmail.com> (raw)
In-Reply-To: <20240412080839.c903a0058bd6594d31bc1d3e@kernel.org>

On Fri, 12 Apr 2024 08:08:39 +0900, Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Thu, 11 Apr 2024 23:29:40 +0800
> Yuntao Wang <ytcoode@gmail.com> wrote:
> 
> > On Thu, 11 Apr 2024 23:07:45 +0900, Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> > 
> > > On Thu, 11 Apr 2024 09:19:32 +0200
> > > Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > 
> > > > CC Hiramatsu-san (now for real :-)
> > > 
> > > Thanks!
> > > 
> > > > 
> > > > On Thu, Apr 11, 2024 at 6:13 AM Yuntao Wang <ytcoode@gmail.com> wrote:
> > > > > extra_init_args ends with a space, so when concatenating extra_init_args
> > > > > to saved_command_line, be sure to remove the extra space.
> > > 
> > > Hi Yuntao,
> > > 
> > > Hmm, if you want to trim the end space, you should trim extra_init_args
> > > itself instead of this adjustment. Also, can you share the example?
> > > 
> > > Thank you,
> > 
> > At first, I also intended to fix this issue as you suggested. However,
> > because both extra_command_line and extra_init_args end with a space,
> > making such a change would require modifications in many places.
> 
> You may just need:
> 
> if (extra_init_args)
> 	strim(extra_init_args);

Okay, I'll post another patch, making the changes as you suggested.

> > That's why I chose this approach instead.
> > 
> > Here are some examples before and after modification:
> > 
> > Before: [    0.829179] Kernel command line: 'console=ttyS0 debug -- bootconfig_arg1 '
> > After:  [    0.032648] Kernel command line: 'console=ttyS0 debug -- bootconfig_arg1'
> > 
> > Before: [    0.757217] Kernel command line: 'console=ttyS0 debug -- bootconfig_arg1  arg1'
> > After:  [    0.068184] Kernel command line: 'console=ttyS0 debug -- bootconfig_arg1 arg1'
> > 
> > In order to make it easier to observe spaces, I added quotes when outputting saved_command_line.
> 
> BTW, is this tailing space harm anything? I don't like a cosmetic change.
> 
> Thank you,

I think this modification is necessary.

If saved_command_line is only used internally in the kernel, having extra
spaces, while not perfect, is acceptable to me. However, since saved_command_line
can be accessed by users through the /proc/cmdline file, having these extra
spaces here and there makes it look too casual.

> > 
> > Note that the first 'before' ends with a space, and there are two spaces between
> > 'bootconfig_arg1' and 'arg1' in the second 'before'.
> > 
> > > > >
> > > > > Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> > > > > ---
> > > > >  init/main.c | 4 +++-
> > > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/init/main.c b/init/main.c
> > > > > index 2ca52474d0c3..cf2c22aa0e8c 100644
> > > > > --- a/init/main.c
> > > > > +++ b/init/main.c
> > > > > @@ -660,12 +660,14 @@ static void __init setup_command_line(char *command_line)
> > > > >                         strcpy(saved_command_line + len, extra_init_args);
> > > > >                         len += ilen - 4;        /* strlen(extra_init_args) */
> > > > >                         strcpy(saved_command_line + len,
> > > > > -                               boot_command_line + initargs_offs - 1);
> > > > > +                               boot_command_line + initargs_offs);
> > > > >                 } else {
> > > > >                         len = strlen(saved_command_line);
> > > > >                         strcpy(saved_command_line + len, " -- ");
> > > > >                         len += 4;
> > > > >                         strcpy(saved_command_line + len, extra_init_args);
> > > > > +                       len += ilen - 4; /* strlen(extra_init_args) */
> > > > > +                       saved_command_line[len-1] = '\0'; /* remove trailing space */
> > > > >                 }
> > > > >         }
> > > > 
> > > > Gr{oetje,eeting}s,
> > > > 
> > > >                         Geert
> > > > 
> > > > -- 
> > > > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68korg
> > > > 
> > > > In personal conversations with technical people, I call myself a hacker. But
> > > > when I'm talking to journalists I just say "programmer" or something like that.
> > > >                                 -- Linus Torvalds
> > > > 
> > > 
> > > 
> > > -- 
> > > Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> 
> -- 
> Masami Hiramatsu (Google) <mhiramat@kernel.org>

  reply	other threads:[~2024-04-12  1:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  4:12 [PATCH] init/main.c: Remove redundant space from saved_command_line Yuntao Wang
2024-04-11  7:18 ` Geert Uytterhoeven
2024-04-11  7:19 ` Geert Uytterhoeven
2024-04-11 14:07   ` Masami Hiramatsu
2024-04-11 15:29     ` Yuntao Wang
2024-04-11 23:08       ` Masami Hiramatsu
2024-04-12  1:46         ` Yuntao Wang [this message]
2024-04-12  3:29         ` [PATCH v2] " Yuntao Wang
2024-04-12  5:18           ` Masami Hiramatsu

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=20240412014642.290764-1-ytcoode@gmail.com \
    --to=ytcoode@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=changbin.du@huawei.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=geert@linux-m68k.org \
    --cc=jpoimboe@kernel.org \
    --cc=kjlx@templeofstupid.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /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.