From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: stable@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/4] tools/bootconfig: Fix to use correct quotes for value
Date: Sat, 13 Jun 2020 00:23:26 +0900 [thread overview]
Message-ID: <159197540663.80267.14460253938950080887.stgit@devnote2> (raw)
In-Reply-To: <159197538852.80267.10091816844311950396.stgit@devnote2>
Fix bootconfig tool to show the correctly choose the
double or single quotes according to the value.
If a bootconfig value includes a double quote character,
we must use single-quotes to quote that value.
Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
tools/bootconfig/main.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index 0efaf45f7367..21896a6675fd 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -14,13 +14,18 @@
#include <linux/kernel.h>
#include <linux/bootconfig.h>
-static int xbc_show_array(struct xbc_node *node)
+static int xbc_show_value(struct xbc_node *node)
{
const char *val;
+ char q;
int i = 0;
xbc_array_for_each_value(node, val) {
- printf("\"%s\"%s", val, node->next ? ", " : ";\n");
+ if (strchr(val, '"'))
+ q = '\'';
+ else
+ q = '"';
+ printf("%c%s%c%s", q, val, q, node->next ? ", " : ";\n");
i++;
}
return i;
@@ -48,10 +53,7 @@ static void xbc_show_compact_tree(void)
continue;
} else if (cnode && xbc_node_is_value(cnode)) {
printf("%s = ", xbc_node_get_data(node));
- if (cnode->next)
- xbc_show_array(cnode);
- else
- printf("\"%s\";\n", xbc_node_get_data(cnode));
+ xbc_show_value(cnode);
} else {
printf("%s;\n", xbc_node_get_data(node));
}
next prev parent reply other threads:[~2020-06-12 15:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-12 15:23 [PATCH 0/4] bootconfig: Fix quote-character issue and return value Masami Hiramatsu
2020-06-12 15:23 ` [PATCH 1/4] proc/bootconfig: Fix to use correct quotes for value Masami Hiramatsu
2020-06-12 22:42 ` Masami Hiramatsu
2020-06-15 19:11 ` Steven Rostedt
2020-06-15 19:24 ` Joe Perches
2020-06-15 21:21 ` Steven Rostedt
2020-06-15 22:30 ` Randy Dunlap
2020-06-15 22:42 ` Steven Rostedt
2020-06-15 23:12 ` Randy Dunlap
2020-06-16 5:05 ` Joe Perches
2020-06-16 8:05 ` Masami Hiramatsu
2020-06-12 15:23 ` Masami Hiramatsu [this message]
2020-06-12 15:23 ` [PATCH 3/4] tools/bootconfig: Fix to return 0 if succeeded to show the bootconfig Masami Hiramatsu
2020-06-15 19:14 ` Steven Rostedt
2020-06-16 7:53 ` Masami Hiramatsu
2020-06-12 15:23 ` [PATCH 4/4] tools/bootconfig: Add testcase for show-command and quotes test Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=159197540663.80267.14460253938950080887.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.