summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-help.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-10-01 15:20:58 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-02 18:36:31 -0300
commit2bae1d1b1aa3b763b99431101a04dfe24ec5ba7f (patch)
tree2f956a4e21553c3f2c9b2a063e9dc2555af717b9 /tools/perf/builtin-help.c
parent69b6470e9ef3f6ea72b7e46e140d85970d8e1bc8 (diff)
perf help: Don't use globals where not needed to
Some variables were global but used in just one function, so move it to where it belongs. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-plurd9htha6ea2mo9e9sd1p5@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-help.c')
-rw-r--r--tools/perf/builtin-help.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 25c8b942ff85..411ee5664e98 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -30,23 +30,6 @@ enum help_format {
HELP_FORMAT_WEB,
};
-static bool show_all = false;
-static enum help_format help_format = HELP_FORMAT_NONE;
-static struct option builtin_help_options[] = {
- OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
- OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN),
- OPT_SET_UINT('w', "web", &help_format, "show manual in web browser",
- HELP_FORMAT_WEB),
- OPT_SET_UINT('i', "info", &help_format, "show info page",
- HELP_FORMAT_INFO),
- OPT_END(),
-};
-
-static const char * const builtin_help_usage[] = {
- "perf help [--all] [--man|--web|--info] [command]",
- NULL
-};
-
static enum help_format parse_help_format(const char *format)
{
if (!strcmp(format, "man"))
@@ -258,11 +241,13 @@ static int add_man_viewer_info(const char *var, const char *value)
static int perf_help_config(const char *var, const char *value, void *cb)
{
+ enum help_format *help_formatp = cb;
+
if (!strcmp(var, "help.format")) {
if (!value)
return config_error_nonbool(var);
- help_format = parse_help_format(value);
- if (help_format == HELP_FORMAT_NONE)
+ *help_formatp = parse_help_format(value);
+ if (*help_formatp == HELP_FORMAT_NONE)
return -1;
return 0;
}
@@ -428,12 +413,27 @@ static int show_html_page(const char *perf_cmd)
int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
{
+ bool show_all = false;
+ enum help_format help_format = HELP_FORMAT_NONE;
+ struct option builtin_help_options[] = {
+ OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
+ OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN),
+ OPT_SET_UINT('w', "web", &help_format, "show manual in web browser",
+ HELP_FORMAT_WEB),
+ OPT_SET_UINT('i', "info", &help_format, "show info page",
+ HELP_FORMAT_INFO),
+ OPT_END(),
+ };
+ const char * const builtin_help_usage[] = {
+ "perf help [--all] [--man|--web|--info] [command]",
+ NULL
+ };
const char *alias;
int rc = 0;
load_command_list("perf-", &main_cmds, &other_cmds);
- perf_config(perf_help_config, NULL);
+ perf_config(perf_help_config, &help_format);
argc = parse_options(argc, argv, builtin_help_options,
builtin_help_usage, 0);