* [PATCH] perf tools: Replace strlcpy with strscpy
@ 2025-12-09 12:59 ny
2026-01-13 20:06 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: ny @ 2025-12-09 12:59 UTC (permalink / raw)
To: acme; +Cc: peterz, mingo, linux-kernel, ny
Replace the deprecated strlcpy function with the preferred strscpy
function in tools/perf/util/machine.c.
strlcpy is deprecated and should be replaced with strscpy according
to kernel best practices. The strscpy function is safer and is the
recommended replacement.
Signed-off-by: ny <nygameemail@163.com>
---
tools/perf/util/machine.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 841b711d9..8786764e2 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1052,7 +1052,7 @@ int machine__create_extra_kernel_map(struct machine *machine,
kmap = map__kmap(map);
- strlcpy(kmap->name, xm->name, KMAP_NAME_LEN);
+ strscpy(kmap->name, xm->name, KMAP_NAME_LEN);
err = maps__insert(machine__kernel_maps(machine), map);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf tools: Replace strlcpy with strscpy
2025-12-09 12:59 [PATCH] perf tools: Replace strlcpy with strscpy ny
@ 2026-01-13 20:06 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-01-13 20:06 UTC (permalink / raw)
To: ny; +Cc: peterz, mingo, linux-kernel
On Tue, Dec 09, 2025 at 12:59:15PM +0000, ny wrote:
> Replace the deprecated strlcpy function with the preferred strscpy
> function in tools/perf/util/machine.c.
>
> strlcpy is deprecated and should be replaced with strscpy according
> to kernel best practices. The strscpy function is safer and is the
> recommended replacement.
Take a look at this:
acme@number:~/git/perf-tools-next$ git grep strscpy tools/
tools/include/linux/string.h:#define strscpy strcpy
tools/testing/selftests/net/ovpn/ovpn-cli.c:#define strscpy strncpy
tools/testing/selftests/net/ovpn/ovpn-cli.c: strscpy(ovpn->ifname, argv[2], IFNAMSIZ - 1);
tools/testing/selftests/user_events/abi_test.c: /* strscpy is not available, use snprintf */
acme@number:~/git/perf-tools-next$
:-)
srcscpy() thus seems to be only available in the kernel sources, not for
tools/, that would be another project.
- Arnaldo
> Signed-off-by: ny <nygameemail@163.com>
> ---
> tools/perf/util/machine.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 841b711d9..8786764e2 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1052,7 +1052,7 @@ int machine__create_extra_kernel_map(struct machine *machine,
>
> kmap = map__kmap(map);
>
> - strlcpy(kmap->name, xm->name, KMAP_NAME_LEN);
> + strscpy(kmap->name, xm->name, KMAP_NAME_LEN);
>
> err = maps__insert(machine__kernel_maps(machine), map);
>
> --
> 2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-13 20:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-09 12:59 [PATCH] perf tools: Replace strlcpy with strscpy ny
2026-01-13 20:06 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.