* [PATCH] perf/core: Remove size arguments when calling strscpy()
@ 2025-03-10 19:23 Thorsten Blum
2025-03-10 19:59 ` [tip: perf/core] perf/core: Remove optional 'size' arguments from strscpy() calls tip-bot2 for Thorsten Blum
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-03-10 19:23 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan
Cc: Thorsten Blum, linux-perf-users, linux-kernel
The size parameter is optional and strscpy() automatically determines
the length of the destination buffer using sizeof() if the argument is
omitted. This makes the explicit sizeof() calls unnecessary.
Furthermore, KSYM_NAME_LEN is equal to sizeof(name) and can also be
removed. Remove them to shorten and simplify the code.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
kernel/events/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 823aa0824916..e4b071fc7d74 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8589,7 +8589,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
unsigned int size;
memset(comm, 0, sizeof(comm));
- strscpy(comm, comm_event->task->comm, sizeof(comm));
+ strscpy(comm, comm_event->task->comm);
size = ALIGN(strlen(comm)+1, sizeof(u64));
comm_event->comm = comm;
@@ -9033,7 +9033,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
}
cpy_name:
- strscpy(tmp, name, sizeof(tmp));
+ strscpy(tmp, name);
name = tmp;
got_name:
/*
@@ -9457,7 +9457,7 @@ void perf_event_ksymbol(u16 ksym_type, u64 addr, u32 len, bool unregister,
ksym_type == PERF_RECORD_KSYMBOL_TYPE_UNKNOWN)
goto err;
- strscpy(name, sym, KSYM_NAME_LEN);
+ strscpy(name, sym);
name_len = strlen(name) + 1;
while (!IS_ALIGNED(name_len, sizeof(u64)))
name[name_len++] = '\0';
--
2.48.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tip: perf/core] perf/core: Remove optional 'size' arguments from strscpy() calls
2025-03-10 19:23 [PATCH] perf/core: Remove size arguments when calling strscpy() Thorsten Blum
@ 2025-03-10 19:59 ` tip-bot2 for Thorsten Blum
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Thorsten Blum @ 2025-03-10 19:59 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thorsten Blum, Ingo Molnar, x86, linux-kernel
The following commit has been merged into the perf/core branch of tip:
Commit-ID: fd3f5d385a52531589c8a7a26d9e108aa1d3f52e
Gitweb: https://git.kernel.org/tip/fd3f5d385a52531589c8a7a26d9e108aa1d3f52e
Author: Thorsten Blum <thorsten.blum@linux.dev>
AuthorDate: Mon, 10 Mar 2025 20:23:35 +01:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 10 Mar 2025 20:50:30 +01:00
perf/core: Remove optional 'size' arguments from strscpy() calls
The 'size' parameter is optional and strscpy() automatically determines
the length of the destination buffer using sizeof() if the argument is
omitted. This makes the explicit sizeof() calls unnecessary.
Furthermore, KSYM_NAME_LEN is equal to sizeof(name) and can also be
removed. Remove them to shorten and simplify the code.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250310192336.442994-1-thorsten.blum@linux.dev
---
kernel/events/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f159dba..e7d0b05 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8665,7 +8665,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
unsigned int size;
memset(comm, 0, sizeof(comm));
- strscpy(comm, comm_event->task->comm, sizeof(comm));
+ strscpy(comm, comm_event->task->comm);
size = ALIGN(strlen(comm)+1, sizeof(u64));
comm_event->comm = comm;
@@ -9109,7 +9109,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
}
cpy_name:
- strscpy(tmp, name, sizeof(tmp));
+ strscpy(tmp, name);
name = tmp;
got_name:
/*
@@ -9533,7 +9533,7 @@ void perf_event_ksymbol(u16 ksym_type, u64 addr, u32 len, bool unregister,
ksym_type == PERF_RECORD_KSYMBOL_TYPE_UNKNOWN)
goto err;
- strscpy(name, sym, KSYM_NAME_LEN);
+ strscpy(name, sym);
name_len = strlen(name) + 1;
while (!IS_ALIGNED(name_len, sizeof(u64)))
name[name_len++] = '\0';
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-10 19:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-10 19:23 [PATCH] perf/core: Remove size arguments when calling strscpy() Thorsten Blum
2025-03-10 19:59 ` [tip: perf/core] perf/core: Remove optional 'size' arguments from strscpy() calls tip-bot2 for Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®