]> git.itanic.dy.fi Git - linux-stable/commitdiff
perf annotate: Ensure init/exit for global options
authorNamhyung Kim <namhyung@kernel.org>
Tue, 28 Nov 2023 17:54:39 +0000 (09:54 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 7 Dec 2023 20:18:24 +0000 (17:18 -0300)
Now it only cares about the global options so it can just handle it
without the argument.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231128175441.721579-7-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-annotate.c
tools/perf/builtin-report.c
tools/perf/builtin-top.c
tools/perf/util/annotate.c
tools/perf/util/annotate.h

index d17213bd83327224d21e4d229b7f832e2da16437..d880f1b039fdf376106319144d201edad77d0720 100644 (file)
@@ -615,13 +615,13 @@ int cmd_annotate(int argc, const char **argv)
        set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
        set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
 
-       annotation_options__init(&annotate_opts);
+       annotation_options__init();
 
        ret = hists__init();
        if (ret < 0)
                return ret;
 
-       annotation_config__init(&annotate_opts);
+       annotation_config__init();
 
        argc = parse_options(argc, argv, options, annotate_usage, 0);
        if (argc) {
@@ -651,7 +651,7 @@ int cmd_annotate(int argc, const char **argv)
                        return -ENOMEM;
        }
 
-       if (annotate_check_args(&annotate_opts) < 0)
+       if (annotate_check_args() < 0)
                return -EINVAL;
 
 #ifdef HAVE_GTK2_SUPPORT
@@ -732,7 +732,7 @@ int cmd_annotate(int argc, const char **argv)
 #ifndef NDEBUG
        perf_session__delete(annotate.session);
 #endif
-       annotation_options__exit(&annotate_opts);
+       annotation_options__exit();
 
        return ret;
 }
index bc0d986c1e0c1ce028d14bbd6a135058107d5253..17fb171e898b9ff7a980675632efeb621b9c43c7 100644 (file)
@@ -1430,7 +1430,7 @@ int cmd_report(int argc, const char **argv)
         */
        symbol_conf.keep_exited_threads = true;
 
-       annotation_options__init(&annotate_opts);
+       annotation_options__init();
 
        ret = perf_config(report__config, &report);
        if (ret)
@@ -1464,7 +1464,7 @@ int cmd_report(int argc, const char **argv)
                        return -ENOMEM;
        }
 
-       if (annotate_check_args(&annotate_opts) < 0) {
+       if (annotate_check_args() < 0) {
                ret = -EINVAL;
                goto exit;
        }
@@ -1696,7 +1696,7 @@ int cmd_report(int argc, const char **argv)
                         */
                        symbol_conf.priv_size += sizeof(u32);
                }
-               annotation_config__init(&annotate_opts);
+               annotation_config__init();
        }
 
        if (symbol__init(&session->header.env) < 0)
@@ -1750,7 +1750,7 @@ int cmd_report(int argc, const char **argv)
        zstd_fini(&(session->zstd_data));
        perf_session__delete(session);
 exit:
-       annotation_options__exit(&annotate_opts);
+       annotation_options__exit();
        free(sort_order_help);
        free(field_order_help);
        return ret;
index b5222d2419832d72ebff38fb42194446e81d6b86..ed83afeeced05cd77441110b03935658933134f9 100644 (file)
@@ -1608,7 +1608,7 @@ int cmd_top(int argc, const char **argv)
        if (status < 0)
                return status;
 
-       annotation_options__init(&annotate_opts);
+       annotation_options__init();
 
        annotate_opts.min_pcnt = 5;
        annotate_opts.context  = 4;
@@ -1660,7 +1660,7 @@ int cmd_top(int argc, const char **argv)
        if (status)
                goto out_delete_evlist;
 
-       if (annotate_check_args(&annotate_opts) < 0)
+       if (annotate_check_args() < 0)
                goto out_delete_evlist;
 
        if (!top.evlist->core.nr_entries) {
@@ -1786,7 +1786,7 @@ int cmd_top(int argc, const char **argv)
        if (status < 0)
                goto out_delete_evlist;
 
-       annotation_config__init(&annotate_opts);
+       annotation_config__init();
 
        symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
        status = symbol__init(NULL);
@@ -1839,7 +1839,7 @@ int cmd_top(int argc, const char **argv)
 out_delete_evlist:
        evlist__delete(top.evlist);
        perf_session__delete(top.session);
-       annotation_options__exit(&annotate_opts);
+       annotation_options__exit();
 
        return status;
 }
index daff9af552f4f7f43d3c43aa496f8a7f81d3c9af..626ff3baeb85570facc935c9115171279cd16030 100644 (file)
@@ -3416,8 +3416,10 @@ static int annotation__config(const char *var, const char *value, void *data)
        return 0;
 }
 
-void annotation_options__init(struct annotation_options *opt)
+void annotation_options__init(void)
 {
+       struct annotation_options *opt = &annotate_opts;
+
        memset(opt, 0, sizeof(*opt));
 
        /* Default values. */
@@ -3428,16 +3430,15 @@ void annotation_options__init(struct annotation_options *opt)
        opt->percent_type = PERCENT_PERIOD_LOCAL;
 }
 
-
-void annotation_options__exit(struct annotation_options *opt)
+void annotation_options__exit(void)
 {
-       zfree(&opt->disassembler_style);
-       zfree(&opt->objdump_path);
+       zfree(&annotate_opts.disassembler_style);
+       zfree(&annotate_opts.objdump_path);
 }
 
-void annotation_config__init(struct annotation_options *opt)
+void annotation_config__init(void)
 {
-       perf_config(annotation__config, opt);
+       perf_config(annotation__config, &annotate_opts);
 }
 
 static unsigned int parse_percent_type(char *str1, char *str2)
@@ -3491,8 +3492,10 @@ int annotate_parse_percent_type(const struct option *opt __maybe_unused, const c
        return err;
 }
 
-int annotate_check_args(struct annotation_options *args)
+int annotate_check_args(void)
 {
+       struct annotation_options *args = &annotate_opts;
+
        if (args->prefix_strip && !args->prefix) {
                pr_err("--prefix-strip requires --prefix\n");
                return -1;
index 857c5fa0e6b1609da51c62fa263a70a0d3d842b4..4283eb4522b28a9d9d956f0a422fe9a4b2e66f3a 100644 (file)
@@ -428,14 +428,14 @@ static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unused,
 }
 #endif
 
-void annotation_options__init(struct annotation_options *opt);
-void annotation_options__exit(struct annotation_options *opt);
+void annotation_options__init(void);
+void annotation_options__exit(void);
 
-void annotation_config__init(struct annotation_options *opt);
+void annotation_config__init(void);
 
 int annotate_parse_percent_type(const struct option *opt, const char *_str,
                                int unset);
 
-int annotate_check_args(struct annotation_options *args);
+int annotate_check_args(void);
 
 #endif /* __PERF_ANNOTATE_H */