public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sh: simplify setup_arch command line handling
@ 2026-04-22  9:30 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-04-22  9:30 UTC (permalink / raw)
  To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz
  Cc: Thorsten Blum, linux-sh, linux-kernel

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 */

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-22  9:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22  9:30 [PATCH] sh: simplify setup_arch command line handling Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox