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:36 -0400 |
commit | 6ee4149736e39deb7ed6d11c5de3101b5b8c2669 (patch) | |
tree | a99b87ec53a968abc02bb6e8388d83e01fc7e3d3 /tools/perf/builtin-buildid-list.c | |
parent | 472cc83c3296cdc9248f1afbcfae8bba0f6f9707 (diff) |
perf buildid-list: 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-ixb32cbcka9w1fk07xrksusf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-buildid-list.c')
-rw-r--r-- | tools/perf/builtin-buildid-list.c | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 1159feeebb19..a0e94fffa03e 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -16,27 +16,6 @@ | |||
16 | #include "util/session.h" | 16 | #include "util/session.h" |
17 | #include "util/symbol.h" | 17 | #include "util/symbol.h" |
18 | 18 | ||
19 | static const char *input_name; | ||
20 | static bool force; | ||
21 | static bool show_kernel; | ||
22 | static bool with_hits; | ||
23 | |||
24 | static const char * const buildid_list_usage[] = { | ||
25 | "perf buildid-list [<options>]", | ||
26 | NULL | ||
27 | }; | ||
28 | |||
29 | static const struct option options[] = { | ||
30 | OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"), | ||
31 | OPT_STRING('i', "input", &input_name, "file", | ||
32 | "input file name"), | ||
33 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | ||
34 | OPT_BOOLEAN('k', "kernel", &show_kernel, "Show current kernel build id"), | ||
35 | OPT_INCR('v', "verbose", &verbose, | ||
36 | "be more verbose"), | ||
37 | OPT_END() | ||
38 | }; | ||
39 | |||
40 | static int sysfs__fprintf_build_id(FILE *fp) | 19 | static int sysfs__fprintf_build_id(FILE *fp) |
41 | { | 20 | { |
42 | u8 kallsyms_build_id[BUILD_ID_SIZE]; | 21 | u8 kallsyms_build_id[BUILD_ID_SIZE]; |
@@ -65,7 +44,8 @@ static int filename__fprintf_build_id(const char *name, FILE *fp) | |||
65 | return fprintf(fp, "%s\n", sbuild_id); | 44 | return fprintf(fp, "%s\n", sbuild_id); |
66 | } | 45 | } |
67 | 46 | ||
68 | static int perf_session__list_build_ids(void) | 47 | static int perf_session__list_build_ids(const char *input_name, |
48 | bool force, bool with_hits) | ||
69 | { | 49 | { |
70 | struct perf_session *session; | 50 | struct perf_session *session; |
71 | 51 | ||
@@ -95,18 +75,31 @@ out: | |||
95 | return 0; | 75 | return 0; |
96 | } | 76 | } |
97 | 77 | ||
98 | static int __cmd_buildid_list(void) | ||
99 | { | ||
100 | if (show_kernel) | ||
101 | return sysfs__fprintf_build_id(stdout); | ||
102 | |||
103 | return perf_session__list_build_ids(); | ||
104 | } | ||
105 | |||
106 | int cmd_buildid_list(int argc, const char **argv, | 78 | int cmd_buildid_list(int argc, const char **argv, |
107 | const char *prefix __maybe_unused) | 79 | const char *prefix __maybe_unused) |
108 | { | 80 | { |
81 | bool show_kernel = false; | ||
82 | bool with_hits = false; | ||
83 | bool force = false; | ||
84 | const char *input_name = NULL; | ||
85 | const struct option options[] = { | ||
86 | OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"), | ||
87 | OPT_STRING('i', "input", &input_name, "file", "input file name"), | ||
88 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | ||
89 | OPT_BOOLEAN('k', "kernel", &show_kernel, "Show current kernel build id"), | ||
90 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), | ||
91 | OPT_END() | ||
92 | }; | ||
93 | const char * const buildid_list_usage[] = { | ||
94 | "perf buildid-list [<options>]", | ||
95 | NULL | ||
96 | }; | ||
97 | |||
109 | argc = parse_options(argc, argv, options, buildid_list_usage, 0); | 98 | argc = parse_options(argc, argv, options, buildid_list_usage, 0); |
110 | setup_pager(); | 99 | setup_pager(); |
111 | return __cmd_buildid_list(); | 100 | |
101 | if (show_kernel) | ||
102 | return sysfs__fprintf_build_id(stdout); | ||
103 | |||
104 | return perf_session__list_build_ids(input_name, force, with_hits); | ||
112 | } | 105 | } |