Skip to content

Commit 272da32

Browse files
mhiramatrostedt
authored andcommitted
tools/bootconfig: Fix to use correct quotes for value
Fix bootconfig tool to select double or single quotes correctly according to the value. If a bootconfig value includes a double quote character, we must use single-quotes to quote that value. Link: http://lkml.kernel.org/r/159230245697.65555.12444299015852932304.stgit@devnote2 Cc: stable@vger.kernel.org Fixes: 950313e ("tools: bootconfig: Add bootconfig command") Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 4e264ff commit 272da32

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎tools/bootconfig/main.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
#include <linux/kernel.h>
1515
#include <linux/bootconfig.h>
1616

17-
static int xbc_show_array(struct xbc_node *node)
17+
static int xbc_show_value(struct xbc_node *node)
1818
{
1919
const char *val;
20+
char q;
2021
int i = 0;
2122

2223
xbc_array_for_each_value(node, val) {
23-
printf("\"%s\"%s", val, node->next ? ", " : ";\n");
24+
if (strchr(val, '"'))
25+
q = '\'';
26+
else
27+
q = '"';
28+
printf("%c%s%c%s", q, val, q, node->next ? ", " : ";\n");
2429
i++;
2530
}
2631
return i;
@@ -48,10 +53,7 @@ static void xbc_show_compact_tree(void)
4853
continue;
4954
} else if (cnode && xbc_node_is_value(cnode)) {
5055
printf("%s = ", xbc_node_get_data(node));
51-
if (cnode->next)
52-
xbc_show_array(cnode);
53-
else
54-
printf("\"%s\";\n", xbc_node_get_data(cnode));
56+
xbc_show_value(cnode);
5557
} else {
5658
printf("%s;\n", xbc_node_get_data(node));
5759
}

0 commit comments

Comments
 (0)