* [PATCH] tools: gpio: replace strncpy with strscpy
@ 2026-05-04 19:52 Lucas Poupeau
2026-05-04 20:18 ` Maxwell Doose
0 siblings, 1 reply; 7+ messages in thread
From: Lucas Poupeau @ 2026-05-04 19:52 UTC (permalink / raw)
To: linus.walleij, brgl; +Cc: linux-gpio, linux-kernel, Lucas Poupeau
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@gmail.com>
---
tools/gpio/gpio-utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c
index 4096bcd511d1..d5d194be7cc2 100644
--- a/tools/gpio/gpio-utils.c
+++ b/tools/gpio/gpio-utils.c
@@ -82,7 +82,7 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,
req.offsets[i] = lines[i];
req.config = *config;
- strcpy(req.consumer, consumer);
+ strscpy(req.consumer, consumer);
req.num_lines = num_lines;
ret = ioctl(fd, GPIO_V2_GET_LINE_IOCTL, &req);
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] tools: gpio: replace strncpy with strscpy
2026-05-04 19:52 [PATCH] tools: gpio: replace strncpy with strscpy Lucas Poupeau
@ 2026-05-04 20:18 ` Maxwell Doose
[not found] ` <CAKYXYMRX-oV6iO+Kh+dV7_2BfsY9gjdXMw6cueOgYw2hjLWeaQ@mail.gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Maxwell Doose @ 2026-05-04 20:18 UTC (permalink / raw)
To: Lucas Poupeau, linus.walleij, brgl; +Cc: linux-gpio, linux-kernel
Hi Lucas,
On Mon, May 4, 2026 at 2:53 PM Lucas Poupeau <lucasp.linux@gmail.com> 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@gmail.com>
> ---
> 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@gmail.com>).
best regards,
max
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools: gpio: replace strncpy with strscpy
[not found] ` <CAKYXYMRX-oV6iO+Kh+dV7_2BfsY9gjdXMw6cueOgYw2hjLWeaQ@mail.gmail.com>
@ 2026-05-04 20:54 ` Maxwell Doose
2026-05-04 21:00 ` Maxwell Doose
0 siblings, 1 reply; 7+ messages in thread
From: Maxwell Doose @ 2026-05-04 20:54 UTC (permalink / raw)
To: Lucas; +Cc: linus.walleij, brgl, linux-gpio, linux-kernel
Hi Lucas,
On Mon, May 4, 2026 at 3:34 PM Lucas <lucasp.linux@gmail.com> wrote:
>
> Hi Max,
>
> Thank you for your review and your kind words!
>
> I will follow your recommendations and send a v2 shortly. I'll make sure
> to update the function call to include the destination buffer size, and
> I'll also correct the commit message and subject as you pointed out.
>
> I'll include your "Reviewed-by" tag in the new version.
>
> Best regards,
> Lucas
>
Actually, timeout, I'm not sure if strscpy() is allowed in tools/. I'm
going to double-check and I'll let you know if it is.
best regards,
max
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools: gpio: replace strncpy with strscpy
2026-05-04 20:54 ` Maxwell Doose
@ 2026-05-04 21:00 ` Maxwell Doose
[not found] ` <CAKYXYMQQ2UxLJw=2O2y=fLL6Kpp3eUiaH7Rx4MF5H7wcoYzcLQ@mail.gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Maxwell Doose @ 2026-05-04 21:00 UTC (permalink / raw)
To: Lucas; +Cc: linus.walleij, brgl, linux-gpio, linux-kernel
On Mon, May 4, 2026 at 3:54 PM Maxwell Doose <m32285159@gmail.com> wrote:
>
> Hi Lucas,
>
> On Mon, May 4, 2026 at 3:34 PM Lucas <lucasp.linux@gmail.com> wrote:
> >
> > Hi Max,
> >
> > Thank you for your review and your kind words!
> >
> > I will follow your recommendations and send a v2 shortly. I'll make sure
> > to update the function call to include the destination buffer size, and
> > I'll also correct the commit message and subject as you pointed out.
> >
> > I'll include your "Reviewed-by" tag in the new version.
> >
> > Best regards,
> > Lucas
> >
>
> Actually, timeout, I'm not sure if strscpy() is allowed in tools/. I'm
> going to double-check and I'll let you know if it is.
>
> best regards,
> max
Alright, just checked tools/include/linux/string.h, this can't be done
unfortunately. I like the idea though, perhaps you should submit a
patch adding strscpy there.
best regards,
max
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools: gpio: replace strncpy with strscpy
[not found] ` <CAKYXYMQQ2UxLJw=2O2y=fLL6Kpp3eUiaH7Rx4MF5H7wcoYzcLQ@mail.gmail.com>
@ 2026-05-04 21:14 ` Maxwell Doose
2026-05-05 10:57 ` Bartosz Golaszewski
0 siblings, 1 reply; 7+ messages in thread
From: Maxwell Doose @ 2026-05-04 21:14 UTC (permalink / raw)
To: Lucas; +Cc: linus.walleij, brgl, linux-gpio, linux-kernel
On Mon, May 4, 2026 at 4:05 PM Lucas <lucasp.linux@gmail.com> wrote:
>
> That's a great suggestion! I would love to try adding strscpy to tools/include/linux/string.h.
>
> It might take me a little more time than a simple cleanup as I need to make sure I don't break the tools build, but I'll work on it and send a patch as soon as it's ready.
>
> Thanks for the guidance!
>
> Best regards, Lucas
>
Of course, but again, don't send html email or top-post, read the
mailing list etiquette at https://subspace.kernel.org/etiquette.html.
best regards,
max
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools: gpio: replace strncpy with strscpy
2026-05-04 21:14 ` Maxwell Doose
@ 2026-05-05 10:57 ` Bartosz Golaszewski
2026-05-05 13:15 ` Maxwell Doose
0 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2026-05-05 10:57 UTC (permalink / raw)
To: Maxwell Doose; +Cc: Lucas, linus.walleij, linux-gpio, linux-kernel
On Mon, May 4, 2026 at 11:14 PM Maxwell Doose <m32285159@gmail.com> wrote:
>
> On Mon, May 4, 2026 at 4:05 PM Lucas <lucasp.linux@gmail.com> wrote:
> >
> > That's a great suggestion! I would love to try adding strscpy to tools/include/linux/string.h.
> >
> > It might take me a little more time than a simple cleanup as I need to make sure I don't break the tools build, but I'll work on it and send a patch as soon as it's ready.
> >
> > Thanks for the guidance!
> >
> > Best regards, Lucas
> >
>
> Of course, but again, don't send html email or top-post, read the
> mailing list etiquette at https://subspace.kernel.org/etiquette.html.
>
> best regards,
> max
Are you guys two AI bots just talking nonsense to each other? This is
a user-space tool, there's no strscpy() in libc...
Reading this was a waste of two minutes I'm not getting back.
Bart
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools: gpio: replace strncpy with strscpy
2026-05-05 10:57 ` Bartosz Golaszewski
@ 2026-05-05 13:15 ` Maxwell Doose
0 siblings, 0 replies; 7+ messages in thread
From: Maxwell Doose @ 2026-05-05 13:15 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: Lucas, linus.walleij, linux-gpio, linux-kernel
On Tue, May 5, 2026 at 5:57 AM Bartosz Golaszewski <brgl@kernel.org> wrote:
>
> Are you guys two AI bots just talking nonsense to each other? This is
> a user-space tool, there's no strscpy() in libc...
>
> Reading this was a waste of two minutes I'm not getting back.
>
??
No, some confusion arised as I'm typically working in iio and gpio.
I'm more used to having strscpy() readily available and thought that
not having strscpy() in the tools-specific libraries was strange. But
the stupid thing is that it was aliased to strcpy in
tools/include/linux/string.h (#define strscpy strcpy). I'm sorry, but
we really need to at least get that macro removed, it's pretty
precarious. Besides, we're not trying to change glibc, we're just
trying to move in the latest and much safer function...
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-05-05 13:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 19:52 [PATCH] tools: gpio: replace strncpy with strscpy Lucas Poupeau
2026-05-04 20:18 ` Maxwell Doose
[not found] ` <CAKYXYMRX-oV6iO+Kh+dV7_2BfsY9gjdXMw6cueOgYw2hjLWeaQ@mail.gmail.com>
2026-05-04 20:54 ` Maxwell Doose
2026-05-04 21:00 ` Maxwell Doose
[not found] ` <CAKYXYMQQ2UxLJw=2O2y=fLL6Kpp3eUiaH7Rx4MF5H7wcoYzcLQ@mail.gmail.com>
2026-05-04 21:14 ` Maxwell Doose
2026-05-05 10:57 ` Bartosz Golaszewski
2026-05-05 13:15 ` Maxwell Doose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox