Skip to contentSkip to conversation

init: Simplify early_hostname()

PATCH Applied Thorsten Blum 1 participant 1 message Aug 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init: Simplify early_hostname()

Inline the strscpy() check and remove the redundant arglen variable. Use %zu to format the unsigned maxlen argument and add a newline after the truncation warning.

---
 init/version.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
init/version.c +3 -5
index 0bd5c45aabc4..cbae11b6f768 100644
@@ -21,16 +21,14 @@ static int __init early_hostname(char *arg)
 {
 	size_t bufsize = sizeof(init_uts_ns.name.nodename);
 	size_t maxlen  = bufsize - 1;
-	ssize_t arglen;
 
 	if (!arg)
 		return -EINVAL;
 
-	arglen = strscpy(init_uts_ns.name.nodename, arg, bufsize);
-	if (arglen < 0) {
-		pr_warn("hostname parameter exceeds %zd characters and will be truncated",
+	if (strscpy(init_uts_ns.name.nodename, arg, bufsize) < 0)
+		pr_warn("hostname parameter exceeds %zu characters and will be truncated\n",
 			maxlen);
-	}
+
 	return 0;
 }
 early_param("hostname", early_hostname);