aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-16 22:18:11 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-17 01:19:56 -0500
commita9a70bbce7ab0bf3b1cba3ac662c4d502da6305c (patch)
treed2215ac394e9f9320d059a139a405f012abcd708
parent5875412152ce67fb5087157b86ab6597f91d23e8 (diff)
perf tools: Don't die() in perf_header__new()
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-3-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/builtin-record.c5
-rw-r--r--tools/perf/util/header.c18
2 files changed, 16 insertions, 7 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 2a85205ba01a..82260c56db3d 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -439,6 +439,11 @@ static int __cmd_record(int argc, const char **argv)
439 else 439 else
440 header = perf_header__new(); 440 header = perf_header__new();
441 441
442 if (header == NULL) {
443 pr_err("Not enough memory for reading perf file header\n");
444 return -1;
445 }
446
442 if (raw_samples) { 447 if (raw_samples) {
443 perf_header__set_feat(header, HEADER_TRACE_INFO); 448 perf_header__set_feat(header, HEADER_TRACE_INFO);
444 } else { 449 } else {
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index dee1ed2f0d1b..726a0eb5f197 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -65,14 +65,15 @@ struct perf_header *perf_header__new(void)
65{ 65{
66 struct perf_header *self = calloc(sizeof(*self), 1); 66 struct perf_header *self = calloc(sizeof(*self), 1);
67 67
68 if (!self) 68 if (self != NULL) {
69 die("nomem"); 69 self->size = 1;
70 70 self->attr = malloc(sizeof(void *));
71 self->size = 1;
72 self->attr = malloc(sizeof(void *));
73 71
74 if (!self->attr) 72 if (self->attr == NULL) {
75 die("nomem"); 73 free(self);
74 self = NULL;
75 }
76 }
76 77
77 return self; 78 return self;
78} 79}
@@ -426,6 +427,9 @@ struct perf_header *perf_header__read(int fd)
426 u64 f_id; 427 u64 f_id;
427 int nr_attrs, nr_ids, i, j; 428 int nr_attrs, nr_ids, i, j;
428 429
430 if (self == NULL)
431 die("nomem");
432
429 if (perf_file_header__read(&f_header, self, fd) < 0) 433 if (perf_file_header__read(&f_header, self, fd) < 0)
430 die("incompatible file format"); 434 die("incompatible file format");
431 435