diff options
| author | Thorsten Blum <blum@kernel.org> | 2026-08-28 19:43:37 +0200 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-06 19:02:55 -0700 |
| commit | 37ee144a07c0d652bea6986ec587eafa22df32c4 (patch) | |
| tree | 46c14952fc5e9a7705be95439a0524d9b57a2b64 /init | |
| parent | b4cc0016f8ead77c823f2d55f4e0a0e61dd924b3 (diff) | |
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/20260828174337.609333-2-blum@kernel.org
Signed-off-by: Thorsten Blum <blum@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'init')
| -rw-r--r-- | init/version.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/init/version.c b/init/version.c index 0bd5c45aabc4..cbae11b6f768 100644 --- a/init/version.c +++ b/init/version.c @@ -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); |
