summaryrefslogtreecommitdiff
path: root/tools/perf/tests/attr.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2018-03-19 11:29:01 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-18 10:16:28 +0300
commitd0c9f9f9fb446e31b36d76e9a47001188f961a44 (patch)
treed7d7437b4e4da6b608ae9a078f437fd6a3133d14 /tools/perf/tests/attr.c
parent57bff812c4e2ca91a876f759198f2cd9e15967ad (diff)
downloadlinux-d0c9f9f9fb446e31b36d76e9a47001188f961a44.tar.xz
perf tools: Fix snprint warnings for gcc 8
commit 77f18153c080855e1c3fb520ca31a4e61530121d upstream. With gcc 8 we get new set of snprintf() warnings that breaks the compilation, one example: tests/mem.c: In function ‘check’: tests/mem.c:19:48: error: ‘%s’ directive output may be truncated writing \ up to 99 bytes into a region of size 89 [-Werror=format-truncation=] snprintf(failure, sizeof failure, "unexpected %s", out); The gcc docs says: To avoid the warning either use a bigger buffer or handle the function's return value which indicates whether or not its output has been truncated. Given that all these warnings are harmless, because the code either properly fails due to uncomplete file path or we don't care for truncated output at all, I'm changing all those snprintf() calls to scnprintf(), which actually 'checks' for the snprint return value so the gcc stays silent. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> Link: http://lkml.kernel.org/r/20180319082902.4518-1-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Ignat Korchagin <ignat@cloudflare.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/perf/tests/attr.c')
-rw-r--r--tools/perf/tests/attr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 0e1367f90af5..60fea0a376fc 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -164,8 +164,8 @@ static int run_dir(const char *d, const char *perf)
if (verbose > 0)
vcnt++;
- snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
- d, d, perf, vcnt, v);
+ scnprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
+ d, d, perf, vcnt, v);
return system(cmd) ? TEST_FAIL : TEST_OK;
}