diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-26 17:42:03 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-26 17:42:03 +0300 |
commit | 328584804edc950fb4608c9a38e396ac71ef22b6 (patch) | |
tree | ea398fb09a36ea3af7f213ccbb2179b1889985d5 /tools/perf/util | |
parent | 526bbbdd442ce143b52cd6a8b4ee424f9930be0d (diff) | |
download | linux-328584804edc950fb4608c9a38e396ac71ef22b6.tar.xz |
perf tools: Ditch rtrim(), use skip_spaces() to get closer to the kernel
No change in behaviour, just using the same kernel idiom for such
operation.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: André Goddard Rosa <andre.goddard@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-a85lkptkt0ru40irpga8yf54@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/annotate.c | 10 | ||||
-rw-r--r-- | tools/perf/util/event.c | 4 | ||||
-rw-r--r-- | tools/perf/util/pmu.c | 3 | ||||
-rw-r--r-- | tools/perf/util/stat-display.c | 4 | ||||
-rw-r--r-- | tools/perf/util/string.c | 14 | ||||
-rw-r--r-- | tools/perf/util/string2.h | 4 |
6 files changed, 12 insertions, 27 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 65005ccea232..783e2628cc8e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -557,7 +557,7 @@ static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_sy if (comment == NULL) return 0; - comment = ltrim(comment); + comment = skip_spaces(comment); comment__symbol(ops->source.raw, comment + 1, &ops->source.addr, &ops->source.name); comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name); @@ -602,7 +602,7 @@ static int dec__parse(struct arch *arch __maybe_unused, struct ins_operands *ops if (comment == NULL) return 0; - comment = ltrim(comment); + comment = skip_spaces(comment); comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name); return 0; @@ -1098,7 +1098,7 @@ static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, str static int disasm_line__parse(char *line, const char **namep, char **rawp) { - char tmp, *name = ltrim(line); + char tmp, *name = skip_spaces(line); if (name[0] == '\0') return -1; @@ -1116,7 +1116,7 @@ static int disasm_line__parse(char *line, const char **namep, char **rawp) goto out_free_name; (*rawp)[0] = tmp; - *rawp = ltrim(*rawp); + *rawp = skip_spaces(*rawp); return 0; @@ -1503,7 +1503,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file, return 0; } - tmp = ltrim(parsed_line); + tmp = skip_spaces(parsed_line); if (*tmp) { /* * Parse hexa addresses followed by ':' diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index d8f8a20543c5..e1d0c5ba1f92 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -158,9 +158,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, if (name) { char *nl; - name += 5; /* strlen("Name:") */ - name = ltrim(name); - + name = skip_spaces(name + 5); /* strlen("Name:") */ nl = strchr(name, '\n'); if (nl) *nl = '\0'; diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index faa8eb231e1b..38dc0c6e28b8 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/list.h> #include <linux/compiler.h> +#include <linux/string.h> #include <sys/types.h> #include <errno.h> #include <fcntl.h> @@ -1339,7 +1340,7 @@ static void wordwrap(char *s, int start, int max, int corr) break; s += wlen; column += n; - s = ltrim(s); + s = skip_spaces(s); } } diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index ce993d29cca5..90df41169113 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -212,7 +212,7 @@ static void print_metric_csv(struct perf_stat_config *config __maybe_unused, return; } snprintf(buf, sizeof(buf), fmt, val); - ends = vals = ltrim(buf); + ends = vals = skip_spaces(buf); while (isdigit(*ends) || *ends == '.') ends++; *ends = 0; @@ -280,7 +280,7 @@ static void print_metric_only_csv(struct perf_stat_config *config __maybe_unused return; unit = fixunit(tbuf, os->evsel, unit); snprintf(buf, sizeof buf, fmt, val); - ends = vals = ltrim(buf); + ends = vals = skip_spaces(buf); while (isdigit(*ends) || *ends == '.') ends++; *ends = 0; diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index d28e723e2790..99a555ea4a9f 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c @@ -319,20 +319,6 @@ char *strxfrchar(char *s, char from, char to) } /** - * ltrim - Removes leading whitespace from @s. - * @s: The string to be stripped. - * - * Return pointer to the first non-whitespace character in @s. - */ -char *ltrim(char *s) -{ - while (isspace(*s)) - s++; - - return s; -} - -/** * rtrim - Removes trailing whitespace from @s. * @s: The string to be stripped. * diff --git a/tools/perf/util/string2.h b/tools/perf/util/string2.h index 07fd37568543..db02059e31c5 100644 --- a/tools/perf/util/string2.h +++ b/tools/perf/util/string2.h @@ -2,6 +2,7 @@ #ifndef PERF_STRING_H #define PERF_STRING_H +#include <linux/string.h> #include <linux/types.h> #include <stddef.h> #include <string.h> @@ -22,12 +23,11 @@ static inline bool strisglob(const char *str) int strtailcmp(const char *s1, const char *s2); char *strxfrchar(char *s, char from, char to); -char *ltrim(char *s); char *rtrim(char *s); static inline char *trim(char *s) { - return ltrim(rtrim(s)); + return skip_spaces(rtrim(s)); } char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); |