mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
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. Link: https://lore.kernel.org/[email protected] Signed-off-by: Thorsten Blum <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
committed by
Andrew Morton
parent
b4cc0016f8
commit
37ee144a07
+3
-5
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user