Skip to content

Commit e0344f9

Browse files
Siddarth Grostedt
authored andcommitted
tracing: Replace strncpy with memcpy for fixed-length substring copy
checkpatch.pl reports the following warning: WARNING: Prefer strscpy, strscpy_pad, or __nonstring over strncpy (see: KSPP#90) In synth_field_string_size(), replace strncpy() with memcpy() to copy 'len' characters from 'start' to 'buf'. The code manually adds a NUL terminator after the copy, making memcpy safe here. Link: https://lore.kernel.org/20250325181232.38284-1-siddarthsgml@gmail.com Signed-off-by: Siddarth G <siddarthsgml@gmail.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 4d38328 commit e0344f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/trace/trace_events_synth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int synth_field_string_size(char *type)
207207
if (len == 0)
208208
return 0; /* variable-length string */
209209

210-
strncpy(buf, start, len);
210+
memcpy(buf, start, len);
211211
buf[len] = '\0';
212212

213213
err = kstrtouint(buf, 0, &size);

0 commit comments

Comments
 (0)