diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-01 14:20:58 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-02 17:36:31 -0400 |
| commit | 2bae1d1b1aa3b763b99431101a04dfe24ec5ba7f (patch) | |
| tree | 2f956a4e21553c3f2c9b2a063e9dc2555af717b9 /tools/perf | |
| parent | 69b6470e9ef3f6ea72b7e46e140d85970d8e1bc8 (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')
| -rw-r--r-- | tools/perf/builtin-help.c | 40 |
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 { | |||
| 30 | HELP_FORMAT_WEB, | 30 | HELP_FORMAT_WEB, |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | static bool show_all = false; | ||
| 34 | static enum help_format help_format = HELP_FORMAT_NONE; | ||
| 35 | static struct option builtin_help_options[] = { | ||
| 36 | OPT_BOOLEAN('a', "all", &show_all, "print all available commands"), | ||
| 37 | OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN), | ||
| 38 | OPT_SET_UINT('w', "web", &help_format, "show manual in web browser", | ||
| 39 | HELP_FORMAT_WEB), | ||
| 40 | OPT_SET_UINT('i', "info", &help_format, "show info page", | ||
| 41 | HELP_FORMAT_INFO), | ||
| 42 | OPT_END(), | ||
| 43 | }; | ||
| 44 | |||
| 45 | static const char * const builtin_help_usage[] = { | ||
| 46 | "perf help [--all] [--man|--web|--info] [command]", | ||
| 47 | NULL | ||
| 48 | }; | ||
| 49 | |||
| 50 | static enum help_format parse_help_format(const char *format) | 33 | static enum help_format parse_help_format(const char *format) |
| 51 | { | 34 | { |
| 52 | if (!strcmp(format, "man")) | 35 | if (!strcmp(format, "man")) |
| @@ -258,11 +241,13 @@ static int add_man_viewer_info(const char *var, const char *value) | |||
| 258 | 241 | ||
| 259 | static int perf_help_config(const char *var, const char *value, void *cb) | 242 | static int perf_help_config(const char *var, const char *value, void *cb) |
| 260 | { | 243 | { |
| 244 | enum help_format *help_formatp = cb; | ||
| 245 | |||
| 261 | if (!strcmp(var, "help.format")) { | 246 | if (!strcmp(var, "help.format")) { |
| 262 | if (!value) | 247 | if (!value) |
| 263 | return config_error_nonbool(var); | 248 | return config_error_nonbool(var); |
| 264 | help_format = parse_help_format(value); | 249 | *help_formatp = parse_help_format(value); |
| 265 | if (help_format == HELP_FORMAT_NONE) | 250 | if (*help_formatp == HELP_FORMAT_NONE) |
| 266 | return -1; | 251 | return -1; |
| 267 | return 0; | 252 | return 0; |
| 268 | } | 253 | } |
| @@ -428,12 +413,27 @@ static int show_html_page(const char *perf_cmd) | |||
| 428 | 413 | ||
| 429 | int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused) | 414 | int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused) |
| 430 | { | 415 | { |
| 416 | bool show_all = false; | ||
| 417 | enum help_format help_format = HELP_FORMAT_NONE; | ||
| 418 | struct option builtin_help_options[] = { | ||
| 419 | OPT_BOOLEAN('a', "all", &show_all, "print all available commands"), | ||
| 420 | OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN), | ||
| 421 | OPT_SET_UINT('w', "web", &help_format, "show manual in web browser", | ||
| 422 | HELP_FORMAT_WEB), | ||
| 423 | OPT_SET_UINT('i', "info", &help_format, "show info page", | ||
| 424 | HELP_FORMAT_INFO), | ||
| 425 | OPT_END(), | ||
| 426 | }; | ||
| 427 | const char * const builtin_help_usage[] = { | ||
| 428 | "perf help [--all] [--man|--web|--info] [command]", | ||
| 429 | NULL | ||
| 430 | }; | ||
| 431 | const char *alias; | 431 | const char *alias; |
| 432 | int rc = 0; | 432 | int rc = 0; |
| 433 | 433 | ||
| 434 | load_command_list("perf-", &main_cmds, &other_cmds); | 434 | load_command_list("perf-", &main_cmds, &other_cmds); |
| 435 | 435 | ||
| 436 | perf_config(perf_help_config, NULL); | 436 | perf_config(perf_help_config, &help_format); |
| 437 | 437 | ||
| 438 | argc = parse_options(argc, argv, builtin_help_options, | 438 | argc = parse_options(argc, argv, builtin_help_options, |
| 439 | builtin_help_usage, 0); | 439 | builtin_help_usage, 0); |
