Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932614AbbHZNrv (ORCPT ); Wed, 26 Aug 2015 09:47:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57449 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756583AbbHZNrT (ORCPT ); Wed, 26 Aug 2015 09:47:19 -0400 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Matt Fleming , =?UTF-8?q?Rapha=C3=ABl=20Beamonte?= Subject: [PATCH 10/11] perf tools: Propagate error info from tp_format Date: Wed, 26 Aug 2015 15:46:52 +0200 Message-Id: <1440596813-12844-11-git-send-email-jolsa@kernel.org> In-Reply-To: <1440596813-12844-1-git-send-email-jolsa@kernel.org> References: <1440596813-12844-1-git-send-email-jolsa@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3417 Lines: 109 Propagate error info from tp_format via ERR_PTR to get it all the way down to the parse-event.c tracepoint adding routines. Link: http://lkml.kernel.org/n/tip-bzdckgv1zfp2y8up9l7ojt7y@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/evsel.c | 8 ++++++-- tools/perf/util/parse-events.c | 3 ++- tools/perf/util/trace-event.c | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b096ef7a240c..bbc18847278d 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "asm/bug.h" #include "callchain.h" @@ -227,6 +228,7 @@ struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx) struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int idx) { struct perf_evsel *evsel = zalloc(perf_evsel__object.size); + int err = -ENOMEM; if (evsel != NULL) { struct perf_event_attr attr = { @@ -239,8 +241,10 @@ struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int goto out_free; evsel->tp_format = trace_event__tp_format(sys, name); - if (evsel->tp_format == NULL) + if (IS_ERR(evsel->tp_format)) { + err = PTR_ERR(evsel->tp_format); goto out_free; + } event_attr_init(&attr); attr.config = evsel->tp_format->id; @@ -253,7 +257,7 @@ struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int out_free: zfree(&evsel->name); free(evsel); - return NULL; + return ERR_PTR(err); } const char *perf_evsel__hw_names[PERF_COUNT_HW_MAX] = { diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 5d17409039c8..ff8a28ac31b7 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1,4 +1,5 @@ #include +#include #include "util.h" #include "../perf.h" #include "evlist.h" @@ -393,7 +394,7 @@ static int add_tracepoint(struct list_head *list, int *idx, struct perf_evsel *evsel; evsel = perf_evsel__newtp_idx(sys_name, evt_name, (*idx)++); - if (!evsel) + if (IS_ERR(evsel)) return -ENOMEM; list_add_tail(&evsel->node, list); diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index b90e646c7a91..867292f2c4ef 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "trace-event.h" #include "machine.h" @@ -73,12 +74,14 @@ tp_format(const char *sys, const char *name) char path[PATH_MAX]; size_t size; char *data; + int err; scnprintf(path, PATH_MAX, "%s/%s/%s/format", tracing_events_path, sys, name); - if (filename__read_str(path, &data, &size)) - return NULL; + err = filename__read_str(path, &data, &size); + if (err) + return ERR_PTR(err); pevent_parse_format(pevent, &event, data, size, sys); -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/