From: Thorsten Blum <blum@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Thorsten Blum <blum@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] init: Simplify early_hostname()
Date: Fri, 28 Aug 2026 19:43:37 +0200 [thread overview]
Message-ID: <20260828174337.609333-2-blum@kernel.org> (raw)
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);
reply other threads:[~2026-08-28 17:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260828174337.609333-2-blum@kernel.org \
--to=blum@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.