Skip to content

Commit 9d6aae7

Browse files
committed
perf record: 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: builtin-record.c:659: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 423d856 commit 9d6aae7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tools/perf/builtin-record.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -655,22 +655,23 @@ record__finish_output(struct record *rec)
655655

656656
static int record__synthesize_workload(struct record *rec, bool tail)
657657
{
658-
struct {
659-
struct thread_map map;
660-
struct thread_map_data map_data;
661-
} thread_map;
658+
int err;
659+
struct thread_map *thread_map;
662660

663661
if (rec->opts.tail_synthesize != tail)
664662
return 0;
665663

666-
thread_map.map.nr = 1;
667-
thread_map.map.map[0].pid = rec->evlist->workload.pid;
668-
thread_map.map.map[0].comm = NULL;
669-
return perf_event__synthesize_thread_map(&rec->tool, &thread_map.map,
664+
thread_map = thread_map__new_by_tid(rec->evlist->workload.pid);
665+
if (thread_map == NULL)
666+
return -1;
667+
668+
err = perf_event__synthesize_thread_map(&rec->tool, thread_map,
670669
process_synthesized_event,
671670
&rec->session->machines.host,
672671
rec->opts.sample_address,
673672
rec->opts.proc_map_timeout);
673+
thread_map__put(thread_map);
674+
return err;
674675
}
675676

676677
static int record__synthesize(struct record *rec, bool tail);

0 commit comments

Comments
 (0)