Commit 13c230ab authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf tools: Ditch rtrim(), use strim() from tools/lib

Cleaning up a bit more tools/perf/util/ by using things we got from the
kernel and have in tools/lib/

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-7hluuoveryoicvkclshzjf1k@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 3ca43b60
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2071,7 +2071,8 @@ static int hist_browser__fprintf_hierarchy_entry(struct hist_browser *browser,
		advance_hpp(&hpp, ret);
	}

	printed += fprintf(fp, "%s\n", rtrim(s));
	strim(s);
	printed += fprintf(fp, "%s\n", s);

	if (he->leaf && folded_sign == '-') {
		printed += hist_browser__fprintf_callchain(browser, he, fp,
+2 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <pthread.h>
#include <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <bpf/libbpf.h>

/* FIXME: For the HE_COLORSET */
@@ -1495,7 +1496,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file,
		return -1;

	line_ip = -1;
	parsed_line = rtrim(line);
	parsed_line = strim(line);

	/* /filename:linenr ? Save line number and ignore. */
	if (regexec(&file_lineno, parsed_line, 2, match, 0) == 0) {
+3 −3
Original line number Diff line number Diff line
@@ -1048,7 +1048,7 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev
		return -1;

	cache->type[len] = 0;
	cache->type = rtrim(cache->type);
	cache->type = strim(cache->type);

	scnprintf(file, PATH_MAX, "%s/size", path);
	if (sysfs__read_str(file, &cache->size, &len)) {
@@ -1057,7 +1057,7 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev
	}

	cache->size[len] = 0;
	cache->size = rtrim(cache->size);
	cache->size = strim(cache->size);

	scnprintf(file, PATH_MAX, "%s/shared_cpu_list", path);
	if (sysfs__read_str(file, &cache->map, &len)) {
@@ -1067,7 +1067,7 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev
	}

	cache->map[len] = 0;
	cache->map = rtrim(cache->map);
	cache->map = strim(cache->map);
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -395,7 +395,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
	buf[ret] = 0;

	/* Remove trailing newline from sysfs file */
	rtrim(buf);
	strim(buf);

	return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL,
				     NULL, NULL, NULL);
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ util/namespaces.c
../lib/bitmap.c
../lib/find_bit.c
../lib/hweight.c
../lib/string.c
../lib/vsprintf.c
util/thread_map.c
util/util.c
Loading