]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
perf session: Remove one more exit() call from library code
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 2 Apr 2010 13:04:18 +0000 (10:04 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 2 Apr 2010 19:28:31 +0000 (16:28 -0300)
Return NULL instead and make the caller propagate the error.

LKML-Reference: <new-submission>
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>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-report.c
tools/perf/util/session.c

index 1fb13e5fd1f9119b1242c74a2895ecfd2cc47c90..6767f10615eaa8901e6eeff52f5d789c7614e6f5 100644 (file)
@@ -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)
index 9da5e723495c293129905e9ec19e4ac13b209619..ddf288fca3eb057d92d2c69660626b3687f0ca6f 100644 (file)
@@ -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];