diff options
Diffstat (limited to 'tools/perf/builtin-help.c')
-rw-r--r-- | tools/perf/builtin-help.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 4fb8734a796e..215b584007b1 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -61,8 +61,7 @@ static const char *get_man_viewer_info(const char *name) | |||
61 | { | 61 | { |
62 | struct man_viewer_info_list *viewer; | 62 | struct man_viewer_info_list *viewer; |
63 | 63 | ||
64 | for (viewer = man_viewer_info_list; viewer; viewer = viewer->next) | 64 | for (viewer = man_viewer_info_list; viewer; viewer = viewer->next) { |
65 | { | ||
66 | if (!strcasecmp(name, viewer->name)) | 65 | if (!strcasecmp(name, viewer->name)) |
67 | return viewer->info; | 66 | return viewer->info; |
68 | } | 67 | } |
@@ -115,7 +114,7 @@ static int check_emacsclient_version(void) | |||
115 | return 0; | 114 | return 0; |
116 | } | 115 | } |
117 | 116 | ||
118 | static void exec_woman_emacs(const char* path, const char *page) | 117 | static void exec_woman_emacs(const char *path, const char *page) |
119 | { | 118 | { |
120 | if (!check_emacsclient_version()) { | 119 | if (!check_emacsclient_version()) { |
121 | /* This works only with emacsclient version >= 22. */ | 120 | /* This works only with emacsclient version >= 22. */ |
@@ -129,7 +128,7 @@ static void exec_woman_emacs(const char* path, const char *page) | |||
129 | } | 128 | } |
130 | } | 129 | } |
131 | 130 | ||
132 | static void exec_man_konqueror(const char* path, const char *page) | 131 | static void exec_man_konqueror(const char *path, const char *page) |
133 | { | 132 | { |
134 | const char *display = getenv("DISPLAY"); | 133 | const char *display = getenv("DISPLAY"); |
135 | if (display && *display) { | 134 | if (display && *display) { |
@@ -157,7 +156,7 @@ static void exec_man_konqueror(const char* path, const char *page) | |||
157 | } | 156 | } |
158 | } | 157 | } |
159 | 158 | ||
160 | static void exec_man_man(const char* path, const char *page) | 159 | static void exec_man_man(const char *path, const char *page) |
161 | { | 160 | { |
162 | if (!path) | 161 | if (!path) |
163 | path = "man"; | 162 | path = "man"; |
@@ -180,7 +179,7 @@ static void add_man_viewer(const char *name) | |||
180 | 179 | ||
181 | while (*p) | 180 | while (*p) |
182 | p = &((*p)->next); | 181 | p = &((*p)->next); |
183 | *p = calloc(1, (sizeof(**p) + len + 1)); | 182 | *p = zalloc(sizeof(**p) + len + 1); |
184 | strncpy((*p)->name, name, len); | 183 | strncpy((*p)->name, name, len); |
185 | } | 184 | } |
186 | 185 | ||
@@ -195,7 +194,7 @@ static void do_add_man_viewer_info(const char *name, | |||
195 | size_t len, | 194 | size_t len, |
196 | const char *value) | 195 | const char *value) |
197 | { | 196 | { |
198 | struct man_viewer_info_list *new = calloc(1, sizeof(*new) + len + 1); | 197 | struct man_viewer_info_list *new = zalloc(sizeof(*new) + len + 1); |
199 | 198 | ||
200 | strncpy(new->name, name, len); | 199 | strncpy(new->name, name, len); |
201 | new->info = strdup(value); | 200 | new->info = strdup(value); |
@@ -287,8 +286,7 @@ void list_common_cmds_help(void) | |||
287 | 286 | ||
288 | puts(" The most commonly used perf commands are:"); | 287 | puts(" The most commonly used perf commands are:"); |
289 | for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { | 288 | for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { |
290 | printf(" %s ", common_cmds[i].name); | 289 | printf(" %-*s ", longest, common_cmds[i].name); |
291 | mput_char(' ', longest - strlen(common_cmds[i].name)); | ||
292 | puts(common_cmds[i].help); | 290 | puts(common_cmds[i].help); |
293 | } | 291 | } |
294 | } | 292 | } |
@@ -315,8 +313,6 @@ static const char *cmd_to_page(const char *perf_cmd) | |||
315 | return "perf"; | 313 | return "perf"; |
316 | else if (!prefixcmp(perf_cmd, "perf")) | 314 | else if (!prefixcmp(perf_cmd, "perf")) |
317 | return perf_cmd; | 315 | return perf_cmd; |
318 | else if (is_perf_command(perf_cmd)) | ||
319 | return prepend("perf-", perf_cmd); | ||
320 | else | 316 | else |
321 | return prepend("perf-", perf_cmd); | 317 | return prepend("perf-", perf_cmd); |
322 | } | 318 | } |
@@ -364,9 +360,8 @@ static void show_man_page(const char *perf_cmd) | |||
364 | 360 | ||
365 | setup_man_path(); | 361 | setup_man_path(); |
366 | for (viewer = man_viewer_list; viewer; viewer = viewer->next) | 362 | for (viewer = man_viewer_list; viewer; viewer = viewer->next) |
367 | { | ||
368 | exec_viewer(viewer->name, page); /* will return when unable */ | 363 | exec_viewer(viewer->name, page); /* will return when unable */ |
369 | } | 364 | |
370 | if (fallback) | 365 | if (fallback) |
371 | exec_viewer(fallback, page); | 366 | exec_viewer(fallback, page); |
372 | exec_viewer("man", page); | 367 | exec_viewer("man", page); |