mirror-linux/tools/perf/ui/browsers
James Clark f2195c5b43 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: ad83f3b715 ("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>
2025-10-23 14:28:58 -07:00
..
Build perf ui: Make ui its own library 2024-06-26 11:06:34 -07:00
annotate-data.c perf ui browser annotate-data: Provide feedback on unhandled hotkeys 2025-04-10 10:45:48 -03:00
annotate.c perf annotate: Fix Clang build by adding block in switch case 2025-10-23 14:28:58 -07:00
header.c perf evlist: Change env variable to session 2025-07-25 10:37:56 -07:00
hists.c perf c2c annotate: Start from the contention line 2025-10-19 12:50:07 +09:00
hists.h perf ui/browser/annotate: Use global annotation_options 2023-12-07 17:18:06 -03:00
map.c perf ui browser map: Provide feedback on unhandled hotkeys 2025-04-10 10:46:26 -03:00
map.h
res_sample.c perf: script: prefer capstone to XED 2024-02-20 18:07:34 -08:00
scripts.c perf ui scripts: Switch FILENAME_MAX to NAME_MAX 2025-07-22 18:17:53 -07:00