aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/data_map.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-19 11:55:55 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-19 12:47:17 -0500
commit4dc0a04bb18fe9b80cefa08694f46a3a19ebfe50 (patch)
tree6d3ff5b79e71985ef4691df2d47202a4f6c3bd53 /tools/perf/util/data_map.c
parent2446042c93bfc6eeebfc89e88fdef2435d2bb5c4 (diff)
perf tools: perf_header__read() shouldn't die()
And also don't call the constructor in it, this way it adheres to the model the other methods follow. 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: <1258649757-17554-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/data_map.c')
-rw-r--r--tools/perf/util/data_map.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index 14cb8465eb08..b8fc0fa2f632 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -106,7 +106,7 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
106 int *cwdlen, 106 int *cwdlen,
107 char **cwd) 107 char **cwd)
108{ 108{
109 int ret, rc = EXIT_FAILURE; 109 int err, rc = EXIT_FAILURE;
110 struct perf_header *header; 110 struct perf_header *header;
111 unsigned long head, shift; 111 unsigned long head, shift;
112 unsigned long offset = 0; 112 unsigned long offset = 0;
@@ -132,8 +132,8 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
132 exit(-1); 132 exit(-1);
133 } 133 }
134 134
135 ret = fstat(input, &input_stat); 135 err = fstat(input, &input_stat);
136 if (ret < 0) { 136 if (err < 0) {
137 perror("failed to stat file"); 137 perror("failed to stat file");
138 exit(-1); 138 exit(-1);
139 } 139 }
@@ -149,8 +149,16 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
149 exit(0); 149 exit(0);
150 } 150 }
151 151
152 *pheader = perf_header__read(input); 152 header = perf_header__new();
153 header = *pheader; 153 if (header == NULL)
154 return -ENOMEM;
155
156 err = perf_header__read(header, input);
157 if (err < 0) {
158 perf_header__delete(header);
159 return err;
160 }
161 *pheader = header;
154 head = header->data_offset; 162 head = header->data_offset;
155 163
156 sample_type = perf_header__sample_type(header); 164 sample_type = perf_header__sample_type(header);