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
@@ -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"
|
||||
@@ -225,11 +226,17 @@ struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx)
|
||||
return evsel;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns pointer with encoded error via <linux/err.h> interface.
|
||||
*/
|
||||
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) {
|
||||
if (evsel == NULL) {
|
||||
goto out_err;
|
||||
} else {
|
||||
struct perf_event_attr attr = {
|
||||
.type = PERF_TYPE_TRACEPOINT,
|
||||
.sample_type = (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
|
||||
@@ -240,8 +247,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;
|
||||
@@ -254,7 +263,8 @@ struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int
|
||||
out_free:
|
||||
zfree(&evsel->name);
|
||||
free(evsel);
|
||||
return NULL;
|
||||
out_err:
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
const char *perf_evsel__hw_names[PERF_COUNT_HW_MAX] = {
|
||||
|
||||
Reference in New Issue
Block a user