summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/jitdump.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-10-13 22:12:35 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-10-24 16:07:36 +0200
commitef2c3e76d98dfb69a46d870b47656e8e5bac6e2b (patch)
tree4d44c261089d351d18b44cc11542e7ce9b5a3473 /tools/perf/util/jitdump.c
parentperf tools: Implement branch_type event parameter (diff)
downloadlinux-ef2c3e76d98dfb69a46d870b47656e8e5bac6e2b.tar.xz
linux-ef2c3e76d98dfb69a46d870b47656e8e5bac6e2b.zip
perf jit: Avoid returning garbage for a ret variable
When the loop body isn't executed at all, then the 'ret' local variable, that is uninitialized will be used as the return value. This triggers this error on Alpine Linux: CC /tmp/build/perf/util/demangle-java.o CC /tmp/build/perf/util/demangle-rust.o CC /tmp/build/perf/util/jitdump.o CC /tmp/build/perf/util/genelf.o util/jitdump.c: In function 'jit_process': util/jitdump.c:622:3: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized] fprintf(stderr, "injected: %s (%d)\n", path, ret); ^ util/jitdump.c:584:6: note: 'ret' was declared here int ret; ^ FLEX /tmp/build/perf/util/parse-events-flex.c / $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/5.3.0/lto-wrapper Target: x86_64-alpine-linux-musl Configured with: /home/buildozer/aports/main/gcc/src/gcc-5.3.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info +--build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 5.3.0' --enable-checking=release +--disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-esp +--enable-cloog-backend --enable-languages=c,c++,objc,java,fortran,ada --disable-libssp --disable-libmudflap --disable-libsanitizer --enable-shared +--enable-threads --enable-tls --with-system-zlib Thread model: posix gcc version 5.3.0 (Alpine 5.3.0) But this so far got under the radar, not causing any build problem, till the "perf jit: enable jitdump support without dwarf" gets applied, when the above problem takes place, some combination of inlining or whatever, the problem is real, so fix it by initializing the variable to zero. Cc: Anton Blanchard <anton@ozlabs.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Maciej Debski <maciejd@google.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: https://lkml.kernel.org/r/20161013200437.GA12815@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/jitdump.c')
-rw-r--r--tools/perf/util/jitdump.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
index 95f0884aae02..f3ed3c963c71 100644
--- a/tools/perf/util/jitdump.c
+++ b/tools/perf/util/jitdump.c
@@ -581,7 +581,7 @@ static int
jit_process_dump(struct jit_buf_desc *jd)
{
union jr_entry *jr;
- int ret;
+ int ret = 0;
while ((jr = jit_get_next_entry(jd))) {
switch(jr->prefix.id) {