Skip to content

Commit 423d856

Browse files
committed
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 <[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]>
1 parent 6aa4d82 commit 423d856

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tools/perf/tests/parse-no-sample-id-all.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ static int process_events(union perf_event **events, size_t count)
5050
}
5151

5252
struct test_attr_event {
53-
struct attr_event attr;
53+
struct perf_event_header header;
54+
struct perf_event_attr attr;
5455
u64 id;
5556
};
5657

@@ -71,20 +72,16 @@ int test__parse_no_sample_id_all(int subtest __maybe_unused)
7172
int err;
7273

7374
struct test_attr_event event1 = {
74-
.attr = {
75-
.header = {
76-
.type = PERF_RECORD_HEADER_ATTR,
77-
.size = sizeof(struct test_attr_event),
78-
},
75+
.header = {
76+
.type = PERF_RECORD_HEADER_ATTR,
77+
.size = sizeof(struct test_attr_event),
7978
},
8079
.id = 1,
8180
};
8281
struct test_attr_event event2 = {
83-
.attr = {
84-
.header = {
85-
.type = PERF_RECORD_HEADER_ATTR,
86-
.size = sizeof(struct test_attr_event),
87-
},
82+
.header = {
83+
.type = PERF_RECORD_HEADER_ATTR,
84+
.size = sizeof(struct test_attr_event),
8885
},
8986
.id = 2,
9087
};

0 commit comments

Comments
 (0)