diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-16 22:18:10 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-17 01:19:55 -0500 |
commit | 5875412152ce67fb5087157b86ab6597f91d23e8 (patch) | |
tree | 5a148dcc777433f0d097ffa072b8b1a5b0a5c346 /tools/perf/util/header.c | |
parent | 11deb1f9f6ca6318fa9470e024b9f0634df48b4c (diff) |
perf tools: Don't die() in perf_header_attr__add_id()
Propagate the errors instead, the users are the ones to decide
what to do if a library call fails.
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: <1258427892-16312-2-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 | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 23ccddae0b06..dee1ed2f0d1b 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -39,18 +39,23 @@ void perf_header_attr__delete(struct perf_header_attr *self) | |||
39 | free(self); | 39 | free(self); |
40 | } | 40 | } |
41 | 41 | ||
42 | void perf_header_attr__add_id(struct perf_header_attr *self, u64 id) | 42 | int perf_header_attr__add_id(struct perf_header_attr *self, u64 id) |
43 | { | 43 | { |
44 | int pos = self->ids; | 44 | int pos = self->ids; |
45 | 45 | ||
46 | self->ids++; | 46 | self->ids++; |
47 | if (self->ids > self->size) { | 47 | if (self->ids > self->size) { |
48 | self->size *= 2; | 48 | int nsize = self->size * 2; |
49 | self->id = realloc(self->id, self->size * sizeof(u64)); | 49 | u64 *nid = realloc(self->id, nsize * sizeof(u64)); |
50 | if (!self->id) | 50 | |
51 | die("nomem"); | 51 | if (nid == NULL) |
52 | return -1; | ||
53 | |||
54 | self->size = nsize; | ||
55 | self->id = nid; | ||
52 | } | 56 | } |
53 | self->id[pos] = id; | 57 | self->id[pos] = id; |
58 | return 0; | ||
54 | } | 59 | } |
55 | 60 | ||
56 | /* | 61 | /* |
@@ -444,7 +449,8 @@ struct perf_header *perf_header__read(int fd) | |||
444 | for (j = 0; j < nr_ids; j++) { | 449 | for (j = 0; j < nr_ids; j++) { |
445 | do_read(fd, &f_id, sizeof(f_id)); | 450 | do_read(fd, &f_id, sizeof(f_id)); |
446 | 451 | ||
447 | perf_header_attr__add_id(attr, f_id); | 452 | if (perf_header_attr__add_id(attr, f_id) < 0) |
453 | die("nomem"); | ||
448 | } | 454 | } |
449 | if (perf_header__add_attr(self, attr) < 0) | 455 | if (perf_header__add_attr(self, attr) < 0) |
450 | die("nomem"); | 456 | die("nomem"); |