Skip to contentSkip to conversation

sh: simplify setup_arch command line handling

PATCH New Thorsten Blum 1 participant 1 message Apr 22 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh: simplify setup_arch command line handling

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.

---
 arch/sh/kernel/setup.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
arch/sh/kernel/setup.c +6 -7
index 039a51291002..d8c19a3d2801 100644
@@ -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 */