Skip to content

Commit f2195c5

Browse files
james-c-linaronamhyung
authored andcommitted
perf annotate: Fix Clang build by adding block in switch case
Clang and GCC disagree with what constitutes a "declaration after statement". GCC allows declarations in switch cases without an extra block, as long as it's immediately after the label. Clang does not. Unfortunately this is the case even in the latest versions of both compilers. The only option that makes them behave in the same way is -Wpedantic, which can't be enabled in Perf because of the number of warnings it generates. Add a block to fix the Clang build, which is the only thing we can do. Fixes the build error: ui/browsers/annotate.c:999:4: error: expected expression struct annotation_line *al = NULL; ui/browsers/annotate.c:1008:4: error: use of undeclared identifier 'al' al = annotated_source__get_line(notes->src, offset); ui/browsers/annotate.c:1009:24: error: use of undeclared identifier 'al' browser->curr_hot = al ? &al->rb_node : NULL; ui/browsers/annotate.c:1009:30: error: use of undeclared identifier 'al' browser->curr_hot = al ? &al->rb_node : NULL; ui/browsers/annotate.c:1000:8: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] s64 offset = annotate_browser__curr_hot_offset(browser); Fixes: ad83f3b ("perf c2c annotate: Start from the contention line") Signed-off-by: James Clark <james.clark@linaro.org> Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent a1d8548 commit f2195c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/perf/ui/browsers/annotate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
995995
case 'H':
996996
nd = browser->curr_hot;
997997
break;
998-
case 's':
998+
case 's': {
999999
struct annotation_line *al = NULL;
10001000
s64 offset = annotate_browser__curr_hot_offset(browser);
10011001

@@ -1012,6 +1012,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
10121012
annotate__scnprintf_title(hists, title, sizeof(title));
10131013
annotate_browser__show(browser, title, help);
10141014
continue;
1015+
}
10151016
case 'o':
10161017
annotate_opts.use_offset = !annotate_opts.use_offset;
10171018
annotation__update_column_widths(notes);

0 commit comments

Comments
 (0)