summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2024-04-03 16:44:19 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2024-04-03 23:05:19 +0200
commitb6347cb5e04e9c1d17342ab46e2ace2d448de727 (patch)
treec9237ab52e841b7b8e5f9d99a4b5a3cfe427a7c3 /tools/perf/util/annotate.c
parentperf build: Add LIBTRACEEVENT_DIR build option (diff)
downloadlinux-b6347cb5e04e9c1d17342ab46e2ace2d448de727.tar.xz
linux-b6347cb5e04e9c1d17342ab46e2ace2d448de727.zip
perf annotate: Initialize 'arch' variable not to trip some -Werror=maybe-uninitialized
In some older distros the build is failing due to -Werror=maybe-uninitialized, in this case we know that this isn't the case because 'arch' gets initialized by evsel__get_arch(), so make sure it is initialized to NULL before returning from evsel__get_arch(), as suggested by Ian Rogers. E.g.: 32 17.12 opensuse:15.5 : FAIL gcc version 7.5.0 (SUSE Linux) util/annotate.c: In function 'hist_entry__get_data_type': util/annotate.c:2269:15: error: 'arch' may be used uninitialized in this function [-Werror=maybe-uninitialized] struct arch *arch; ^~~~ cc1: all warnings being treated as errors 43 7.30 ubuntu:18.04-x-powerpc64el : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) util/annotate.c: In function 'hist_entry__get_data_type': util/annotate.c:2351:36: error: 'arch' may be used uninitialized in this function [-Werror=maybe-uninitialized] if (map__dso(ms->map)->kernel && arch__is(arch, "x86") && ^~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Suggested-by: Ian Rogers <irogers@google.com> Reviewed-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/lkml/CAP-5=fUqtjxAsmdGrnkjhUTLHs-JvV10TtxyocpYDJK_+LYTiQ@mail.gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index b795f27f2602..35235147b111 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -838,8 +838,10 @@ static int evsel__get_arch(struct evsel *evsel, struct arch **parch)
struct arch *arch;
int err;
- if (!arch_name)
+ if (!arch_name) {
+ *parch = NULL;
return errno;
+ }
*parch = arch = arch__find(arch_name);
if (arch == NULL) {