aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-28 19:48:33 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-30 05:59:57 -0500
commitae99fb2c335ef018520950ddc9692faacab39cf2 (patch)
tree9476516a203657b118f878d8ca6b4d0793a12c1e /tools/perf/util/parse-events.c
parent769885f372300a7fcfb9e54e4e2990718d40b529 (diff)
perf header: perf_header__push_event() shouldn't die
Just propagate eventual errors. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1262047716-23171-2-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c18
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
756static void store_event_type(const char *orgname) 756static 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
779int parse_events(const struct option *opt __used, const char *str, int unset __used) 782int 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)