]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf/core: Remove optional 'size' arguments from strscpy() calls
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 10 Mar 2025 19:23:35 +0000 (20:23 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 10 Mar 2025 19:50:30 +0000 (20:50 +0100)
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

index f159dbab45300fcadffcdc060727fd61f2b2ebb4..e7d0b055f96c77cbcf81bf44230c9d325613b5e7 100644 (file)
@@ -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';