* [PATCH] init: Simplify early_hostname()
@ 2026-08-28 17:43 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-08-28 17:43 UTC (permalink / raw)
To: Andrew Morton, Thorsten Blum; +Cc: linux-kernel
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.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
init/version.c | 8 +++-----
1 file 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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-28 17:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28 17:43 [PATCH] init: Simplify early_hostname() Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®