From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Tom Zanussi <tom.zanussi@linux.intel.com>,
Borislav Petkov <bp@alien8.de>
Subject: [for-linus][PATCH 13/15] bootconfig: Print array as multiple commands for legacy command line
Date: Mon, 24 Feb 2020 12:20:35 -0500 [thread overview]
Message-ID: <20200224172117.900809318@goodmis.org> (raw)
In-Reply-To: 20200224172022.330525468@goodmis.org
From: Masami Hiramatsu <mhiramat@kernel.org>
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 <bp@alien8.de>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
init/main.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/init/main.c b/init/main.c
index 2fe8dec93e68..c9b1ee6bbb8d 100644
--- a/init/main.c
+++ b/init/main.c
@@ -268,7 +268,6 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
{
struct xbc_node *knode, *vnode;
char *end = buf + size;
- char c = '\"';
const char *val;
int ret;
@@ -279,25 +278,20 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
return ret;
vnode = xbc_node_get_child(knode);
- ret = snprintf(buf, rest(buf, end), "%s%c", xbc_namebuf,
- vnode ? '=' : ' ');
- if (ret < 0)
- return ret;
- buf += ret;
- if (!vnode)
+ if (!vnode) {
+ ret = snprintf(buf, rest(buf, end), "%s ", xbc_namebuf);
+ if (ret < 0)
+ return ret;
+ buf += ret;
continue;
-
- c = '\"';
+ }
xbc_array_for_each_value(vnode, val) {
- ret = snprintf(buf, rest(buf, end), "%c%s", c, val);
+ ret = snprintf(buf, rest(buf, end), "%s=\"%s\" ",
+ xbc_namebuf, val);
if (ret < 0)
return ret;
buf += ret;
- c = ',';
}
- if (rest(buf, end) > 2)
- strcpy(buf, "\" ");
- buf += 2;
}
return buf - (end - size);
--
2.25.0
next prev parent reply other threads:[~2020-02-24 17:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 17:20 [for-linus][PATCH 00/15] tracing: Updates coming for 5.6 rc release Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 01/15] tracing: Make sure synth_event_trace() example always uses u64 Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 02/15] tracing: Make synth_event trace functions endian-correct Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 03/15] tracing: Check that number of vals matches number of synth event fields Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 04/15] tracing: Fix number printing bug in print_synth_event() Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 05/15] tracing: Have synthetic event test use raw_smp_processor_id() Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 06/15] tracing: Disable trace_printk() on post poned tests Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 07/15] bootconfig: Mark boot_config_checksum() static Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 08/15] tracing: Clear trace_state when starting trace Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 09/15] bootconfig: Set CONFIG_BOOT_CONFIG=n by default Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 10/15] bootconfig: Add bootconfig magic word for indicating bootconfig explicitly Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 11/15] tools/bootconfig: Remove unneeded error message silencer Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 12/15] bootconfig: Reject subkey and value on same parent key Steven Rostedt
2020-02-24 17:20 ` Steven Rostedt [this message]
2020-02-24 17:20 ` [for-linus][PATCH 14/15] bootconfig: Prohibit re-defining value on same key Steven Rostedt
2020-02-24 17:20 ` [for-linus][PATCH 15/15] bootconfig: Add append value operator support Steven Rostedt
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=20200224172117.900809318@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=tom.zanussi@linux.intel.com \
/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.