init/main.c: Remove redundant space from saved_command_line
PATCH 1/1 init/main.c: Remove redundant space from saved_command_line
extra_init_args ends with a space, so when concatenating extra_init_args to saved_command_line, be sure to remove the extra space.
--- init/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
init/main.c +3 -1
@@ -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 */ } }
Signature · 1 line
2.44.0
CC Masami Hiramatsu <[email protected]>
Quoted 17 lines · Yuntao Wang
extra_init_argsends with a space, so when concatenatingextra_init_argstosaved_command_line, be sure to remove the extra space.Signed-off-by Yuntao Wang <[email protected]>--- init/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)init/main.c +0
-1@@ -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 );
init/main.c static void __init setup_command_line(char *command_line) · line 672
Quoted 10 lines
init/main.c +3
-0+ 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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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
CC Hiramatsu-san (now for real :-)
Quoted 17 lines · Yuntao Wang
extra_init_argsends with a space, so when concatenatingextra_init_argstosaved_command_line, be sure to remove the extra space.Signed-off-by Yuntao Wang <[email protected]>--- init/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)init/main.c +0
-1@@ -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 );
init/main.c static void __init setup_command_line(char *command_line) · line 672
Quoted 10 lines
init/main.c +3
-0+ 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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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)
maintainerQuoted 1 line · On Thu, 11 Apr 2024 09:19:32 +0200 Geert Uytterhoeven <[email protected]>…
CC Hiramatsu-san (now for real :-)
Thanks!
Quoted 4 lines · Yuntao Wang
Quoted 2 lines
extra_init_argsends with a space, so when concatenatingextra_init_argstosaved_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,
Quoted 37 lines
Quoted 15 lines
Signed-off-by Yuntao Wang <[email protected]>--- init/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)init/main.c +0
-1@@ -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 );init/main.c static void __init setup_command_line(char *command_line) · line 672
Quoted 10 lines
init/main.c +3
-0+ 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
Signature · 5 lines
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
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 12 lines · Masami Hiramatsu (Google)
Quoted 1 line · On Thu, 11 Apr 2024 09:19:32 +0200 Geert Uytterhoeven <[email protected]>…
CC Hiramatsu-san (now for real :-)
Thanks!
Quoted 4 lines · Yuntao Wang
Quoted 2 lines
extra_init_argsends with a space, so when concatenatingextra_init_argstosaved_command_line, be sure to remove the extra space.
Quoted 6 lines
Hi Yuntao,
Hmm, if you want to trim the end space, you should trim
extra_init_argsitself 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'.
Quoted 41 lines
Quoted 37 lines
Quoted 15 lines
Signed-off-by Yuntao Wang <[email protected]>--- init/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)init/main.c +0
-1@@ -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 );init/main.c static void __init setup_command_line(char *command_line) · line 672
Quoted 10 lines
init/main.c +3
-0+ 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
Signature · 5 lines
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 TorvaldsSignature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Masami Hiramatsu (Google)
maintainerQuoted 16 lines · On Thu, 11 Apr 2024 23:29:40 +0800 Yuntao Wang <[email protected]> wrote:
Quoted 14 lines · Masami Hiramatsu (Google)
Quoted 1 line · On Thu, 11 Apr 2024 09:19:32 +0200 Geert Uytterhoeven <[email protected]>…
CC Hiramatsu-san (now for real :-)
Thanks!
Quoted 4 lines · Yuntao Wang
Quoted 2 lines
extra_init_argsends with a space, so when concatenatingextra_init_argstosaved_command_line, be sure to remove the extra space.Hi Yuntao,
Quoted 8 lines
Quoted 4 lines
Hmm, if you want to trim the end space, you should trim
extra_init_argsitself 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_lineandextra_init_argsend 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);
Quoted 11 lines
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,
Quoted 45 lines
Note that the first 'before' ends with a space, and there are two spaces between '
bootconfig_arg1' and 'arg1' in the second 'before'.Quoted 41 lines
Quoted 37 lines
Quoted 15 lines
Signed-off-by Yuntao Wang <[email protected]>--- init/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)init/main.c +0
-1@@ -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 );init/main.c static void __init setup_command_line(char *command_line) · line 672
Quoted 10 lines
init/main.c +3
-0+ 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
Signature · 5 lines
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 TorvaldsSignature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 24 lines · Masami Hiramatsu (Google)
Quoted 21 lines · On Thu, 11 Apr 2024 23:29:40 +0800 Yuntao Wang <[email protected]> wrote:
Quoted 18 lines · Masami Hiramatsu (Google)
Quoted 1 line · On Thu, 11 Apr 2024 09:19:32 +0200 Geert Uytterhoeven <[email protected]>…
CC Hiramatsu-san (now for real :-)
Thanks!
Quoted 4 lines · Yuntao Wang
Quoted 2 lines
extra_init_argsends with a space, so when concatenatingextra_init_argstosaved_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_argsitself instead of this adjustment. Also, can you share the example?Thank you,
Quoted 8 lines
Quoted 3 lines
At first, I also intended to fix this issue as you suggested. However, because both
extra_command_lineandextra_init_argsend 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.
Quoted 7 lines
Quoted 7 lines
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'
Quoted 8 lines
Quoted 4 lines
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.
Quoted 49 lines
Quoted 45 lines
Note that the first 'before' ends with a space, and there are two spaces between '
bootconfig_arg1' and 'arg1' in the second 'before'.Quoted 41 lines
Quoted 37 lines
Quoted 15 lines
Signed-off-by Yuntao Wang <[email protected]>--- init/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)init/main.c +0
-1@@ -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 );init/main.c static void __init setup_command_line(char *command_line) · line 672
Quoted 10 lines
init/main.c +3
-0+ 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
Signature · 5 lines
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 TorvaldsSignature · 1 line
Masami Hiramatsu (Google) <[email protected]>Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
PATCH v2 1/1 init/main.c: Remove redundant space from saved_command_line
In reply to Masami Hiramatsu (Google)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.
---
v1 -> v2: Fix the issue using the method suggested by Masami
init/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
init/main.c +3 -1
@@ -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 ;
Signature · 1 line
2.44.0
Quoted 6 lines · On Fri, 12 Apr 2024 11:29:50 +0800 Yuntao Wang <[email protected]> wrote:
There is a space at the end of
extra_init_args. In the current logic, copyingextra_init_argstosaved_command_linewill cause extra spaces insaved_command_linehere or there. Remove the trailing space fromextra_init_argsto make the string insaved_command_linelook more perfect.Signed-off-by Yuntao Wang <[email protected]>
OK, this looks good to me.
Let me pick this to bootconfig/for-next.
Thank you,
Quoted 25 lines
---
v1 -> v2: Fix the issue using the method suggested by Masamiinit/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)init/main.c +3
-1@@ -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 ;Signature · 1 line
2.44.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>