From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933474AbdBPUBo (ORCPT ); Thu, 16 Feb 2017 15:01:44 -0500 Received: from terminus.zytor.com ([65.50.211.136]:48882 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932694AbdBPUBm (ORCPT ); Thu, 16 Feb 2017 15:01:42 -0500 Date: Thu, 16 Feb 2017 12:01:31 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: tglx@linutronix.de, wangnan0@huawei.com, jolsa@kernel.org, mingo@kernel.org, dsahern@gmail.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, hpa@zytor.com, adrian.hunter@intel.com, acme@redhat.com Reply-To: mingo@kernel.org, jolsa@kernel.org, wangnan0@huawei.com, tglx@linutronix.de, acme@redhat.com, adrian.hunter@intel.com, namhyung@kernel.org, hpa@zytor.com, dsahern@gmail.com, linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tests: Synthesize struct instead of using field after variable sized type Git-Commit-ID: 423d856a4d6ab26a50309fd051f2bdf0e5d00fd6 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: 423d856a4d6ab26a50309fd051f2bdf0e5d00fd6 Gitweb: http://git.kernel.org/tip/423d856a4d6ab26a50309fd051f2bdf0e5d00fd6 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 14 Feb 2017 15:04:48 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 14 Feb 2017 15:19:18 -0300 perf tests: Synthesize struct instead of using field after variable sized type End result is the same, its an ABI, so the struct won't change, avoid using a GNU extension, so that we can catch other cases that may be bugs. Caught when building with clang: tests/parse-no-sample-id-all.c:53:20: error: field 'attr' with variable sized type 'struct attr_event' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end] struct attr_event attr; ^ 1 error generated. Testing it: # perf test sample_id 24: Parse with no sample_id_all bit set : Ok # Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-e2vs1x771fc208uvxnwcf08b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/parse-no-sample-id-all.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c index 81c6eea..65dcf48 100644 --- a/tools/perf/tests/parse-no-sample-id-all.c +++ b/tools/perf/tests/parse-no-sample-id-all.c @@ -50,7 +50,8 @@ static int process_events(union perf_event **events, size_t count) } struct test_attr_event { - struct attr_event attr; + struct perf_event_header header; + struct perf_event_attr attr; u64 id; }; @@ -71,20 +72,16 @@ int test__parse_no_sample_id_all(int subtest __maybe_unused) int err; struct test_attr_event event1 = { - .attr = { - .header = { - .type = PERF_RECORD_HEADER_ATTR, - .size = sizeof(struct test_attr_event), - }, + .header = { + .type = PERF_RECORD_HEADER_ATTR, + .size = sizeof(struct test_attr_event), }, .id = 1, }; struct test_attr_event event2 = { - .attr = { - .header = { - .type = PERF_RECORD_HEADER_ATTR, - .size = sizeof(struct test_attr_event), - }, + .header = { + .type = PERF_RECORD_HEADER_ATTR, + .size = sizeof(struct test_attr_event), }, .id = 2, };