Skip to content

Commit fd3f5d3

Browse files
tobluxIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7a310c6 commit fd3f5d3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/events/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8665,7 +8665,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
86658665
unsigned int size;
86668666

86678667
memset(comm, 0, sizeof(comm));
8668-
strscpy(comm, comm_event->task->comm, sizeof(comm));
8668+
strscpy(comm, comm_event->task->comm);
86698669
size = ALIGN(strlen(comm)+1, sizeof(u64));
86708670

86718671
comm_event->comm = comm;
@@ -9109,7 +9109,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
91099109
}
91109110

91119111
cpy_name:
9112-
strscpy(tmp, name, sizeof(tmp));
9112+
strscpy(tmp, name);
91139113
name = tmp;
91149114
got_name:
91159115
/*
@@ -9533,7 +9533,7 @@ void perf_event_ksymbol(u16 ksym_type, u64 addr, u32 len, bool unregister,
95339533
ksym_type == PERF_RECORD_KSYMBOL_TYPE_UNKNOWN)
95349534
goto err;
95359535

9536-
strscpy(name, sym, KSYM_NAME_LEN);
9536+
strscpy(name, sym);
95379537
name_len = strlen(name) + 1;
95389538
while (!IS_ALIGNED(name_len, sizeof(u64)))
95399539
name[name_len++] = '\0';

0 commit comments

Comments
 (0)