[PATCH] tools: gpio: replace strncpy with strscpy
From: Lucas Poupeau
Date: Mon May 04 2026 - 15:59:26 EST
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(-)
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