diff options
Diffstat (limited to 'tools/perf/util/header.c')
| -rw-r--r-- | tools/perf/util/header.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index c0b70c697a36..2dd5edf161b7 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
| @@ -31,21 +31,16 @@ static const char **header_argv; | |||
| 31 | 31 | ||
| 32 | int perf_header__push_event(u64 id, const char *name) | 32 | int perf_header__push_event(u64 id, const char *name) |
| 33 | { | 33 | { |
| 34 | struct perf_trace_event_type *nevents; | ||
| 35 | |||
| 34 | if (strlen(name) > MAX_EVENT_NAME) | 36 | if (strlen(name) > MAX_EVENT_NAME) |
| 35 | pr_warning("Event %s will be truncated\n", name); | 37 | pr_warning("Event %s will be truncated\n", name); |
| 36 | 38 | ||
| 37 | if (!events) { | 39 | nevents = realloc(events, (event_count + 1) * sizeof(*events)); |
| 38 | events = malloc(sizeof(struct perf_trace_event_type)); | 40 | if (nevents == NULL) |
| 39 | if (events == NULL) | 41 | return -ENOMEM; |
| 40 | return -ENOMEM; | 42 | events = nevents; |
| 41 | } else { | ||
| 42 | struct perf_trace_event_type *nevents; | ||
| 43 | 43 | ||
| 44 | nevents = realloc(events, (event_count + 1) * sizeof(*events)); | ||
| 45 | if (nevents == NULL) | ||
| 46 | return -ENOMEM; | ||
| 47 | events = nevents; | ||
| 48 | } | ||
| 49 | memset(&events[event_count], 0, sizeof(struct perf_trace_event_type)); | 44 | memset(&events[event_count], 0, sizeof(struct perf_trace_event_type)); |
| 50 | events[event_count].event_id = id; | 45 | events[event_count].event_id = id; |
| 51 | strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1); | 46 | strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1); |
| @@ -442,7 +437,7 @@ static bool perf_session__read_build_ids(struct perf_session *session, bool with | |||
| 442 | return ret; | 437 | return ret; |
| 443 | } | 438 | } |
| 444 | 439 | ||
| 445 | static int write_trace_info(int fd, struct perf_header *h __used, | 440 | static int write_tracing_data(int fd, struct perf_header *h __used, |
| 446 | struct perf_evlist *evlist) | 441 | struct perf_evlist *evlist) |
| 447 | { | 442 | { |
| 448 | return read_tracing_data(fd, &evlist->entries); | 443 | return read_tracing_data(fd, &evlist->entries); |
| @@ -1477,7 +1472,7 @@ out: | |||
| 1477 | return err; | 1472 | return err; |
| 1478 | } | 1473 | } |
| 1479 | 1474 | ||
| 1480 | static int process_trace_info(struct perf_file_section *section __unused, | 1475 | static int process_tracing_data(struct perf_file_section *section __unused, |
| 1481 | struct perf_header *ph __unused, | 1476 | struct perf_header *ph __unused, |
| 1482 | int feat __unused, int fd) | 1477 | int feat __unused, int fd) |
| 1483 | { | 1478 | { |
| @@ -1513,11 +1508,11 @@ struct feature_ops { | |||
| 1513 | .full_only = true } | 1508 | .full_only = true } |
| 1514 | 1509 | ||
| 1515 | /* feature_ops not implemented: */ | 1510 | /* feature_ops not implemented: */ |
| 1516 | #define print_trace_info NULL | 1511 | #define print_tracing_data NULL |
| 1517 | #define print_build_id NULL | 1512 | #define print_build_id NULL |
| 1518 | 1513 | ||
| 1519 | static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { | 1514 | static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { |
| 1520 | FEAT_OPP(HEADER_TRACE_INFO, trace_info), | 1515 | FEAT_OPP(HEADER_TRACING_DATA, tracing_data), |
| 1521 | FEAT_OPP(HEADER_BUILD_ID, build_id), | 1516 | FEAT_OPP(HEADER_BUILD_ID, build_id), |
| 1522 | FEAT_OPA(HEADER_HOSTNAME, hostname), | 1517 | FEAT_OPA(HEADER_HOSTNAME, hostname), |
| 1523 | FEAT_OPA(HEADER_OSRELEASE, osrelease), | 1518 | FEAT_OPA(HEADER_OSRELEASE, osrelease), |
