Skip to content

Commit 07d6f72

Browse files
acmelgregkh
authored andcommitted
perf help: Remove needless use of strncpy()
commit b631389 upstream. Since we make sure the destination buffer has at least strlen(orig) + 1, no need to do a strncpy(dest, orig, strlen(orig)), just use strcpy(dest, orig). This silences this gcc 8.2 warning on Alpine Linux: In function 'add_man_viewer', inlined from 'perf_help_config' at builtin-help.c:284:3: builtin-help.c:192:2: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] strncpy((*p)->name, name, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ builtin-help.c: In function 'perf_help_config': builtin-help.c:187:15: note: length computed here size_t len = strlen(name); ^~~~~~~~~~~~ Cc: Adrian Hunter <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Fixes: 0780060 ("perf_counter tools: add in basic glue from Git") Link: https://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 948475f commit 07d6f72

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/builtin-help.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static void add_man_viewer(const char *name)
186186
while (*p)
187187
p = &((*p)->next);
188188
*p = zalloc(sizeof(**p) + len + 1);
189-
strncpy((*p)->name, name, len);
189+
strcpy((*p)->name, name);
190190
}
191191

192192
static int supported_man_viewer(const char *name, size_t len)

0 commit comments

Comments
 (0)