From ad5b217b152d99ca3922153500c619d9758dd87a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 2 Apr 2010 10:04:18 -0300 Subject: perf session: Remove one more exit() call from library code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return NULL instead and make the caller propagate the error. LKML-Reference: Cc: Frédéric Weisbecker Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Paul Mackerras Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-report.c | 5 ++++- tools/perf/util/session.c | 11 +++-------- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'tools/perf') diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 1fb13e5fd1f9..6767f10615ea 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -89,9 +89,12 @@ static int perf_session__add_hist_entry(struct perf_session *self, struct event_stat_id *stats; struct perf_event_attr *attr; - if ((sort__has_parent || symbol_conf.use_callchain) && data->callchain) + if ((sort__has_parent || symbol_conf.use_callchain) && data->callchain) { syms = perf_session__resolve_callchain(self, al->thread, data->callchain, &parent); + if (syms == NULL) + return -ENOMEM; + } attr = perf_header__find_attr(data->id, &self->header); if (attr) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 9da5e723495c..ddf288fca3eb 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -118,16 +118,11 @@ struct map_symbol *perf_session__resolve_callchain(struct perf_session *self, struct symbol **parent) { u8 cpumode = PERF_RECORD_MISC_USER; - struct map_symbol *syms = NULL; unsigned int i; + struct map_symbol *syms = calloc(chain->nr, sizeof(*syms)); - if (symbol_conf.use_callchain) { - syms = calloc(chain->nr, sizeof(*syms)); - if (!syms) { - fprintf(stderr, "Can't allocate memory for symbols\n"); - exit(-1); - } - } + if (!syms) + return NULL; for (i = 0; i < chain->nr; i++) { u64 ip = chain->ips[i]; -- cgit v1.2.1