diff options
-rw-r--r-- | tools/perf/util/event.c | 1 | ||||
-rw-r--r-- | tools/perf/util/header.c | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 1757b0ffeaa9..2477270c1d3f 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -713,6 +713,7 @@ int event__parse_sample(event_t *event, u64 type, struct sample_data *data) | |||
713 | array++; | 713 | array++; |
714 | } | 714 | } |
715 | 715 | ||
716 | data->id = -1ULL; | ||
716 | if (type & PERF_SAMPLE_ID) { | 717 | if (type & PERF_SAMPLE_ID) { |
717 | data->id = *array; | 718 | data->id = *array; |
718 | array++; | 719 | array++; |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 2b9f898efea6..8847bec64c54 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -922,6 +922,14 @@ perf_header__find_attr(u64 id, struct perf_header *header) | |||
922 | { | 922 | { |
923 | int i; | 923 | int i; |
924 | 924 | ||
925 | /* | ||
926 | * We set id to -1 if the data file doesn't contain sample | ||
927 | * ids. Check for this and avoid walking through the entire | ||
928 | * list of ids which may be large. | ||
929 | */ | ||
930 | if (id == -1ULL) | ||
931 | return NULL; | ||
932 | |||
925 | for (i = 0; i < header->attrs; i++) { | 933 | for (i = 0; i < header->attrs; i++) { |
926 | struct perf_header_attr *attr = header->attr[i]; | 934 | struct perf_header_attr *attr = header->attr[i]; |
927 | int j; | 935 | int j; |