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>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
e2f9f8ea6a
commit
8dd2a1317e
@@ -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 <api/fs/tracing_path.h>
|
||||
#include "trace-event.h"
|
||||
@@ -66,6 +67,9 @@ void trace_event__cleanup(struct trace_event *t)
|
||||
pevent_free(t->pevent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns pointer with encoded error via <linux/err.h> interface.
|
||||
*/
|
||||
static struct event_format*
|
||||
tp_format(const char *sys, const char *name)
|
||||
{
|
||||
@@ -74,12 +78,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);
|
||||
|
||||
@@ -87,11 +93,14 @@ tp_format(const char *sys, const char *name)
|
||||
return event;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns pointer with encoded error via <linux/err.h> interface.
|
||||
*/
|
||||
struct event_format*
|
||||
trace_event__tp_format(const char *sys, const char *name)
|
||||
{
|
||||
if (!tevent_initialized && trace_event__init2())
|
||||
return NULL;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
return tp_format(sys, name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user