aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2017-02-14 13:04:48 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-02-14 13:19:18 -0500
commit423d856a4d6ab26a50309fd051f2bdf0e5d00fd6 (patch)
tree72e6fd2c354308fa759c85b4358ab3acaf68555b /tools
parent6aa4d8264003eb4f91fb09831ad25f059113f7b2 (diff)
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 <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-e2vs1x771fc208uvxnwcf08b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/tests/parse-no-sample-id-all.c19
1 files 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 81c6eeaca0f5..65dcf48a92fb 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)
50} 50}
51 51
52struct test_attr_event { 52struct test_attr_event {
53 struct attr_event attr; 53 struct perf_event_header header;
54 struct perf_event_attr attr;
54 u64 id; 55 u64 id;
55}; 56};
56 57
@@ -71,20 +72,16 @@ int test__parse_no_sample_id_all(int subtest __maybe_unused)
71 int err; 72 int err;
72 73
73 struct test_attr_event event1 = { 74 struct test_attr_event event1 = {
74 .attr = { 75 .header = {
75 .header = { 76 .type = PERF_RECORD_HEADER_ATTR,
76 .type = PERF_RECORD_HEADER_ATTR, 77 .size = sizeof(struct test_attr_event),
77 .size = sizeof(struct test_attr_event),
78 },
79 }, 78 },
80 .id = 1, 79 .id = 1,
81 }; 80 };
82 struct test_attr_event event2 = { 81 struct test_attr_event event2 = {
83 .attr = { 82 .header = {
84 .header = { 83 .type = PERF_RECORD_HEADER_ATTR,
85 .type = PERF_RECORD_HEADER_ATTR, 84 .size = sizeof(struct test_attr_event),
86 .size = sizeof(struct test_attr_event),
87 },
88 }, 85 },
89 .id = 2, 86 .id = 2,
90 }; 87 };