From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933477AbdBPUCS (ORCPT ); Thu, 16 Feb 2017 15:02:18 -0500 Received: from terminus.zytor.com ([65.50.211.136]:48944 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932694AbdBPUCR (ORCPT ); Thu, 16 Feb 2017 15:02:17 -0500 Date: Thu, 16 Feb 2017 12:02:01 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: namhyung@kernel.org, wangnan0@huawei.com, hpa@zytor.com, tglx@linutronix.de, acme@redhat.com, linux-kernel@vger.kernel.org, dsahern@gmail.com, jolsa@kernel.org, adrian.hunter@intel.com, mingo@kernel.org Reply-To: wangnan0@huawei.com, namhyung@kernel.org, acme@redhat.com, hpa@zytor.com, tglx@linutronix.de, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, dsahern@gmail.com, jolsa@kernel.org, mingo@kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf record: Do not put a variable sized type not at the end of a struct Git-Commit-ID: 9d6aae725454beada044179f1005c8f8c206dd6a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 9d6aae725454beada044179f1005c8f8c206dd6a Gitweb: http://git.kernel.org/tip/9d6aae725454beada044179f1005c8f8c206dd6a Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 14 Feb 2017 10:59:04 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 14 Feb 2017 15:19:19 -0300 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 Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-c9drclo52ezxmwa7qxklin2y@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 2ddf189..6cd6776 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -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);