Skip to content

Commit

Permalink
perf record: Do not put a variable sized type not at the end of a struct
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
acmel committed Feb 14, 2017
1 parent 423d856 commit 9d6aae7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,22 +655,23 @@ record__finish_output(struct record *rec)

static int record__synthesize_workload(struct record *rec, bool tail)
{
struct {
struct thread_map map;
struct thread_map_data map_data;
} thread_map;
int err;
struct thread_map *thread_map;

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

thread_map.map.nr = 1;
thread_map.map.map[0].pid = rec->evlist->workload.pid;
thread_map.map.map[0].comm = NULL;
return perf_event__synthesize_thread_map(&rec->tool, &thread_map.map,
thread_map = thread_map__new_by_tid(rec->evlist->workload.pid);
if (thread_map == NULL)
return -1;

err = perf_event__synthesize_thread_map(&rec->tool, thread_map,
process_synthesized_event,
&rec->session->machines.host,
rec->opts.sample_address,
rec->opts.proc_map_timeout);
thread_map__put(thread_map);
return err;
}

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

0 comments on commit 9d6aae7

Please sign in to comment.