diff options
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index ef9114583994..bb4fca3efcc3 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -7,9 +7,8 @@ | |||
7 | #include "header.h" | 7 | #include "header.h" |
8 | 8 | ||
9 | /* | 9 | /* |
10 | * | 10 | * Create new perf.data header attribute: |
11 | */ | 11 | */ |
12 | |||
13 | struct perf_header_attr *perf_header_attr__new(struct perf_counter_attr *attr) | 12 | struct perf_header_attr *perf_header_attr__new(struct perf_counter_attr *attr) |
14 | { | 13 | { |
15 | struct perf_header_attr *self = malloc(sizeof(*self)); | 14 | struct perf_header_attr *self = malloc(sizeof(*self)); |
@@ -43,9 +42,8 @@ void perf_header_attr__add_id(struct perf_header_attr *self, u64 id) | |||
43 | } | 42 | } |
44 | 43 | ||
45 | /* | 44 | /* |
46 | * | 45 | * Create new perf.data header: |
47 | */ | 46 | */ |
48 | |||
49 | struct perf_header *perf_header__new(void) | 47 | struct perf_header *perf_header__new(void) |
50 | { | 48 | { |
51 | struct perf_header *self = malloc(sizeof(*self)); | 49 | struct perf_header *self = malloc(sizeof(*self)); |
@@ -86,9 +84,11 @@ void perf_header__add_attr(struct perf_header *self, | |||
86 | self->attr[pos] = attr; | 84 | self->attr[pos] = attr; |
87 | } | 85 | } |
88 | 86 | ||
87 | #define MAX_EVENT_NAME 64 | ||
88 | |||
89 | struct perf_trace_event_type { | 89 | struct perf_trace_event_type { |
90 | u64 event_id; | 90 | u64 event_id; |
91 | char name[64]; | 91 | char name[MAX_EVENT_NAME]; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | static int event_count; | 94 | static int event_count; |
@@ -96,7 +96,7 @@ static struct perf_trace_event_type *events; | |||
96 | 96 | ||
97 | void perf_header__push_event(u64 id, const char *name) | 97 | void perf_header__push_event(u64 id, const char *name) |
98 | { | 98 | { |
99 | if (strlen(name) > 64) | 99 | if (strlen(name) > MAX_EVENT_NAME) |
100 | printf("Event %s will be truncated\n", name); | 100 | printf("Event %s will be truncated\n", name); |
101 | 101 | ||
102 | if (!events) { | 102 | if (!events) { |
@@ -110,7 +110,7 @@ void perf_header__push_event(u64 id, const char *name) | |||
110 | } | 110 | } |
111 | memset(&events[event_count], 0, sizeof(struct perf_trace_event_type)); | 111 | memset(&events[event_count], 0, sizeof(struct perf_trace_event_type)); |
112 | events[event_count].event_id = id; | 112 | events[event_count].event_id = id; |
113 | strncpy(events[event_count].name, name, 63); | 113 | strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1); |
114 | event_count++; | 114 | event_count++; |
115 | } | 115 | } |
116 | 116 | ||