perf probe: Let probe_file__add_event return 0 if succeeded
authorMasami Hiramatsu <mhiramat@kernel.org>
Tue, 26 Apr 2016 09:03:04 +0000 (18:03 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 26 Apr 2016 16:14:58 +0000 (13:14 -0300)
Since other methods return 0 if succeeded (or filedesc), let
probe_file__add_event() return 0 instead of the length of written bytes.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160426090303.11891.18232.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/probe-file.c

index e3b3b92e44587350b86797e93e57900afd71f94e..3fe6214970e632932cb3809dea4c36d0aa792029 100644 (file)
@@ -220,8 +220,7 @@ int probe_file__add_event(int fd, struct probe_trace_event *tev)
 
        pr_debug("Writing event: %s\n", buf);
        if (!probe_event_dry_run) {
-               ret = write(fd, buf, strlen(buf));
-               if (ret <= 0) {
+               if (write(fd, buf, strlen(buf)) < (int)strlen(buf)) {
                        ret = -errno;
                        pr_warning("Failed to write event: %s\n",
                                   strerror_r(errno, sbuf, sizeof(sbuf)));