Skip to content

Commit 8989605

Browse files
committed
perf tools: Do not put a variable sized type not at the end of a struct
As this is a GNU extension and while harmless in this case, we can do the same thing in a more clearer way by using an existing thread_map constructor. With this we avoid this while compiling with clang: util/parse-events.c:2024:21: error: field 'map' with variable sized type 'struct thread_map' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end] struct thread_map map; ^ 1 error generated. Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 9d6aae7 commit 8989605

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tools/perf/util/parse-events.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,17 +2020,14 @@ static bool is_event_supported(u8 type, unsigned config)
20202020
.config = config,
20212021
.disabled = 1,
20222022
};
2023-
struct {
2024-
struct thread_map map;
2025-
int threads[1];
2026-
} tmap = {
2027-
.map.nr = 1,
2028-
.threads = { 0 },
2029-
};
2023+
struct thread_map *tmap = thread_map__new_by_tid(0);
2024+
2025+
if (tmap == NULL)
2026+
return false;
20302027

20312028
evsel = perf_evsel__new(&attr);
20322029
if (evsel) {
2033-
open_return = perf_evsel__open(evsel, NULL, &tmap.map);
2030+
open_return = perf_evsel__open(evsel, NULL, tmap);
20342031
ret = open_return >= 0;
20352032

20362033
if (open_return == -EACCES) {
@@ -2042,7 +2039,7 @@ static bool is_event_supported(u8 type, unsigned config)
20422039
*
20432040
*/
20442041
evsel->attr.exclude_kernel = 1;
2045-
ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
2042+
ret = perf_evsel__open(evsel, NULL, tmap) >= 0;
20462043
}
20472044
perf_evsel__delete(evsel);
20482045
}

0 commit comments

Comments
 (0)