tools lib: Move argv_{split,free} from tools/perf/util/
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 9c10548c42219e961279826c2763a0e32dc056b9 Gitweb: https://git.kernel.org/tip/9c10548c42219e961279826c2763a0e32dc056b9 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 26 Jun 2019 15:27:58 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 1 Jul 2019 22:50:40 -0300
tools lib: Move argv_{split,free} from tools/perf/util/
This came from the kernel lib/argv_split.c, so move it to tools/lib/argv_split.c, to get it closer to the kernel structure.
We need to audit the usage of argv_split() to figure out if it is really necessary to do have one allocation per argv[] entry, looking at one of its users I guess that is not the case and we probably are even leaking those allocations by not using argv_free() judiciously, for later.
With this we further remove stuff from tools/perf/util/, reducing the perf specific codebase and encouraging other tools/ code to use these routines so as to keep the style and constructs used with the kernel.
Cc Adrian Hunter <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Namhyung Kim <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/include/linux/string.h | 3 ++ tools/lib/argv_split.c | 100 +++++++++++++++++++++++++++++++++++++++++++ tools/perf/MANIFEST | 1 + tools/perf/util/Build | 5 +++ tools/perf/util/string.c | 91 --------------------------------------- tools/perf/util/string2.h | 2 - 6 files changed, 109 insertions(+), 93 deletions(-)
tools/include/linux/string.h +3 -0
@@ -7,6 +7,9 @@void *memdup (const void *src,size_t len); +char **argv_split (const char *str,int *argcp); +void argv_free (char **argv); +int strtobool (const char *s,bool *res);/*
tools/lib/argv_split.c new file +100 -0
100 lines not on this page · raw message
tools/perf/MANIFEST +1 -0
@@ -7,6 +7,7 @@ tools/lib/traceevent tools/lib/api tools/lib/bpf tools/lib/subcmd +tools/lib/argv_split.c tools/lib/ctype.c tools/lib/hweight.c tools/lib/rbtree.c
tools/perf/util/Build +5 -0
@@ -20,6 +20,7 @@ perf-y += parse-events.o perf-y += perf_regs.o perf-y += path.o perf-y += print_binary.o +perf-y += argv_split.o perf-y += rbtree.o perf-y += libstring.o perf-y += bitmap.o
@@ -209,6 +210,10 @@ $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) +$(OUTPUT)util/argv_split.o: ../lib/argv_split.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c) + $(OUTPUT)util/bitmap.o: ../lib/bitmap.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c)
tools/perf/util/string.c +0 -91
97 lines not on this page · raw message
tools/perf/util/string2.h +0 -2
@@ -11,8 +11,6 @@ extern const char *graph_dotted_line;extern const char *dots;s64 perf_atoll (const char *str); -char **argv_split (const char *str,int *argcp); -void argv_free (char **argv);bool strglobmatch (const char *str,const char *pat);bool strglobmatch_nocase (const char *str,const char *pat);bool strlazymatch (const char *str,const char *pat);