Linux wireless drivers development
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: rfkill: Replace strcpy with memcpy to improve rfkill_alloc
Date: Fri, 20 Feb 2026 18:00:00 +0100	[thread overview]
Message-ID: <86C8A63A-E72F-48C9-A1C0-4E65A91CA987@linux.dev> (raw)
In-Reply-To: <6983492c92a811b45c27bc36337e16fbd1abd94f.camel@sipsolutions.net>

On 8. Jan 2026, at 13:29, Johannes Berg wrote:
> 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"...

Yes, this is primarily a refactoring to avoid deprecated strcpy(), and
to harden the code by using struct_size().

Thanks,
Thorsten


      reply	other threads:[~2026-02-20 17:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 12:20 [PATCH net-next] net: rfkill: Replace strcpy with memcpy to improve rfkill_alloc Thorsten Blum
2026-01-08 12:29 ` Johannes Berg
2026-02-20 17:00   ` Thorsten Blum [this message]

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=86C8A63A-E72F-48C9-A1C0-4E65A91CA987@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox