From: Thorsten Blum <thorsten.blum@linux.dev>
To: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sh: simplify setup_arch command line handling
Date: Wed, 22 Apr 2026 11:30:28 +0200 [thread overview]
Message-ID: <20260422093029.69042-2-thorsten.blum@linux.dev> (raw)
Handle CONFIG_CMDLINE_EXTEND explicitly in its own branch and build the
command line string with a single snprintf(), instead of first copying
COMMAND_LINE and then appending a space and CONFIG_CMDLINE using two
strlcat() calls.
This keeps the logic aligned with the mutually exclusive Kconfig options
and makes the three cases easier to read.
Also use the two-argument version of strscpy() for the fixed-size
'command_line' buffer in the overwrite and bootloader-only cases.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/sh/kernel/setup.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 039a51291002..d8c19a3d2801 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -299,14 +299,13 @@ void __init setup_arch(char **cmdline_p)
bss_resource.start = virt_to_phys(__bss_start);
bss_resource.end = virt_to_phys(__bss_stop)-1;
-#ifdef CONFIG_CMDLINE_OVERWRITE
- strscpy(command_line, CONFIG_CMDLINE, sizeof(command_line));
+#if defined(CONFIG_CMDLINE_OVERWRITE)
+ strscpy(command_line, CONFIG_CMDLINE);
+#elif defined(CONFIG_CMDLINE_EXTEND)
+ snprintf(command_line, sizeof(command_line), "%s %s", COMMAND_LINE,
+ CONFIG_CMDLINE);
#else
- strscpy(command_line, COMMAND_LINE, sizeof(command_line));
-#ifdef CONFIG_CMDLINE_EXTEND
- strlcat(command_line, " ", sizeof(command_line));
- strlcat(command_line, CONFIG_CMDLINE, sizeof(command_line));
-#endif
+ strscpy(command_line, COMMAND_LINE);
#endif
/* Save unparsed command line copy for /proc/cmdline */
reply other threads:[~2026-04-22 9:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260422093029.69042-2-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=dalias@libc.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=ysato@users.sourceforge.jp \
/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.