perf probe: Don't use strerror if strlist__add failed
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Thu, 14 Aug 2014 02:22:30 +0000 (02:22 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 15 Aug 2014 13:53:36 +0000 (10:53 -0300)
Since the strlist__add doesn't involves any IO, the failure reason must
be ENOMEM or EINVAL, moreover this is just a debug message, we don't
need to show the error string.

And also, if get_probe_trace_command_rawlist() returns NULL, it doesn't
mean the rawlist is empty, there is an error.  So caller must use
-ENOMEM for the error.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naohiro Aota <naota@elisp.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20140814022230.3545.99254.stgit@kbuild-fedora.novalocal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/probe-event.c

index ac15ff7800099f04f2ff28a428175800b058da82..bf39c23b275ddee156cfcb972b30c2e5f5491e08 100644 (file)
@@ -1881,7 +1881,7 @@ static struct strlist *get_probe_trace_command_rawlist(int fd)
                        p[idx] = '\0';
                ret = strlist__add(sl, buf);
                if (ret < 0) {
-                       pr_debug("strlist__add failed: %s\n", strerror(-ret));
+                       pr_debug("strlist__add failed (%d)\n", ret);
                        strlist__delete(sl);
                        return NULL;
                }
@@ -1940,7 +1940,7 @@ static int __show_perf_probe_events(int fd, bool is_kprobe)
 
        rawlist = get_probe_trace_command_rawlist(fd);
        if (!rawlist)
-               return -ENOENT;
+               return -ENOMEM;
 
        strlist__for_each(ent, rawlist) {
                ret = parse_probe_trace_command(ent->s, &tev);
@@ -2007,6 +2007,8 @@ static struct strlist *get_probe_trace_event_names(int fd, bool include_group)
 
        memset(&tev, 0, sizeof(tev));
        rawlist = get_probe_trace_command_rawlist(fd);
+       if (!rawlist)
+               return NULL;
        sl = strlist__new(true, NULL);
        strlist__for_each(ent, rawlist) {
                ret = parse_probe_trace_command(ent->s, &tev);