* [PATCH RESEND] block: Replace deprecated strcpy() in devt_from_devname()
@ 2026-07-27 9:57 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-07-27 9:57 UTC (permalink / raw)
To: Jens Axboe; +Cc: Thorsten Blum, linux-block, linux-kernel
strcpy() is deprecated [1] and uses an additional strlen() internally;
use memcpy() directly since we already know the length of name and that
it is guaranteed to be NUL-terminated. Also use strnlen() and sizeof()
instead of the hard-coded size while at it.
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
block/early-lookup.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/block/early-lookup.c b/block/early-lookup.c
index 3fb57f7d2b12..5c30a0cc85a0 100644
--- a/block/early-lookup.c
+++ b/block/early-lookup.c
@@ -155,10 +155,11 @@ static int __init devt_from_devname(const char *name, dev_t *devt)
int part;
char s[32];
char *p;
+ size_t name_len = strnlen(name, sizeof(s));
- if (strlen(name) > 31)
+ if (name_len == sizeof(s))
return -EINVAL;
- strcpy(s, name);
+ memcpy(s, name, name_len + 1);
for (p = s; *p; p++) {
if (*p == '/')
*p = '!';
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-27 9:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 9:57 [PATCH RESEND] block: Replace deprecated strcpy() in devt_from_devname() Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox