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:35 -0400 |
| commit | 472cc83c3296cdc9248f1afbcfae8bba0f6f9707 (patch) | |
| tree | d0d2bf4c217e2fc0967194f490ddfeef3fe2b303 /tools/perf | |
| parent | 73bdc7159b0a83146fa8d1b8df7baf1cea992d4c (diff) | |
perf buildid-cache: 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-6i7lqzm4hmkg35o1370lb7w4@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/builtin-buildid-cache.c | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 83654557e108..d37e077f4b14 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
| @@ -15,22 +15,6 @@ | |||
| 15 | #include "util/strlist.h" | 15 | #include "util/strlist.h" |
| 16 | #include "util/symbol.h" | 16 | #include "util/symbol.h" |
| 17 | 17 | ||
| 18 | static char const *add_name_list_str, *remove_name_list_str; | ||
| 19 | |||
| 20 | static const char * const buildid_cache_usage[] = { | ||
| 21 | "perf buildid-cache [<options>]", | ||
| 22 | NULL | ||
| 23 | }; | ||
| 24 | |||
| 25 | static const struct option buildid_cache_options[] = { | ||
| 26 | OPT_STRING('a', "add", &add_name_list_str, | ||
| 27 | "file list", "file(s) to add"), | ||
| 28 | OPT_STRING('r', "remove", &remove_name_list_str, "file list", | ||
| 29 | "file(s) to remove"), | ||
| 30 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), | ||
| 31 | OPT_END() | ||
| 32 | }; | ||
| 33 | |||
| 34 | static int build_id_cache__add_file(const char *filename, const char *debugdir) | 18 | static int build_id_cache__add_file(const char *filename, const char *debugdir) |
| 35 | { | 19 | { |
| 36 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | 20 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; |
| @@ -51,8 +35,8 @@ static int build_id_cache__add_file(const char *filename, const char *debugdir) | |||
| 51 | return err; | 35 | return err; |
| 52 | } | 36 | } |
| 53 | 37 | ||
| 54 | static int build_id_cache__remove_file(const char *filename __maybe_unused, | 38 | static int build_id_cache__remove_file(const char *filename, |
| 55 | const char *debugdir __maybe_unused) | 39 | const char *debugdir) |
| 56 | { | 40 | { |
| 57 | u8 build_id[BUILD_ID_SIZE]; | 41 | u8 build_id[BUILD_ID_SIZE]; |
| 58 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | 42 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; |
| @@ -73,11 +57,34 @@ static int build_id_cache__remove_file(const char *filename __maybe_unused, | |||
| 73 | return err; | 57 | return err; |
| 74 | } | 58 | } |
| 75 | 59 | ||
| 76 | static int __cmd_buildid_cache(void) | 60 | int cmd_buildid_cache(int argc, const char **argv, |
| 61 | const char *prefix __maybe_unused) | ||
| 77 | { | 62 | { |
| 78 | struct strlist *list; | 63 | struct strlist *list; |
| 79 | struct str_node *pos; | 64 | struct str_node *pos; |
| 80 | char debugdir[PATH_MAX]; | 65 | char debugdir[PATH_MAX]; |
| 66 | char const *add_name_list_str = NULL, | ||
| 67 | *remove_name_list_str = NULL; | ||
| 68 | const struct option buildid_cache_options[] = { | ||
| 69 | OPT_STRING('a', "add", &add_name_list_str, | ||
| 70 | "file list", "file(s) to add"), | ||
| 71 | OPT_STRING('r', "remove", &remove_name_list_str, "file list", | ||
| 72 | "file(s) to remove"), | ||
| 73 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), | ||
| 74 | OPT_END() | ||
| 75 | }; | ||
| 76 | const char * const buildid_cache_usage[] = { | ||
| 77 | "perf buildid-cache [<options>]", | ||
| 78 | NULL | ||
| 79 | }; | ||
| 80 | |||
| 81 | argc = parse_options(argc, argv, buildid_cache_options, | ||
| 82 | buildid_cache_usage, 0); | ||
| 83 | |||
| 84 | if (symbol__init() < 0) | ||
| 85 | return -1; | ||
| 86 | |||
| 87 | setup_pager(); | ||
| 81 | 88 | ||
| 82 | snprintf(debugdir, sizeof(debugdir), "%s", buildid_dir); | 89 | snprintf(debugdir, sizeof(debugdir), "%s", buildid_dir); |
| 83 | 90 | ||
| @@ -119,16 +126,3 @@ static int __cmd_buildid_cache(void) | |||
| 119 | 126 | ||
| 120 | return 0; | 127 | return 0; |
| 121 | } | 128 | } |
| 122 | |||
| 123 | int cmd_buildid_cache(int argc, const char **argv, | ||
| 124 | const char *prefix __maybe_unused) | ||
| 125 | { | ||
| 126 | argc = parse_options(argc, argv, buildid_cache_options, | ||
| 127 | buildid_cache_usage, 0); | ||
| 128 | |||
| 129 | if (symbol__init() < 0) | ||
| 130 | return -1; | ||
| 131 | |||
| 132 | setup_pager(); | ||
| 133 | return __cmd_buildid_cache(); | ||
| 134 | } | ||
