diff options
author | Namhyung Kim <namhyung@kernel.org> | 2015-01-10 05:33:48 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-01-16 15:49:28 -0500 |
commit | 7949ba1fa249caa7e611abb8d92f40b0a46c8617 (patch) | |
tree | 51b3a6b4ff09b3b45c318174d69ef15ae5c5614b /tools | |
parent | 33636732dcd7cc738a5913bb730d663c6b03c8fb (diff) |
perf probe: Propagate error code when write(2) failed
When it failed to write probe commands to the probe_event file in
debugfs, it needs to propagate the error code properly. Current code
blindly uses the return value of the write(2) so it always uses
-1 (-EPERM) and it might confuse users.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1420886028-15135-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/probe-event.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 7f9b8632e433..94a717bf007d 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -2052,9 +2052,11 @@ static int write_probe_trace_event(int fd, struct probe_trace_event *tev) | |||
2052 | pr_debug("Writing event: %s\n", buf); | 2052 | pr_debug("Writing event: %s\n", buf); |
2053 | if (!probe_event_dry_run) { | 2053 | if (!probe_event_dry_run) { |
2054 | ret = write(fd, buf, strlen(buf)); | 2054 | ret = write(fd, buf, strlen(buf)); |
2055 | if (ret <= 0) | 2055 | if (ret <= 0) { |
2056 | ret = -errno; | ||
2056 | pr_warning("Failed to write event: %s\n", | 2057 | pr_warning("Failed to write event: %s\n", |
2057 | strerror_r(errno, sbuf, sizeof(sbuf))); | 2058 | strerror_r(errno, sbuf, sizeof(sbuf))); |
2059 | } | ||
2058 | } | 2060 | } |
2059 | free(buf); | 2061 | free(buf); |
2060 | return ret; | 2062 | return ret; |