summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-07-26 19:07:30 +0200
committerIngo Molnar <mingo@kernel.org>2017-07-26 19:07:30 +0200
commitee438ec8f33c5af0d4a4ffb935c5b9272e8c2680 (patch)
treed95fe900307968a2874b5cd64e09bbb378c77e23 /tools/lib
parent510457ec9dc259b002879bcfe475f89d4514a0fc (diff)
parent62e6039f02888efdd824e8c596c4927616a97ce3 (diff)
downloadtalos-obmc-linux-ee438ec8f33c5af0d4a4ffb935c5b9272e8c2680.tar.gz
talos-obmc-linux-ee438ec8f33c5af0d4a4ffb935c5b9272e8c2680.zip
Merge tag 'perf-core-for-mingo-4.14-20170725' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvemends and fixes for v4.14: New features: - Filter out 'sshd' in the tracer ancestry in 'perf trace' syswide tracing, to elliminate tracing loops (Arnaldo Carvalho de Melo) - Support lookup of symbols in other mount namespaces in 'perf top' (Krister Johansen) - Initial 'clone' syscall args beautifier in 'perf trace' (Arnaldo Carvalho de Melo) User visible changes: - Ignore 'fd' and 'offset' args for MAP_ANONYMOUS in 'perf trace' (Arnaldo Carvalho de Melo) - Process tracing data in 'perf annotate' pipe mode (David Carrillo-Cisneros) - Make 'perf report --branch-history' work without callgraphs(-g) option in perf record (Jin Yao) - Tag branch type/flag on "to" and tag cycles on "from" in 'perf report' (Jin Yao) Fixes: - Fix jvmti linker error when libelf config is disabled (Sudeep Holla) - Fix cgroups refcount usage (Arnaldo Carvalho de Melo) - Fix kernel symbol adjustment for s390x (Thomas Richter) - Fix 'perf report --stdio --show-total-period', it was showing the number of samples, not the total period (Taeung Song) Infrastructure changes: - Add perf_sample dictionary to tracepoint handlers in 'perf script' python, which were already present for other types of events (hardware, etc) (Arun Kalyanasundaram) - Make build fail on vendor events JSON parse error (Andi Kleen) - Adopt strstarts() from the kernel (Arnaldo Carvalho de Melo) Arch specific changes: - Set no_aux_samples for the tracking event in Intel PT (Kan Liang) - Always set no branch for Intel PT dummy event (Kan Liang) Trivial changes: - Simplify some error handlers in 'perf script' (Dan Carpenter) - Add EXCLUDE_EXTLIBS and EXTRA_PERFLIBS to makefile (David Carrillo-Cisneros) Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/string.c41
-rw-r--r--tools/lib/subcmd/help.c2
-rw-r--r--tools/lib/subcmd/parse-options.c18
3 files changed, 35 insertions, 26 deletions
diff --git a/tools/lib/string.c b/tools/lib/string.c
index 8e678af1c6ee..a4246f14ded1 100644
--- a/tools/lib/string.c
+++ b/tools/lib/string.c
@@ -39,27 +39,45 @@ void *memdup(const void *src, size_t len)
* @s: input string
* @res: result
*
- * This routine returns 0 iff the first character is one of 'Yy1Nn0'.
- * Otherwise it will return -EINVAL. Value pointed to by res is
- * updated upon finding a match.
+ * This routine returns 0 iff the first character is one of 'Yy1Nn0', or
+ * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value
+ * pointed to by res is updated upon finding a match.
*/
int strtobool(const char *s, bool *res)
{
+ if (!s)
+ return -EINVAL;
+
switch (s[0]) {
case 'y':
case 'Y':
case '1':
*res = true;
- break;
+ return 0;
case 'n':
case 'N':
case '0':
*res = false;
- break;
+ return 0;
+ case 'o':
+ case 'O':
+ switch (s[1]) {
+ case 'n':
+ case 'N':
+ *res = true;
+ return 0;
+ case 'f':
+ case 'F':
+ *res = false;
+ return 0;
+ default:
+ break;
+ }
default:
- return -EINVAL;
+ break;
}
- return 0;
+
+ return -EINVAL;
}
/**
@@ -87,12 +105,3 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size)
}
return ret;
}
-
-int prefixcmp(const char *str, const char *prefix)
-{
- for (; ; str++, prefix++)
- if (!*prefix)
- return 0;
- else if (*str != *prefix)
- return (unsigned char)*prefix - (unsigned char)*str;
-}
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,
while ((de = readdir(dir)) != NULL) {
int entlen;
- if (prefixcmp(de->d_name, prefix))
+ if (!strstarts(de->d_name, prefix))
continue;
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:
return 0;
}
if (!rest) {
- if (!prefixcmp(options->long_name, "no-")) {
+ if (strstarts(options->long_name, "no-")) {
/*
* The long name itself starts with "no-", so
* accept the option without "no-" so that users
@@ -381,7 +381,7 @@ retry:
goto match;
}
/* Abbreviated case */
- if (!prefixcmp(options->long_name + 3, arg)) {
+ if (strstarts(options->long_name + 3, arg)) {
flags |= OPT_UNSET;
goto is_abbreviated;
}
@@ -406,7 +406,7 @@ is_abbreviated:
continue;
}
/* negated and abbreviated very much? */
- if (!prefixcmp("no-", arg)) {
+ if (strstarts("no-", arg)) {
flags |= OPT_UNSET;
goto is_abbreviated;
}
@@ -416,7 +416,7 @@ is_abbreviated:
flags |= OPT_UNSET;
rest = skip_prefix(arg + 3, options->long_name);
/* abbreviated and negated? */
- if (!rest && !prefixcmp(options->long_name, arg + 3))
+ if (!rest && strstarts(options->long_name, arg + 3))
goto is_abbreviated;
if (!rest)
continue;
@@ -456,7 +456,7 @@ static void check_typos(const char *arg, const struct option *options)
if (strlen(arg) < 3)
return;
- if (!prefixcmp(arg, "no-")) {
+ if (strstarts(arg, "no-")) {
fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg);
exit(129);
}
@@ -464,7 +464,7 @@ static void check_typos(const char *arg, const struct option *options)
for (; options->type != OPTION_END; options++) {
if (!options->long_name)
continue;
- if (!prefixcmp(options->long_name, arg)) {
+ if (strstarts(options->long_name, arg)) {
fprintf(stderr, " Error: did you mean `--%s` (with two dashes ?)", arg);
exit(129);
}
@@ -933,10 +933,10 @@ opt:
if (opts->long_name == NULL)
continue;
- if (!prefixcmp(opts->long_name, optstr))
+ if (strstarts(opts->long_name, optstr))
print_option_help(opts, 0);
- if (!prefixcmp("no-", optstr) &&
- !prefixcmp(opts->long_name, optstr + 3))
+ if (strstarts("no-", optstr) &&
+ strstarts(opts->long_name, optstr + 3))
print_option_help(opts, 0);
}
OpenPOWER on IntegriCloud