diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-09-07 04:38:06 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-09-15 08:48:33 -0400 |
commit | 8dd2a1317eba2c207632dcb19adb7cb746861652 (patch) | |
tree | 15d062f65152a883e2dd459f397bbcf5b1cffe68 /tools/perf/util/trace-event.c | |
parent | e2f9f8ea6a54e252e3a94a5c2321f673b5b97360 (diff) |
perf evsel: Propagate error info from tp_format
Propagate error info from tp_format via ERR_PTR to get it all the way
down to the parse-event.c tracepoint adding routines. Following
functions now return pointer with encoded error:
- tp_format
- trace_event__tp_format
- perf_evsel__newtp_idx
- perf_evsel__newtp
This affects several other places in perf, that cannot use pointer check
anymore, but must utilize the err.h interface, when getting error
information from above functions list.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Link: http://lkml.kernel.org/r/1441615087-13886-5-git-send-email-jolsa@kernel.org
[ Add two missing ERR_PTR() and one IS_ERR() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/trace-event.c')
-rw-r--r-- | tools/perf/util/trace-event.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c index 2f4996ab313d..802bb868d446 100644 --- a/tools/perf/util/trace-event.c +++ b/tools/perf/util/trace-event.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <sys/stat.h> | 7 | #include <sys/stat.h> |
8 | #include <fcntl.h> | 8 | #include <fcntl.h> |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/err.h> | ||
10 | #include <traceevent/event-parse.h> | 11 | #include <traceevent/event-parse.h> |
11 | #include <api/fs/tracing_path.h> | 12 | #include <api/fs/tracing_path.h> |
12 | #include "trace-event.h" | 13 | #include "trace-event.h" |
@@ -66,6 +67,9 @@ void trace_event__cleanup(struct trace_event *t) | |||
66 | pevent_free(t->pevent); | 67 | pevent_free(t->pevent); |
67 | } | 68 | } |
68 | 69 | ||
70 | /* | ||
71 | * Returns pointer with encoded error via <linux/err.h> interface. | ||
72 | */ | ||
69 | static struct event_format* | 73 | static struct event_format* |
70 | tp_format(const char *sys, const char *name) | 74 | tp_format(const char *sys, const char *name) |
71 | { | 75 | { |
@@ -74,12 +78,14 @@ tp_format(const char *sys, const char *name) | |||
74 | char path[PATH_MAX]; | 78 | char path[PATH_MAX]; |
75 | size_t size; | 79 | size_t size; |
76 | char *data; | 80 | char *data; |
81 | int err; | ||
77 | 82 | ||
78 | scnprintf(path, PATH_MAX, "%s/%s/%s/format", | 83 | scnprintf(path, PATH_MAX, "%s/%s/%s/format", |
79 | tracing_events_path, sys, name); | 84 | tracing_events_path, sys, name); |
80 | 85 | ||
81 | if (filename__read_str(path, &data, &size)) | 86 | err = filename__read_str(path, &data, &size); |
82 | return NULL; | 87 | if (err) |
88 | return ERR_PTR(err); | ||
83 | 89 | ||
84 | pevent_parse_format(pevent, &event, data, size, sys); | 90 | pevent_parse_format(pevent, &event, data, size, sys); |
85 | 91 | ||
@@ -87,11 +93,14 @@ tp_format(const char *sys, const char *name) | |||
87 | return event; | 93 | return event; |
88 | } | 94 | } |
89 | 95 | ||
96 | /* | ||
97 | * Returns pointer with encoded error via <linux/err.h> interface. | ||
98 | */ | ||
90 | struct event_format* | 99 | struct event_format* |
91 | trace_event__tp_format(const char *sys, const char *name) | 100 | trace_event__tp_format(const char *sys, const char *name) |
92 | { | 101 | { |
93 | if (!tevent_initialized && trace_event__init2()) | 102 | if (!tevent_initialized && trace_event__init2()) |
94 | return NULL; | 103 | return ERR_PTR(-ENOMEM); |
95 | 104 | ||
96 | return tp_format(sys, name); | 105 | return tp_format(sys, name); |
97 | } | 106 | } |