From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933201AbdBPUCp (ORCPT ); Thu, 16 Feb 2017 15:02:45 -0500 Received: from terminus.zytor.com ([65.50.211.136]:48982 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932761AbdBPUCn (ORCPT ); Thu, 16 Feb 2017 15:02:43 -0500 Date: Thu, 16 Feb 2017 12:02:30 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: acme@redhat.com, dsahern@gmail.com, hpa@zytor.com, namhyung@kernel.org, mingo@kernel.org, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, wangnan0@huawei.com, jolsa@kernel.org, tglx@linutronix.de Reply-To: dsahern@gmail.com, acme@redhat.com, namhyung@kernel.org, hpa@zytor.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, mingo@kernel.org, wangnan0@huawei.com, jolsa@kernel.org, tglx@linutronix.de To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Do not put a variable sized type not at the end of a struct Git-Commit-ID: 89896051f8dae5a04ada1f5fbeeaedc23f484f68 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: 89896051f8dae5a04ada1f5fbeeaedc23f484f68 Gitweb: http://git.kernel.org/tip/89896051f8dae5a04ada1f5fbeeaedc23f484f68 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 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 Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-tqocbplnyyhpst6drgm2u4m3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 07be076..281e44a 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2020,17 +2020,14 @@ static bool is_event_supported(u8 type, unsigned config) .config = config, .disabled = 1, }; - struct { - struct thread_map map; - int threads[1]; - } tmap = { - .map.nr = 1, - .threads = { 0 }, - }; + struct thread_map *tmap = thread_map__new_by_tid(0); + + if (tmap == NULL) + return false; evsel = perf_evsel__new(&attr); if (evsel) { - open_return = perf_evsel__open(evsel, NULL, &tmap.map); + open_return = perf_evsel__open(evsel, NULL, tmap); ret = open_return >= 0; if (open_return == -EACCES) { @@ -2042,7 +2039,7 @@ static bool is_event_supported(u8 type, unsigned config) * */ evsel->attr.exclude_kernel = 1; - ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0; + ret = perf_evsel__open(evsel, NULL, tmap) >= 0; } perf_evsel__delete(evsel); }