[PATCH] sh: simplify setup_arch command line handling

Thorsten Blum <[email protected]>
Newsgroups gmane.linux.ports.sh.devel,gmane.linux.kernel
Message-ID <[email protected]>
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 <[email protected]>
---
 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 */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.