From: Ian Rogers Date: Mon, 24 Jul 2023 20:12:45 +0000 (-0700) Subject: perf parse-events: Avoid use uninitialized warning X-Git-Tag: v6.6.17~3940^2~205 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f97a3a0deccece93797cd35ba1c18704e94b7e7;p=platform%2Fkernel%2Flinux-rpi.git perf parse-events: Avoid use uninitialized warning With GCC LTO a potential use uninitialized is spotted: ``` In function ‘parse_events_config_bpf’, inlined from ‘parse_events_load_bpf’ at util/parse-events.c:874:8: util/parse-events.c:792:37: error: ‘error_pos’ may be used uninitialized [-Werror=maybe-uninitialized] 792 | idx = term->err_term + error_pos; | ^ util/parse-events.c: In function ‘parse_events_load_bpf’: util/parse-events.c:765:13: note: ‘error_pos’ was declared here 765 | int error_pos; | ^ ``` So initialize at declaration. Reviewed-by: Nick Desaulniers Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Carsten Haitzler Cc: Fangrui Song Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: Tom Rix Cc: Xing Zhengjun Cc: Yang Jihong Cc: bpf@vger.kernel.org Cc: llvm@lists.linux.dev Link: https://lore.kernel.org/r/20230724201247.748146-3-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index acde097..da29061 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -762,7 +762,7 @@ parse_events_config_bpf(struct parse_events_state *parse_state, struct list_head *head_config) { struct parse_events_term *term; - int error_pos; + int error_pos = 0; if (!head_config || list_empty(head_config)) return 0;