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/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
 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 <traceevent/event-parse.h>
 #include <linux/hw_breakpoint.h>
 #include <linux/perf_event.h>
+#include <linux/err.h>
 #include <sys/resource.h>
 #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 <linux/hw_breakpoint.h>
+#include <linux/err.h>
 #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 <sys/stat.h>
 #include <fcntl.h>
 #include <linux/kernel.h>
+#include <linux/err.h>
 #include <traceevent/event-parse.h>
 #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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to