Re: [PATCH] tools: gpio: replace strncpy with strscpy

From: Maxwell Doose

Date: Mon May 04 2026 - 16:19:06 EST


Hi Lucas,

On Mon, May 4, 2026 at 2:53 PM Lucas Poupeau <lucasp.linux@xxxxxxxxx> wrote:
>
> Replace strncpy with strscpy in gpio-utils.c. strscpy is the preferred
> way to copy strings in the kernel as it guarantees NUL-termination and
> is more robust.
>
> Reported by checkpatch.pl.
>
> Signed-off-by: Lucas Poupeau <lucasp.linux@xxxxxxxxx>
> ---
>  tools/gpio/gpio-utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
[snip]

There's already someone working on this:

https://lore.kernel.org/linux-gpio/20260504134532.0438e390@pumpkin/

but to be honest this one is much better than that one. Just some quick
recommendations, please change:

>+ strscpy(req.consumer, consumer);

to be something like:

strscpy(req.consumer, consumer, sizeof(req.consumer));

Also, please double check the commit message and subject (says strncpy,
should be strcpy). Once you fix those issues feel free to add my
reviewed-by (Reviewed-by: Maxwell Doose <m32285159@xxxxxxxxx>).

best regards,
max