diff options
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index dc585a835cab..609d5a9470c5 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -753,11 +753,11 @@ modifier: | |||
753 | return ret; | 753 | return ret; |
754 | } | 754 | } |
755 | 755 | ||
756 | static void store_event_type(const char *orgname) | 756 | static int store_event_type(const char *orgname) |
757 | { | 757 | { |
758 | char filename[PATH_MAX], *c; | 758 | char filename[PATH_MAX], *c; |
759 | FILE *file; | 759 | FILE *file; |
760 | int id; | 760 | int id, n; |
761 | 761 | ||
762 | sprintf(filename, "%s/", debugfs_path); | 762 | sprintf(filename, "%s/", debugfs_path); |
763 | strncat(filename, orgname, strlen(orgname)); | 763 | strncat(filename, orgname, strlen(orgname)); |
@@ -769,11 +769,14 @@ static void store_event_type(const char *orgname) | |||
769 | 769 | ||
770 | file = fopen(filename, "r"); | 770 | file = fopen(filename, "r"); |
771 | if (!file) | 771 | if (!file) |
772 | return; | 772 | return 0; |
773 | if (fscanf(file, "%i", &id) < 1) | 773 | n = fscanf(file, "%i", &id); |
774 | die("cannot store event ID"); | ||
775 | fclose(file); | 774 | fclose(file); |
776 | perf_header__push_event(id, orgname); | 775 | if (n < 1) { |
776 | pr_err("cannot store event ID\n"); | ||
777 | return -EINVAL; | ||
778 | } | ||
779 | return perf_header__push_event(id, orgname); | ||
777 | } | 780 | } |
778 | 781 | ||
779 | int parse_events(const struct option *opt __used, const char *str, int unset __used) | 782 | int parse_events(const struct option *opt __used, const char *str, int unset __used) |
@@ -782,7 +785,8 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u | |||
782 | enum event_result ret; | 785 | enum event_result ret; |
783 | 786 | ||
784 | if (strchr(str, ':')) | 787 | if (strchr(str, ':')) |
785 | store_event_type(str); | 788 | if (store_event_type(str) < 0) |
789 | return -1; | ||
786 | 790 | ||
787 | for (;;) { | 791 | for (;;) { |
788 | if (nr_counters == MAX_COUNTERS) | 792 | if (nr_counters == MAX_COUNTERS) |