Commit 7949ba1fa249caa7e611abb8d92f40b0a46c8617

Authored by Namhyung Kim
Committed by Arnaldo Carvalho de Melo
1 parent 33636732dc

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>

Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff

tools/perf/util/probe-event.c
... ... @@ -2052,9 +2052,11 @@
2052 2052 pr_debug("Writing event: %s\n", buf);
2053 2053 if (!probe_event_dry_run) {
2054 2054 ret = write(fd, buf, strlen(buf));
2055   - if (ret <= 0)
  2055 + if (ret <= 0) {
  2056 + ret = -errno;
2056 2057 pr_warning("Failed to write event: %s\n",
2057 2058 strerror_r(errno, sbuf, sizeof(sbuf)));
  2059 + }
2058 2060 }
2059 2061 free(buf);
2060 2062 return ret;