public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] perf annotate: Initialize 'arch' variable not to trip some -Werror=maybe-uninitialized
@ 2024-04-03 15:16 Arnaldo Carvalho de Melo
  2024-04-03 16:01 ` Ian Rogers
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-04-03 15:16 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Adrian Hunter, Ian Rogers, Jiri Olsa, Linux Kernel Mailing List

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 just init
it to NULL to silence those cases.

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

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index b795f27f26024f35..f316e0b65897957a 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2266,7 +2266,7 @@ struct annotated_data_type *hist_entry__get_data_type(struct hist_entry *he)
 {
 	struct map_symbol *ms = &he->ms;
 	struct evsel *evsel = hists_to_evsel(he->hists);
-	struct arch *arch;
+	struct arch *arch = NULL;
 	struct disasm_line *dl;
 	struct annotated_insn_loc loc;
 	struct annotated_op_loc *op_loc;
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-03 22:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-03 15:16 [PATCH 1/1] perf annotate: Initialize 'arch' variable not to trip some -Werror=maybe-uninitialized Arnaldo Carvalho de Melo
2024-04-03 16:01 ` Ian Rogers
2024-04-03 19:52   ` Arnaldo Carvalho de Melo
2024-04-03 20:15     ` Namhyung Kim
2024-04-03 21:03   ` Arnaldo Carvalho de Melo
2024-04-03 22:01     ` Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox