Skip to content

Commit e9d6825

Browse files
committed
Merge tag 'bootconfig-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull bootconfig updates from Masami Hiramatsu: - Do not put unneeded quotes on the extra command line items which was inserted from the bootconfig. - Remove redundant spaces from the extra command line. * tag 'bootconfig-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: init/main.c: Minor cleanup for the setup_command_line() function init/main.c: Remove redundant space from saved_command_line bootconfig: do not put quotes on cmdline items unless necessary
2 parents 91b6163 + ddd5336 commit e9d6825

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

init/main.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
327327
{
328328
struct xbc_node *knode, *vnode;
329329
char *end = buf + size;
330-
const char *val;
330+
const char *val, *q;
331331
int ret;
332332

333333
xbc_node_for_each_key_value(root, knode, val) {
@@ -345,8 +345,9 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
345345
continue;
346346
}
347347
xbc_array_for_each_value(vnode, val) {
348-
ret = snprintf(buf, rest(buf, end), "%s=\"%s\" ",
349-
xbc_namebuf, val);
348+
q = strpbrk(val, " \t\r\n") ? "\"" : "";
349+
ret = snprintf(buf, rest(buf, end), "%s=%s%s%s ",
350+
xbc_namebuf, q, val, q);
350351
if (ret < 0)
351352
return ret;
352353
buf += ret;
@@ -627,14 +628,16 @@ static void __init setup_command_line(char *command_line)
627628

628629
if (extra_command_line)
629630
xlen = strlen(extra_command_line);
630-
if (extra_init_args)
631+
if (extra_init_args) {
632+
extra_init_args = strim(extra_init_args); /* remove trailing space */
631633
ilen = strlen(extra_init_args) + 4; /* for " -- " */
634+
}
632635

633-
len = xlen + strlen(boot_command_line) + 1;
636+
len = xlen + strlen(boot_command_line) + ilen + 1;
634637

635-
saved_command_line = memblock_alloc(len + ilen, SMP_CACHE_BYTES);
638+
saved_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
636639
if (!saved_command_line)
637-
panic("%s: Failed to allocate %zu bytes\n", __func__, len + ilen);
640+
panic("%s: Failed to allocate %zu bytes\n", __func__, len);
638641

639642
len = xlen + strlen(command_line) + 1;
640643

0 commit comments

Comments
 (0)