tools/gpio/gpio-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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
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
© 2016 - 2026 Red Hat, Inc.