diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-29 03:48:33 +0300 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-30 13:59:57 +0300 |
commit | ae99fb2c335ef018520950ddc9692faacab39cf2 (patch) | |
tree | 9476516a203657b118f878d8ca6b4d0793a12c1e /tools/perf/util/parse-events.c | |
parent | 769885f372300a7fcfb9e54e4e2990718d40b529 (diff) | |
download | linux-ae99fb2c335ef018520950ddc9692faacab39cf2.tar.xz |
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.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: return ret; } -static void store_event_type(const char *orgname) +static int store_event_type(const char *orgname) { char filename[PATH_MAX], *c; FILE *file; - int id; + int id, n; sprintf(filename, "%s/", debugfs_path); strncat(filename, orgname, strlen(orgname)); @@ -769,11 +769,14 @@ static void store_event_type(const char *orgname) file = fopen(filename, "r"); if (!file) - return; - if (fscanf(file, "%i", &id) < 1) - die("cannot store event ID"); + return 0; + n = fscanf(file, "%i", &id); fclose(file); - perf_header__push_event(id, orgname); + if (n < 1) { + pr_err("cannot store event ID\n"); + return -EINVAL; + } + return perf_header__push_event(id, orgname); } 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 enum event_result ret; if (strchr(str, ':')) - store_event_type(str); + if (store_event_type(str) < 0) + return -1; for (;;) { if (nr_counters == MAX_COUNTERS) |