Commit 472cc83c3296cdc9248f1afbcfae8bba0f6f9707

Authored by Arnaldo Carvalho de Melo
1 parent 73bdc7159b

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>

Showing 1 changed file with 26 additions and 32 deletions Side-by-side Diff

tools/perf/builtin-buildid-cache.c
... ... @@ -15,22 +15,6 @@
15 15 #include "util/strlist.h"
16 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 18 static int build_id_cache__add_file(const char *filename, const char *debugdir)
35 19 {
36 20 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
... ... @@ -51,8 +35,8 @@
51 35 return err;
52 36 }
53 37  
54   -static int build_id_cache__remove_file(const char *filename __maybe_unused,
55   - const char *debugdir __maybe_unused)
  38 +static int build_id_cache__remove_file(const char *filename,
  39 + const char *debugdir)
56 40 {
57 41 u8 build_id[BUILD_ID_SIZE];
58 42 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
59 43  
60 44  
... ... @@ -73,12 +57,35 @@
73 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 63 struct strlist *list;
79 64 struct str_node *pos;
80 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 + };
81 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();
  88 +
82 89 snprintf(debugdir, sizeof(debugdir), "%s", buildid_dir);
83 90  
84 91 if (add_name_list_str) {
... ... @@ -118,18 +125,5 @@
118 125 }
119 126  
120 127 return 0;
121   -}
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 128 }