diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-16 16:30:26 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-17 01:19:52 -0500 |
commit | dc79c0fc08a94b857aed446bfb47cdfde529400c (patch) | |
tree | a68f563cf3e4a047e1948d0735de9b5991166e4d /tools/perf/util/header.c | |
parent | c34984b2bbc77596c97c333539bffc90d2033178 (diff) |
perf tools: Don't die in perf_header_attr__new()
We really should propagate such kinds of errors so that users of
these library functions decide what to do in such cases instead
of exiting in random places like now.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1258407027-384-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index d8416f011179..2f07a238ffdf 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -19,16 +19,16 @@ struct perf_header_attr *perf_header_attr__new(struct perf_event_attr *attr) | |||
19 | { | 19 | { |
20 | struct perf_header_attr *self = malloc(sizeof(*self)); | 20 | struct perf_header_attr *self = malloc(sizeof(*self)); |
21 | 21 | ||
22 | if (!self) | 22 | if (self != NULL) { |
23 | die("nomem"); | 23 | self->attr = *attr; |
24 | 24 | self->ids = 0; | |
25 | self->attr = *attr; | 25 | self->size = 1; |
26 | self->ids = 0; | 26 | self->id = malloc(sizeof(u64)); |
27 | self->size = 1; | 27 | if (self->id == NULL) { |
28 | self->id = malloc(sizeof(u64)); | 28 | free(self); |
29 | 29 | self = NULL; | |
30 | if (!self->id) | 30 | } |
31 | die("nomem"); | 31 | } |
32 | 32 | ||
33 | return self; | 33 | return self; |
34 | } | 34 | } |
@@ -423,6 +423,8 @@ struct perf_header *perf_header__read(int fd) | |||
423 | tmp = lseek(fd, 0, SEEK_CUR); | 423 | tmp = lseek(fd, 0, SEEK_CUR); |
424 | 424 | ||
425 | attr = perf_header_attr__new(&f_attr.attr); | 425 | attr = perf_header_attr__new(&f_attr.attr); |
426 | if (attr == NULL) | ||
427 | die("nomem"); | ||
426 | 428 | ||
427 | nr_ids = f_attr.ids.size / sizeof(u64); | 429 | nr_ids = f_attr.ids.size / sizeof(u64); |
428 | lseek(fd, f_attr.ids.offset, SEEK_SET); | 430 | lseek(fd, f_attr.ids.offset, SEEK_SET); |