perf tools: Modify error code for when perf_session__new() fails
authorTaeung Song <treeze.taeung@gmail.com>
Wed, 24 Sep 2014 01:33:37 +0000 (10:33 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 26 Sep 2014 15:32:58 +0000 (12:32 -0300)
Because perf_session__new() can fail for more reasons than just ENOMEM,
modify error code(ENOMEM or EINVAL) to -1.

Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1411522417-9917-1-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
13 files changed:
tools/perf/builtin-annotate.c
tools/perf/builtin-diff.c
tools/perf/builtin-evlist.c
tools/perf/builtin-inject.c
tools/perf/builtin-kmem.c
tools/perf/builtin-kvm.c
tools/perf/builtin-lock.c
tools/perf/builtin-mem.c
tools/perf/builtin-report.c
tools/perf/builtin-script.c
tools/perf/builtin-timechart.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c

index d4da6929597fa5fa5cafd049c74cffb2fd77ba5c..be59394184252c88861edb353bd2be7be469f6c1 100644 (file)
@@ -340,7 +340,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 
        annotate.session = perf_session__new(&file, false, &annotate.tool);
        if (annotate.session == NULL)
-               return -ENOMEM;
+               return -1;
 
        symbol_conf.priv_size = sizeof(struct annotation);
        symbol_conf.try_vmlinux_path = true;
index 190d0b6b28cce61c364919adcc9c41fa8899ec40..a3ce19f7aebdd6f63e440b88ab9d168338ed509f 100644 (file)
@@ -683,7 +683,7 @@ static int __cmd_diff(void)
                d->session = perf_session__new(&d->file, false, &tool);
                if (!d->session) {
                        pr_err("Failed to open %s\n", d->file.path);
-                       ret = -ENOMEM;
+                       ret = -1;
                        goto out_delete;
                }
 
index 66e12f55c052869e32864ad52e19dda226d918c3..0f93f859b782ba1701b1457cb3f90c9d1ecf5995 100644 (file)
@@ -28,7 +28,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
 
        session = perf_session__new(&file, 0, NULL);
        if (session == NULL)
-               return -ENOMEM;
+               return -1;
 
        evlist__for_each(session->evlist, pos)
                perf_evsel__fprintf(pos, details, stdout);
index 3a62b6b3c8fdcc2dd308791dc14d5bd18a6ed087..de99ca1bb94268d01c1baebb5757490c367ec912 100644 (file)
@@ -460,7 +460,7 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
        file.path = inject.input_name;
        inject.session = perf_session__new(&file, true, &inject.tool);
        if (inject.session == NULL)
-               return -ENOMEM;
+               return -1;
 
        if (symbol__init(&inject.session->header.env) < 0)
                return -1;
index 23762187a2191dc98bf68a35b2103d73df0aea78..f295141025bcfecdb01c913b94cc3b1ed533d2b4 100644 (file)
@@ -698,7 +698,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 
        session = perf_session__new(&file, false, &perf_kmem);
        if (session == NULL)
-               return -ENOMEM;
+               return -1;
 
        symbol__init(&session->header.env);
 
index 1e639d6265ccb97a79654ca3ee62693bbc7c38b3..d8bf2271f4ea7e298811c7aa4759ed7ffda84dbd 100644 (file)
@@ -1058,7 +1058,7 @@ static int read_events(struct perf_kvm_stat *kvm)
        kvm->session = perf_session__new(&file, false, &kvm->tool);
        if (!kvm->session) {
                pr_err("Initializing perf session failed\n");
-               return -EINVAL;
+               return -1;
        }
 
        symbol__init(&kvm->session->header.env);
@@ -1361,7 +1361,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
         */
        kvm->session = perf_session__new(&file, false, &kvm->tool);
        if (kvm->session == NULL) {
-               err = -ENOMEM;
+               err = -1;
                goto out;
        }
        kvm->session->evlist = kvm->evlist;
index 92790ed7af45d4376e2d95c10e515601bdbb70e1..e7ec71589da6dbcc06f5a8367466f953cac99c4c 100644 (file)
@@ -862,7 +862,7 @@ static int __cmd_report(bool display_info)
        session = perf_session__new(&file, false, &eops);
        if (!session) {
                pr_err("Initializing perf session failed\n");
-               return -ENOMEM;
+               return -1;
        }
 
        symbol__init(&session->header.env);
index 8b4a87fe3858367235168e27ab2601f3788ece11..24db6ffe2957450d17a6a6465441317b81f7f49e 100644 (file)
@@ -124,7 +124,7 @@ static int report_raw_events(struct perf_mem *mem)
                                                         &mem->tool);
 
        if (session == NULL)
-               return -ENOMEM;
+               return -1;
 
        if (mem->cpu_list) {
                ret = perf_session__cpu_bitmap(session, mem->cpu_list,
index 8c0b3f22412ab23933bb4daf7d7d6fbc54dc7a20..ac145fae0521c3c9779a90c097228ff39074d5a6 100644 (file)
@@ -720,7 +720,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 repeat:
        session = perf_session__new(&file, false, &report.tool);
        if (session == NULL)
-               return -ENOMEM;
+               return -1;
 
        if (report.queue_size) {
                ordered_events__set_alloc_size(&session->ordered_events,
index 02dce9295e2c7eec4dfd9bfcac1d33f37f6e0a60..b9b9e58a6c399d4c4c2e8dc3162598acf2b1cd62 100644 (file)
@@ -1744,7 +1744,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 
        session = perf_session__new(&file, false, &script.tool);
        if (session == NULL)
-               return -ENOMEM;
+               return -1;
 
        if (header || header_only) {
                perf_session__fprintf_info(session, stdout, show_full_info);
index 48eea6cd2f5be475088e0c55d053ab4bd4e66246..35b425b6293f759b5119d8fb6a07d2ab2303d6f7 100644 (file)
@@ -1605,7 +1605,7 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
        int ret = -EINVAL;
 
        if (session == NULL)
-               return -ENOMEM;
+               return -1;
 
        symbol__init(&session->header.env);
 
index 832fb527ed90aa0467a0c712bf9bcf9ddc484398..5c16ba2dcf08bc19e7e63c092ee310094ea2c633 100644 (file)
@@ -929,7 +929,7 @@ static int __cmd_top(struct perf_top *top)
 
        top->session = perf_session__new(NULL, false, NULL);
        if (top->session == NULL)
-               return -ENOMEM;
+               return -1;
 
        machines__set_symbol_filter(&top->session->machines, symbol_filter);
 
index fe39dc620179a6fd1061899f7d6efd5c225ef4f7..c70e69ea1c5dcc2db046fc5d9577236a3b64b025 100644 (file)
@@ -2250,7 +2250,7 @@ static int trace__replay(struct trace *trace)
 
        session = perf_session__new(&file, false, &trace->tool);
        if (session == NULL)
-               return -ENOMEM;
+               return -1;
 
        if (symbol__init(&session->header.env) < 0)
                goto out;