Skip to content

Commit 88b9137

Browse files
mhiramatrostedt
authored andcommitted
bootconfig: Print array as multiple commands for legacy command line
Print arraied values as multiple same options for legacy kernel command line. With this rule, if the "kernel.*" and "init.*" array entries in bootconfig are printed out as multiple same options, e.g. kernel { console = "ttyS0,115200" console += "tty0" } will be correctly converted to console="ttyS0,115200" console="tty0" in the kernel command line. Link: http://lkml.kernel.org/r/158220118213.26565.8163300497009463916.stgit@devnote2 Reported-by: Borislav Petkov <[email protected]> Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent a24d286 commit 88b9137

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

init/main.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
268268
{
269269
struct xbc_node *knode, *vnode;
270270
char *end = buf + size;
271-
char c = '\"';
272271
const char *val;
273272
int ret;
274273

@@ -279,25 +278,20 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
279278
return ret;
280279

281280
vnode = xbc_node_get_child(knode);
282-
ret = snprintf(buf, rest(buf, end), "%s%c", xbc_namebuf,
283-
vnode ? '=' : ' ');
284-
if (ret < 0)
285-
return ret;
286-
buf += ret;
287-
if (!vnode)
281+
if (!vnode) {
282+
ret = snprintf(buf, rest(buf, end), "%s ", xbc_namebuf);
283+
if (ret < 0)
284+
return ret;
285+
buf += ret;
288286
continue;
289-
290-
c = '\"';
287+
}
291288
xbc_array_for_each_value(vnode, val) {
292-
ret = snprintf(buf, rest(buf, end), "%c%s", c, val);
289+
ret = snprintf(buf, rest(buf, end), "%s=\"%s\" ",
290+
xbc_namebuf, val);
293291
if (ret < 0)
294292
return ret;
295293
buf += ret;
296-
c = ',';
297294
}
298-
if (rest(buf, end) > 2)
299-
strcpy(buf, "\" ");
300-
buf += 2;
301295
}
302296

303297
return buf - (end - size);

0 commit comments

Comments
 (0)