Re: [PATCH net-next] net: rfkill: Replace strcpy with memcpy to improve rfkill_alloc
From: Johannes Berg
Date: Thu Jan 08 2026 - 08:14:12 EST
On Mon, 2025-12-15 at 13:20 +0100, Thorsten Blum wrote:
> 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.
>
> Use struct_size(), which provides additional compile-time checks for
> structures with flexible array members (e.g., __must_be_array()), to
> determine the allocation size for a new 'struct rfkill'.
TBH, I don't really see that this is a real _improvement_. I guess I'll
take it if you sell it as "let's not use deprecated strcpy" instead,
although even the documentation says "no new uses"...
johannes