Re: [PATCH] drm/amdgpu: Replace deprecated strcpy with strscpy

David Laight <[email protected]>
Newsgroups org.freedesktop.lists.amd-gfx,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Message-ID <20260819111248.29286a7c@pumpkin>
On Tue, 18 Aug 2026 13:56:06 -0400
Alex Deucher <[email protected]> wrote:

> On Tue, Aug 18, 2026 at 1:51 PM Amin <[email protected]> wrote:
> >
> > You raise a fair point about the compile-time truncation check.
> > My reasoning follows the kernel's own deprecation guidance, which
> > explicitly lists strcpy() as deprecated and names strscpy() as the
> > safe replacement:
> >
> > https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy  
> 
> RIght.  My thinking was that strscpy() would be preferred to avoid
> static checkers from complaining about strcpy().

Personally I think the guidance (and checkpatch) should be changed.
It is pretty easy to change the header files to only allow safe
strcpy().
If nothing else that reduces pointless churn that just makes more
work for the maintainers.

There are plenty of strcpy() and strlcat() calls that are 'not obviously
correctly bounded' (and probably some strscpy() ones as well) which are
better targets for patches than the ones that are trivially valid.

David 

> 
> Alex
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.