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

From: David Laight

Date: Wed Aug 19 2026 - 06:15:45 EST


On Tue, 18 Aug 2026 13:56:06 -0400
Alex Deucher <alexdeucher@xxxxxxxxx> wrote:

> On Tue, Aug 18, 2026 at 1:51 PM Amin <amin.gattout@xxxxxxxxx> 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