* Re: [PATCH] init/main.c: Remove redundant space from saved_command_line
[not found] ` <CAMuHMdU1-F0eZAXUyVCt2ik2w9J+vTm1DnvTVwx2hNz1CDZc1g@mail.gmail.com>
@ 2024-04-11 14:07 ` Masami Hiramatsu
2024-04-11 15:29 ` Yuntao Wang
0 siblings, 1 reply; 6+ messages in thread
From: Masami Hiramatsu @ 2024-04-11 14:07 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Yuntao Wang, linux-kernel, Thomas Gleixner,
Peter Zijlstra (Intel), Andrew Morton, Josh Poimboeuf,
ndesaulniers@google.com, Tejun Heo, Christophe Leroy,
Krister Johansen, Changbin Du, Arnd Bergmann, Masami Hiramatsu,
Linux Trace Kernel
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,
> >
> > 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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] init/main.c: Remove redundant space from saved_command_line
2024-04-11 14:07 ` [PATCH] init/main.c: Remove redundant space from saved_command_line Masami Hiramatsu
@ 2024-04-11 15:29 ` Yuntao Wang
2024-04-11 23:08 ` Masami Hiramatsu
0 siblings, 1 reply; 6+ messages in thread
From: Yuntao Wang @ 2024-04-11 15:29 UTC (permalink / raw)
To: mhiramat
Cc: akpm, arnd, changbin.du, christophe.leroy, geert, jpoimboe, kjlx,
linux-kernel, linux-trace-kernel, ndesaulniers, peterz, tglx, tj,
ytcoode
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.
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.
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] init/main.c: Remove redundant space from saved_command_line
2024-04-11 15:29 ` Yuntao Wang
@ 2024-04-11 23:08 ` Masami Hiramatsu
2024-04-12 1:46 ` Yuntao Wang
2024-04-12 3:29 ` [PATCH v2] " Yuntao Wang
0 siblings, 2 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2024-04-11 23:08 UTC (permalink / raw)
To: Yuntao Wang
Cc: akpm, arnd, changbin.du, christophe.leroy, geert, jpoimboe, kjlx,
linux-kernel, linux-trace-kernel, ndesaulniers, peterz, tglx, tj
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);
> 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,
>
> 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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] init/main.c: Remove redundant space from saved_command_line
2024-04-11 23:08 ` Masami Hiramatsu
@ 2024-04-12 1:46 ` Yuntao Wang
2024-04-12 3:29 ` [PATCH v2] " Yuntao Wang
1 sibling, 0 replies; 6+ messages in thread
From: Yuntao Wang @ 2024-04-12 1:46 UTC (permalink / raw)
To: mhiramat
Cc: akpm, arnd, changbin.du, christophe.leroy, geert, jpoimboe, kjlx,
linux-kernel, linux-trace-kernel, ndesaulniers, peterz, tglx, tj,
ytcoode
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] init/main.c: Remove redundant space from saved_command_line
2024-04-11 23:08 ` Masami Hiramatsu
2024-04-12 1:46 ` Yuntao Wang
@ 2024-04-12 3:29 ` Yuntao Wang
2024-04-12 5:18 ` Masami Hiramatsu
1 sibling, 1 reply; 6+ messages in thread
From: Yuntao Wang @ 2024-04-12 3:29 UTC (permalink / raw)
To: mhiramat
Cc: akpm, arnd, changbin.du, christophe.leroy, geert, jpoimboe, kjlx,
linux-kernel, linux-trace-kernel, ndesaulniers, peterz, tglx, tj,
ytcoode
There is a space at the end of extra_init_args. In the current logic,
copying extra_init_args to saved_command_line will cause extra spaces
in saved_command_line here or there. Remove the trailing space from
extra_init_args to make the string in saved_command_line look more perfect.
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
v1 -> v2: Fix the issue using the method suggested by Masami
init/main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/init/main.c b/init/main.c
index 881f6230ee59..0f03dd15e0e2 100644
--- a/init/main.c
+++ b/init/main.c
@@ -627,8 +627,10 @@ static void __init setup_command_line(char *command_line)
if (extra_command_line)
xlen = strlen(extra_command_line);
- if (extra_init_args)
+ if (extra_init_args) {
+ extra_init_args = strim(extra_init_args); /* remove trailing space */
ilen = strlen(extra_init_args) + 4; /* for " -- " */
+ }
len = xlen + strlen(boot_command_line) + 1;
--
2.44.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] init/main.c: Remove redundant space from saved_command_line
2024-04-12 3:29 ` [PATCH v2] " Yuntao Wang
@ 2024-04-12 5:18 ` Masami Hiramatsu
0 siblings, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2024-04-12 5:18 UTC (permalink / raw)
To: Yuntao Wang
Cc: akpm, arnd, changbin.du, christophe.leroy, geert, jpoimboe, kjlx,
linux-kernel, linux-trace-kernel, ndesaulniers, peterz, tglx, tj
On Fri, 12 Apr 2024 11:29:50 +0800
Yuntao Wang <ytcoode@gmail.com> wrote:
> There is a space at the end of extra_init_args. In the current logic,
> copying extra_init_args to saved_command_line will cause extra spaces
> in saved_command_line here or there. Remove the trailing space from
> extra_init_args to make the string in saved_command_line look more perfect.
>
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
OK, this looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Let me pick this to bootconfig/for-next.
Thank you,
> ---
> v1 -> v2: Fix the issue using the method suggested by Masami
>
> init/main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/init/main.c b/init/main.c
> index 881f6230ee59..0f03dd15e0e2 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -627,8 +627,10 @@ static void __init setup_command_line(char *command_line)
>
> if (extra_command_line)
> xlen = strlen(extra_command_line);
> - if (extra_init_args)
> + if (extra_init_args) {
> + extra_init_args = strim(extra_init_args); /* remove trailing space */
> ilen = strlen(extra_init_args) + 4; /* for " -- " */
> + }
>
> len = xlen + strlen(boot_command_line) + 1;
>
> --
> 2.44.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-12 5:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240411041200.225356-1-ytcoode@gmail.com>
[not found] ` <CAMuHMdU1-F0eZAXUyVCt2ik2w9J+vTm1DnvTVwx2hNz1CDZc1g@mail.gmail.com>
2024-04-11 14:07 ` [PATCH] init/main.c: Remove redundant space from saved_command_line Masami Hiramatsu
2024-04-11 15:29 ` Yuntao Wang
2024-04-11 23:08 ` Masami Hiramatsu
2024-04-12 1:46 ` Yuntao Wang
2024-04-12 3:29 ` [PATCH v2] " Yuntao Wang
2024-04-12 5:18 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).