diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-07-20 14:27:39 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-07-20 14:46:10 -0400 |
commit | 8e99b6d4533cf3f49dcd813155a513a5b572baef (patch) | |
tree | f3f082ab6d3e1916353b59e7f70735183cc72722 | |
parent | 082ab9a18e532864d1ceecfb50221df62b1d5a92 (diff) |
tools include: Adopt strstarts() from the kernel
Replacing prefixcmp(), same purpose, inverted result, so standardize on
the kernel variant, to reduce silly differences among tools/ and the
kernel sources, making it easier for people to work in both codebases.
And then doing:
if (strstarts(option, "no-"))
Looks clearer than doing:
if (!prefixcmp(option, "no-"))
To figure out if option starts witn "no-".
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-kaei42gi7lpa8subwtv7eug8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/include/linux/string.h | 12 | ||||
-rw-r--r-- | tools/lib/string.c | 9 | ||||
-rw-r--r-- | tools/lib/subcmd/help.c | 2 | ||||
-rw-r--r-- | tools/lib/subcmd/parse-options.c | 18 | ||||
-rw-r--r-- | tools/perf/builtin-config.c | 3 | ||||
-rw-r--r-- | tools/perf/builtin-ftrace.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-help.c | 6 | ||||
-rw-r--r-- | tools/perf/perf.c | 16 | ||||
-rw-r--r-- | tools/perf/ui/browser.c | 3 | ||||
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 3 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 3 | ||||
-rw-r--r-- | tools/perf/util/bpf-loader.c | 2 | ||||
-rw-r--r-- | tools/perf/util/callchain.c | 2 | ||||
-rw-r--r-- | tools/perf/util/config.c | 13 | ||||
-rw-r--r-- | tools/perf/util/llvm-utils.c | 2 |
15 files changed, 50 insertions, 46 deletions
diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h index d62b56cf8c12..a30fad536f52 100644 --- a/tools/include/linux/string.h +++ b/tools/include/linux/string.h | |||
@@ -1,8 +1,8 @@ | |||
1 | #ifndef _TOOLS_LINUX_STRING_H_ | 1 | #ifndef _TOOLS_LINUX_STRING_H_ |
2 | #define _TOOLS_LINUX_STRING_H_ | 2 | #define _TOOLS_LINUX_STRING_H_ |
3 | 3 | ||
4 | |||
5 | #include <linux/types.h> /* for size_t */ | 4 | #include <linux/types.h> /* for size_t */ |
5 | #include <string.h> | ||
6 | 6 | ||
7 | void *memdup(const void *src, size_t len); | 7 | void *memdup(const void *src, size_t len); |
8 | 8 | ||
@@ -18,6 +18,14 @@ extern size_t strlcpy(char *dest, const char *src, size_t size); | |||
18 | 18 | ||
19 | char *str_error_r(int errnum, char *buf, size_t buflen); | 19 | char *str_error_r(int errnum, char *buf, size_t buflen); |
20 | 20 | ||
21 | int prefixcmp(const char *str, const char *prefix); | 21 | /** |
22 | * strstarts - does @str start with @prefix? | ||
23 | * @str: string to examine | ||
24 | * @prefix: prefix to look for. | ||
25 | */ | ||
26 | static inline bool strstarts(const char *str, const char *prefix) | ||
27 | { | ||
28 | return strncmp(str, prefix, strlen(prefix)) == 0; | ||
29 | } | ||
22 | 30 | ||
23 | #endif /* _LINUX_STRING_H_ */ | 31 | #endif /* _LINUX_STRING_H_ */ |
diff --git a/tools/lib/string.c b/tools/lib/string.c index 8e678af1c6ee..bd239bc1d557 100644 --- a/tools/lib/string.c +++ b/tools/lib/string.c | |||
@@ -87,12 +87,3 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size) | |||
87 | } | 87 | } |
88 | return ret; | 88 | return ret; |
89 | } | 89 | } |
90 | |||
91 | int prefixcmp(const char *str, const char *prefix) | ||
92 | { | ||
93 | for (; ; str++, prefix++) | ||
94 | if (!*prefix) | ||
95 | return 0; | ||
96 | else if (*str != *prefix) | ||
97 | return (unsigned char)*prefix - (unsigned char)*str; | ||
98 | } | ||
diff --git a/tools/lib/subcmd/help.c b/tools/lib/subcmd/help.c index ba970a73d053..0310520f918e 100644 --- a/tools/lib/subcmd/help.c +++ b/tools/lib/subcmd/help.c | |||
@@ -171,7 +171,7 @@ static void list_commands_in_dir(struct cmdnames *cmds, | |||
171 | while ((de = readdir(dir)) != NULL) { | 171 | while ((de = readdir(dir)) != NULL) { |
172 | int entlen; | 172 | int entlen; |
173 | 173 | ||
174 | if (prefixcmp(de->d_name, prefix)) | 174 | if (!strstarts(de->d_name, prefix)) |
175 | continue; | 175 | continue; |
176 | 176 | ||
177 | astrcat(&buf, de->d_name); | 177 | astrcat(&buf, de->d_name); |
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index 359bfa77f39c..2bd6fd0c1d40 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c | |||
@@ -368,7 +368,7 @@ retry: | |||
368 | return 0; | 368 | return 0; |
369 | } | 369 | } |
370 | if (!rest) { | 370 | if (!rest) { |
371 | if (!prefixcmp(options->long_name, "no-")) { | 371 | if (strstarts(options->long_name, "no-")) { |
372 | /* | 372 | /* |
373 | * The long name itself starts with "no-", so | 373 | * The long name itself starts with "no-", so |
374 | * accept the option without "no-" so that users | 374 | * accept the option without "no-" so that users |
@@ -381,7 +381,7 @@ retry: | |||
381 | goto match; | 381 | goto match; |
382 | } | 382 | } |
383 | /* Abbreviated case */ | 383 | /* Abbreviated case */ |
384 | if (!prefixcmp(options->long_name + 3, arg)) { | 384 | if (strstarts(options->long_name + 3, arg)) { |
385 | flags |= OPT_UNSET; | 385 | flags |= OPT_UNSET; |
386 | goto is_abbreviated; | 386 | goto is_abbreviated; |
387 | } | 387 | } |
@@ -406,7 +406,7 @@ is_abbreviated: | |||
406 | continue; | 406 | continue; |
407 | } | 407 | } |
408 | /* negated and abbreviated very much? */ | 408 | /* negated and abbreviated very much? */ |
409 | if (!prefixcmp("no-", arg)) { | 409 | if (strstarts("no-", arg)) { |
410 | flags |= OPT_UNSET; | 410 | flags |= OPT_UNSET; |
411 | goto is_abbreviated; | 411 | goto is_abbreviated; |
412 | } | 412 | } |
@@ -416,7 +416,7 @@ is_abbreviated: | |||
416 | flags |= OPT_UNSET; | 416 | flags |= OPT_UNSET; |
417 | rest = skip_prefix(arg + 3, options->long_name); | 417 | rest = skip_prefix(arg + 3, options->long_name); |
418 | /* abbreviated and negated? */ | 418 | /* abbreviated and negated? */ |
419 | if (!rest && !prefixcmp(options->long_name, arg + 3)) | 419 | if (!rest && strstarts(options->long_name, arg + 3)) |
420 | goto is_abbreviated; | 420 | goto is_abbreviated; |
421 | if (!rest) | 421 | if (!rest) |
422 | continue; | 422 | continue; |
@@ -456,7 +456,7 @@ static void check_typos(const char *arg, const struct option *options) | |||
456 | if (strlen(arg) < 3) | 456 | if (strlen(arg) < 3) |
457 | return; | 457 | return; |
458 | 458 | ||
459 | if (!prefixcmp(arg, "no-")) { | 459 | if (strstarts(arg, "no-")) { |
460 | fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg); | 460 | fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg); |
461 | exit(129); | 461 | exit(129); |
462 | } | 462 | } |
@@ -464,7 +464,7 @@ static void check_typos(const char *arg, const struct option *options) | |||
464 | for (; options->type != OPTION_END; options++) { | 464 | for (; options->type != OPTION_END; options++) { |
465 | if (!options->long_name) | 465 | if (!options->long_name) |
466 | continue; | 466 | continue; |
467 | if (!prefixcmp(options->long_name, arg)) { | 467 | if (strstarts(options->long_name, arg)) { |
468 | fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg); | 468 | fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg); |
469 | exit(129); | 469 | exit(129); |
470 | } | 470 | } |
@@ -933,10 +933,10 @@ opt: | |||
933 | if (opts->long_name == NULL) | 933 | if (opts->long_name == NULL) |
934 | continue; | 934 | continue; |
935 | 935 | ||
936 | if (!prefixcmp(opts->long_name, optstr)) | 936 | if (strstarts(opts->long_name, optstr)) |
937 | print_option_help(opts, 0); | 937 | print_option_help(opts, 0); |
938 | if (!prefixcmp("no-", optstr) && | 938 | if (strstarts("no-", optstr) && |
939 | !prefixcmp(opts->long_name, optstr + 3)) | 939 | strstarts(opts->long_name, optstr + 3)) |
940 | print_option_help(opts, 0); | 940 | print_option_help(opts, 0); |
941 | } | 941 | } |
942 | 942 | ||
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index ece45582a48d..3ddcc6e2abeb 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "util/util.h" | 13 | #include "util/util.h" |
14 | #include "util/debug.h" | 14 | #include "util/debug.h" |
15 | #include "util/config.h" | 15 | #include "util/config.h" |
16 | #include <linux/string.h> | ||
16 | 17 | ||
17 | static bool use_system_config, use_user_config; | 18 | static bool use_system_config, use_user_config; |
18 | 19 | ||
@@ -79,7 +80,7 @@ static int show_spec_config(struct perf_config_set *set, const char *var) | |||
79 | return -1; | 80 | return -1; |
80 | 81 | ||
81 | perf_config_items__for_each_entry(&set->sections, section) { | 82 | perf_config_items__for_each_entry(&set->sections, section) { |
82 | if (prefixcmp(var, section->name) != 0) | 83 | if (!strstarts(var, section->name)) |
83 | continue; | 84 | continue; |
84 | 85 | ||
85 | perf_config_items__for_each_entry(§ion->items, item) { | 86 | perf_config_items__for_each_entry(§ion->items, item) { |
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index dd26c62c9893..25a42acabee1 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c | |||
@@ -381,7 +381,7 @@ static int perf_ftrace_config(const char *var, const char *value, void *cb) | |||
381 | { | 381 | { |
382 | struct perf_ftrace *ftrace = cb; | 382 | struct perf_ftrace *ftrace = cb; |
383 | 383 | ||
384 | if (prefixcmp(var, "ftrace.")) | 384 | if (!strstarts(var, "ftrace.")) |
385 | return 0; | 385 | return 0; |
386 | 386 | ||
387 | if (strcmp(var, "ftrace.tracer")) | 387 | if (strcmp(var, "ftrace.tracer")) |
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 530a7f2fa0f3..dbe4e4153bcf 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -90,7 +90,7 @@ static int check_emacsclient_version(void) | |||
90 | */ | 90 | */ |
91 | finish_command(&ec_process); | 91 | finish_command(&ec_process); |
92 | 92 | ||
93 | if (prefixcmp(buffer.buf, "emacsclient")) { | 93 | if (!strstarts(buffer.buf, "emacsclient")) { |
94 | fprintf(stderr, "Failed to parse emacsclient version.\n"); | 94 | fprintf(stderr, "Failed to parse emacsclient version.\n"); |
95 | goto out; | 95 | goto out; |
96 | } | 96 | } |
@@ -283,7 +283,7 @@ static int perf_help_config(const char *var, const char *value, void *cb) | |||
283 | add_man_viewer(value); | 283 | add_man_viewer(value); |
284 | return 0; | 284 | return 0; |
285 | } | 285 | } |
286 | if (!prefixcmp(var, "man.")) | 286 | if (!strstarts(var, "man.")) |
287 | return add_man_viewer_info(var, value); | 287 | return add_man_viewer_info(var, value); |
288 | 288 | ||
289 | return 0; | 289 | return 0; |
@@ -313,7 +313,7 @@ static const char *cmd_to_page(const char *perf_cmd) | |||
313 | 313 | ||
314 | if (!perf_cmd) | 314 | if (!perf_cmd) |
315 | return "perf"; | 315 | return "perf"; |
316 | else if (!prefixcmp(perf_cmd, "perf")) | 316 | else if (!strstarts(perf_cmd, "perf")) |
317 | return perf_cmd; | 317 | return perf_cmd; |
318 | 318 | ||
319 | return asprintf(&s, "perf-%s", perf_cmd) < 0 ? NULL : s; | 319 | return asprintf(&s, "perf-%s", perf_cmd) < 0 ? NULL : s; |
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 628a5e412cb1..e0279babe0c0 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -89,7 +89,7 @@ struct pager_config { | |||
89 | static int pager_command_config(const char *var, const char *value, void *data) | 89 | static int pager_command_config(const char *var, const char *value, void *data) |
90 | { | 90 | { |
91 | struct pager_config *c = data; | 91 | struct pager_config *c = data; |
92 | if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd)) | 92 | if (strstarts(var, "pager.") && !strcmp(var + 6, c->cmd)) |
93 | c->val = perf_config_bool(var, value); | 93 | c->val = perf_config_bool(var, value); |
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
@@ -108,9 +108,9 @@ static int check_pager_config(const char *cmd) | |||
108 | static int browser_command_config(const char *var, const char *value, void *data) | 108 | static int browser_command_config(const char *var, const char *value, void *data) |
109 | { | 109 | { |
110 | struct pager_config *c = data; | 110 | struct pager_config *c = data; |
111 | if (!prefixcmp(var, "tui.") && !strcmp(var + 4, c->cmd)) | 111 | if (strstarts(var, "tui.") && !strcmp(var + 4, c->cmd)) |
112 | c->val = perf_config_bool(var, value); | 112 | c->val = perf_config_bool(var, value); |
113 | if (!prefixcmp(var, "gtk.") && !strcmp(var + 4, c->cmd)) | 113 | if (strstarts(var, "gtk.") && !strcmp(var + 4, c->cmd)) |
114 | c->val = perf_config_bool(var, value) ? 2 : 0; | 114 | c->val = perf_config_bool(var, value) ? 2 : 0; |
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
@@ -192,7 +192,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) | |||
192 | /* | 192 | /* |
193 | * Check remaining flags. | 193 | * Check remaining flags. |
194 | */ | 194 | */ |
195 | if (!prefixcmp(cmd, CMD_EXEC_PATH)) { | 195 | if (strstarts(cmd, CMD_EXEC_PATH)) { |
196 | cmd += strlen(CMD_EXEC_PATH); | 196 | cmd += strlen(CMD_EXEC_PATH); |
197 | if (*cmd == '=') | 197 | if (*cmd == '=') |
198 | set_argv_exec_path(cmd + 1); | 198 | set_argv_exec_path(cmd + 1); |
@@ -229,7 +229,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) | |||
229 | *envchanged = 1; | 229 | *envchanged = 1; |
230 | (*argv)++; | 230 | (*argv)++; |
231 | (*argc)--; | 231 | (*argc)--; |
232 | } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { | 232 | } else if (strstarts(cmd, CMD_DEBUGFS_DIR)) { |
233 | tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR)); | 233 | tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR)); |
234 | fprintf(stderr, "dir: %s\n", tracing_path); | 234 | fprintf(stderr, "dir: %s\n", tracing_path); |
235 | if (envchanged) | 235 | if (envchanged) |
@@ -470,14 +470,14 @@ int main(int argc, const char **argv) | |||
470 | * So we just directly call the internal command handler, and | 470 | * So we just directly call the internal command handler, and |
471 | * die if that one cannot handle it. | 471 | * die if that one cannot handle it. |
472 | */ | 472 | */ |
473 | if (!prefixcmp(cmd, "perf-")) { | 473 | if (strstarts(cmd, "perf-")) { |
474 | cmd += 5; | 474 | cmd += 5; |
475 | argv[0] = cmd; | 475 | argv[0] = cmd; |
476 | handle_internal_command(argc, argv); | 476 | handle_internal_command(argc, argv); |
477 | fprintf(stderr, "cannot handle %s internally", cmd); | 477 | fprintf(stderr, "cannot handle %s internally", cmd); |
478 | goto out; | 478 | goto out; |
479 | } | 479 | } |
480 | if (!prefixcmp(cmd, "trace")) { | 480 | if (strstarts(cmd, "trace")) { |
481 | #ifdef HAVE_LIBAUDIT_SUPPORT | 481 | #ifdef HAVE_LIBAUDIT_SUPPORT |
482 | setup_path(); | 482 | setup_path(); |
483 | argv[0] = "trace"; | 483 | argv[0] = "trace"; |
@@ -495,7 +495,7 @@ int main(int argc, const char **argv) | |||
495 | commit_pager_choice(); | 495 | commit_pager_choice(); |
496 | 496 | ||
497 | if (argc > 0) { | 497 | if (argc > 0) { |
498 | if (!prefixcmp(argv[0], "--")) | 498 | if (strstarts(argv[0], "--")) |
499 | argv[0] += 2; | 499 | argv[0] += 2; |
500 | } else { | 500 | } else { |
501 | /* The user didn't specify a command; give them help */ | 501 | /* The user didn't specify a command; give them help */ |
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index f73f3f13e01d..d0c2007c307b 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/compiler.h> | 8 | #include <linux/compiler.h> |
9 | #include <linux/list.h> | 9 | #include <linux/list.h> |
10 | #include <linux/rbtree.h> | 10 | #include <linux/rbtree.h> |
11 | #include <linux/string.h> | ||
11 | #include <stdlib.h> | 12 | #include <stdlib.h> |
12 | #include <sys/ttydefaults.h> | 13 | #include <sys/ttydefaults.h> |
13 | #include "browser.h" | 14 | #include "browser.h" |
@@ -563,7 +564,7 @@ static int ui_browser__color_config(const char *var, const char *value, | |||
563 | int i; | 564 | int i; |
564 | 565 | ||
565 | /* same dir for all commands */ | 566 | /* same dir for all commands */ |
566 | if (prefixcmp(var, "colors.") != 0) | 567 | if (!strstarts(var, "colors.") != 0) |
567 | return 0; | 568 | return 0; |
568 | 569 | ||
569 | for (i = 0; ui_browser__colorsets[i].name != NULL; ++i) { | 570 | for (i = 0; ui_browser__colorsets[i].name != NULL; ++i) { |
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 8d3f6f53c122..6794a8bec404 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <inttypes.h> | 13 | #include <inttypes.h> |
14 | #include <pthread.h> | 14 | #include <pthread.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/string.h> | ||
16 | #include <sys/ttydefaults.h> | 17 | #include <sys/ttydefaults.h> |
17 | 18 | ||
18 | struct disasm_line_samples { | 19 | struct disasm_line_samples { |
@@ -1198,7 +1199,7 @@ static int annotate__config(const char *var, const char *value, | |||
1198 | struct annotate_config *cfg; | 1199 | struct annotate_config *cfg; |
1199 | const char *name; | 1200 | const char *name; |
1200 | 1201 | ||
1201 | if (prefixcmp(var, "annotate.") != 0) | 1202 | if (!strstarts(var, "annotate.")) |
1202 | return 0; | 1203 | return 0; |
1203 | 1204 | ||
1204 | name = var + 9; | 1205 | name = var + 9; |
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 2df8eb1ed3c0..5c95b8301c67 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <linux/string.h> | ||
2 | 3 | ||
3 | #include "../../util/util.h" | 4 | #include "../../util/util.h" |
4 | #include "../../util/hist.h" | 5 | #include "../../util/hist.h" |
@@ -292,7 +293,7 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root, | |||
292 | * displayed twice. | 293 | * displayed twice. |
293 | */ | 294 | */ |
294 | if (!i++ && field_order == NULL && | 295 | if (!i++ && field_order == NULL && |
295 | sort_order && !prefixcmp(sort_order, "sym")) | 296 | sort_order && strstarts(sort_order, "sym")) |
296 | continue; | 297 | continue; |
297 | 298 | ||
298 | if (!printed) { | 299 | if (!printed) { |
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 4bd2d1d882af..4a1264c66101 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c | |||
@@ -1246,7 +1246,7 @@ int bpf__config_obj(struct bpf_object *obj, | |||
1246 | if (!obj || !term || !term->config) | 1246 | if (!obj || !term || !term->config) |
1247 | return -EINVAL; | 1247 | return -EINVAL; |
1248 | 1248 | ||
1249 | if (!prefixcmp(term->config, "map:")) { | 1249 | if (strstarts(term->config, "map:")) { |
1250 | key_scan_pos = sizeof("map:") - 1; | 1250 | key_scan_pos = sizeof("map:") - 1; |
1251 | err = bpf__obj_config_map(obj, term, evlist, &key_scan_pos); | 1251 | err = bpf__obj_config_map(obj, term, evlist, &key_scan_pos); |
1252 | goto out; | 1252 | goto out; |
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 22d413ae6025..02130e2e72c7 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -304,7 +304,7 @@ int perf_callchain_config(const char *var, const char *value) | |||
304 | { | 304 | { |
305 | char *endptr; | 305 | char *endptr; |
306 | 306 | ||
307 | if (prefixcmp(var, "call-graph.")) | 307 | if (!strstarts(var, "call-graph.")) |
308 | return 0; | 308 | return 0; |
309 | var += sizeof("call-graph.") - 1; | 309 | var += sizeof("call-graph.") - 1; |
310 | 310 | ||
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 31a7dea248d0..bc75596f9e79 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <sys/types.h> | 19 | #include <sys/types.h> |
20 | #include <sys/stat.h> | 20 | #include <sys/stat.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <linux/string.h> | ||
22 | 23 | ||
23 | #include "sane_ctype.h" | 24 | #include "sane_ctype.h" |
24 | 25 | ||
@@ -433,22 +434,22 @@ static int perf_ui_config(const char *var, const char *value) | |||
433 | int perf_default_config(const char *var, const char *value, | 434 | int perf_default_config(const char *var, const char *value, |
434 | void *dummy __maybe_unused) | 435 | void *dummy __maybe_unused) |
435 | { | 436 | { |
436 | if (!prefixcmp(var, "core.")) | 437 | if (strstarts(var, "core.")) |
437 | return perf_default_core_config(var, value); | 438 | return perf_default_core_config(var, value); |
438 | 439 | ||
439 | if (!prefixcmp(var, "hist.")) | 440 | if (strstarts(var, "hist.")) |
440 | return perf_hist_config(var, value); | 441 | return perf_hist_config(var, value); |
441 | 442 | ||
442 | if (!prefixcmp(var, "ui.")) | 443 | if (strstarts(var, "ui.")) |
443 | return perf_ui_config(var, value); | 444 | return perf_ui_config(var, value); |
444 | 445 | ||
445 | if (!prefixcmp(var, "call-graph.")) | 446 | if (strstarts(var, "call-graph.")) |
446 | return perf_callchain_config(var, value); | 447 | return perf_callchain_config(var, value); |
447 | 448 | ||
448 | if (!prefixcmp(var, "llvm.")) | 449 | if (strstarts(var, "llvm.")) |
449 | return perf_llvm_config(var, value); | 450 | return perf_llvm_config(var, value); |
450 | 451 | ||
451 | if (!prefixcmp(var, "buildid.")) | 452 | if (strstarts(var, "buildid.")) |
452 | return perf_buildid_config(var, value); | 453 | return perf_buildid_config(var, value); |
453 | 454 | ||
454 | /* Add other config variables here. */ | 455 | /* Add other config variables here. */ |
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c index c6a15f204c03..209b0c82eff4 100644 --- a/tools/perf/util/llvm-utils.c +++ b/tools/perf/util/llvm-utils.c | |||
@@ -33,7 +33,7 @@ struct llvm_param llvm_param = { | |||
33 | 33 | ||
34 | int perf_llvm_config(const char *var, const char *value) | 34 | int perf_llvm_config(const char *var, const char *value) |
35 | { | 35 | { |
36 | if (prefixcmp(var, "llvm.")) | 36 | if (!strstarts(var, "llvm.")) |
37 | return 0; | 37 | return 0; |
38 | var += sizeof("llvm.") - 1; | 38 | var += sizeof("llvm.") - 1; |
39 | 39 | ||