]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
perf tools: Move extra string util functions to util/string2.h
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 17 Apr 2017 19:51:59 +0000 (16:51 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 19 Apr 2017 16:01:51 +0000 (13:01 -0300)
Moving them from util.h, where they don't belong. Since libc already
have string.h, name it slightly differently, as string2.h.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-eh3vz5sqxsrdd8lodoro4jrw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
23 files changed:
tools/perf/bench/mem-functions.c
tools/perf/builtin-script.c
tools/perf/builtin-stat.c
tools/perf/builtin-trace.c
tools/perf/ui/browser.c
tools/perf/ui/browsers/hists.c
tools/perf/ui/gtk/hists.c
tools/perf/ui/stdio/hist.c
tools/perf/util/annotate.c
tools/perf/util/dso.c
tools/perf/util/dwarf-aux.c
tools/perf/util/event.c
tools/perf/util/header.c
tools/perf/util/parse-events.c
tools/perf/util/pmu.c
tools/perf/util/probe-event.c
tools/perf/util/probe-file.c
tools/perf/util/probe-finder.c
tools/perf/util/strfilter.c
tools/perf/util/string.c
tools/perf/util/string2.h [new file with mode: 0644]
tools/perf/util/thread_map.c
tools/perf/util/util.h

index d1dea33dcfcfcf60f998e2f80877e25cb348bdcb..fbd732b54047976ec3abae8f54c630c6a6f78e2e 100644 (file)
@@ -12,6 +12,7 @@
 #include <subcmd/parse-options.h>
 #include "../util/header.h"
 #include "../util/cloexec.h"
+#include "../util/string2.h"
 #include "bench.h"
 #include "mem-memcpy-arch.h"
 #include "mem-memset-arch.h"
index 5f4e36a4c444a19499d72ebca3569fdb4d647fff..a710f68679542218c40b388eda0c50b9ee9582f0 100644 (file)
@@ -21,6 +21,7 @@
 #include "util/cpumap.h"
 #include "util/thread_map.h"
 #include "util/stat.h"
+#include "util/string2.h"
 #include "util/thread-stack.h"
 #include "util/time-utils.h"
 #include "print_binary.h"
index 5abef25f998344d80ce3ddabfdebbf40b12bdc5c..1da86e6708c06ebcd791e2bfd7f370532defe2f8 100644 (file)
@@ -64,6 +64,7 @@
 #include "util/session.h"
 #include "util/tool.h"
 #include "util/group.h"
+#include "util/string2.h"
 #include "asm/bug.h"
 
 #include <linux/time64.h>
index 9a8b9e6f47f76f44f5337db6a124f2915309da6f..4160d946a34ddf19f8a276ac83dc9a768fd8e942 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/bpf-loader.h"
 #include "callchain.h"
 #include "print_binary.h"
+#include "string2.h"
 #include "syscalltbl.h"
 #include "rb_resort.h"
 
index 73bdd07321c4f40ac409405735960adef5a6f18e..a4d3762cd8250c0e799978d0454d52a04073b8f1 100644 (file)
@@ -1,4 +1,5 @@
 #include "../util.h"
+#include "../string2.h"
 #include "../config.h"
 #include "../../perf.h"
 #include "libslang.h"
index ac7f6a3e4a86b4cc77773df93d45661cbc25d149..bc397bbbc3a7d28a1b9e51bc52ee35898361d078 100644 (file)
@@ -20,6 +20,7 @@
 #include "map.h"
 #include "annotate.h"
 #include "srcline.h"
+#include "string2.h"
 
 #include "sane_ctype.h"
 
index a4f02de7c1b54d426bb1b3f50b7fc2ba39ae5fa8..c42de4dcc055f0eb8cf6eccc773c4d1280ca0d74 100644 (file)
@@ -4,6 +4,7 @@
 #include "../sort.h"
 #include "../hist.h"
 #include "../helpline.h"
+#include "../string2.h"
 #include "gtk.h"
 
 #define MAX_COLUMNS                    32
index 66aa4eb369f17761e2c565b6fc056e0ec06a7518..5565105c9688d6e2323836144332407dac052892 100644 (file)
@@ -5,6 +5,7 @@
 #include "../../util/sort.h"
 #include "../../util/evsel.h"
 #include "../../util/srcline.h"
+#include "../../util/string2.h"
 #include "../../util/sane_ctype.h"
 
 static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
index d69fdafba27431b3a8dadd9956cfa5a6c666a378..297bf5c66609313ffb628974edd2867b4bf016dd 100644 (file)
@@ -19,6 +19,7 @@
 #include "annotate.h"
 #include "evsel.h"
 #include "block-range.h"
+#include "string2.h"
 #include "arch/common.h"
 #include <regex.h>
 #include <pthread.h>
index 385c82e12473bf8e5ac5c615aa3867645bccb75c..6ad57730a0eda42895ce3fd758ec12f86553b336 100644 (file)
@@ -8,6 +8,7 @@
 #include "auxtrace.h"
 #include "util.h"
 #include "debug.h"
+#include "string2.h"
 #include "vdso.h"
 
 static const char * const debuglink_paths[] = {
index 5fb186d142f6907178060727997203acb37ae2f6..780ee4629bd04dab10757ec04f2d0f9f663bcfb0 100644 (file)
@@ -22,6 +22,7 @@
 #include "util.h"
 #include "debug.h"
 #include "dwarf-aux.h"
+#include "string2.h"
 
 /**
  * cu_find_realpath - Find the realpath of the target file
index f8a706ba72f244ffd390617be97fb7401b2b2611..53b81b2283c14e4b6dc181f0c1e6824cf0a0c682 100644 (file)
@@ -8,7 +8,7 @@
 #include "hist.h"
 #include "machine.h"
 #include "sort.h"
-#include "string.h"
+#include "string2.h"
 #include "strlist.h"
 #include "thread.h"
 #include "thread_map.h"
index faf046fc398fe5a22d206a96220b302360887358..51865b8cb9f355ae18d581862fd05400996e7165 100644 (file)
@@ -1,5 +1,6 @@
 #include <inttypes.h>
 #include "util.h"
+#include "string2.h"
 #include <sys/types.h>
 #include <byteswap.h>
 #include <unistd.h>
index 6b498aea9fdea012e70bbaa0fafb7f256a5c48d0..535c7cbb2bfb386f06e23d17221c887e3c5dd90b 100644 (file)
@@ -7,7 +7,7 @@
 #include <subcmd/parse-options.h>
 #include "parse-events.h"
 #include <subcmd/exec-cmd.h>
-#include "string.h"
+#include "string2.h"
 #include "symbol.h"
 #include "cache.h"
 #include "header.h"
index 11c752561c558c0fccf41f0e403d48eb6b38ba2c..7503fa170249cf868d9164c7c1618ce6bf8f0b77 100644 (file)
@@ -15,6 +15,7 @@
 #include "header.h"
 #include "pmu-events/pmu-events.h"
 #include "cache.h"
+#include "string2.h"
 
 struct perf_pmu_format {
        char *name;
index 7caba7003734bf4cd1de8e7e03c7b0e507a72c09..8f1374071cfcae0ae748d45b22cb3d03f34717a2 100644 (file)
@@ -47,6 +47,7 @@
 #include "probe-finder.h"
 #include "probe-file.h"
 #include "session.h"
+#include "string2.h"
 
 #include "sane_ctype.h"
 
index 88714dec891223f10e41dd794e08ab8180bcdc52..7942ea5c7e8173d2ee12f512f442de3eaea8cb82 100644 (file)
@@ -28,6 +28,7 @@
 #include "probe-file.h"
 #include "session.h"
 #include "perf_regs.h"
+#include "string2.h"
 
 /* 4096 - 2 ('\n' + '\0') */
 #define MAX_CMDLEN 4094
index 9ddd7dad2e6e736dbc03b946eb076d03e0626f2f..3f3cd11d3b7c9f7b28dc55ed2a6028e46b7c5bfa 100644 (file)
@@ -41,6 +41,7 @@
 #include "symbol.h"
 #include "probe-finder.h"
 #include "probe-file.h"
+#include "string2.h"
 
 /* Kprobe tracer basic type is up to u64 */
 #define MAX_BASIC_TYPE_BITS    64
index c663c9153245feaa46827ef9c2a22e0b17e025cb..3b068e0e2d595a6cade0a897a8251789e11a8772 100644 (file)
@@ -1,5 +1,5 @@
 #include "util.h"
-#include "string.h"
+#include "string2.h"
 #include "strfilter.h"
 
 #include "sane_ctype.h"
index e716a6e5bb19cf37aed1e421c30b08926735494e..cca53b693a48d852450c00bf7ef6f90285d7ce4d 100644 (file)
@@ -1,5 +1,7 @@
-#include "util.h"
-#include "linux/string.h"
+#include "string2.h"
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <stdlib.h>
 
 #include "sane_ctype.h"
 
@@ -101,8 +103,10 @@ static int count_argc(const char *str)
 void argv_free(char **argv)
 {
        char **p;
-       for (p = argv; *p; p++)
-               zfree(p);
+       for (p = argv; *p; p++) {
+               free(*p);
+               *p = NULL;
+       }
 
        free(argv);
 }
@@ -122,7 +126,7 @@ void argv_free(char **argv)
 char **argv_split(const char *str, int *argcp)
 {
        int argc = count_argc(str);
-       char **argv = zalloc(sizeof(*argv) * (argc+1));
+       char **argv = calloc(argc + 1, sizeof(*argv));
        char **argvp;
 
        if (argv == NULL)
@@ -379,7 +383,7 @@ char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints
                                goto out_err_overflow;
 
                        if (i > 0)
-                               printed += snprintf(e + printed, size - printed, " %s ", or_and);
+                               printed += scnprintf(e + printed, size - printed, " %s ", or_and);
                        printed += scnprintf(e + printed, size - printed,
                                             "%s %s %d", var, eq_neq, ints[i]);
                }
diff --git a/tools/perf/util/string2.h b/tools/perf/util/string2.h
new file mode 100644 (file)
index 0000000..2f61968
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef PERF_STRING_H
+#define PERF_STRING_H
+
+#include <linux/types.h>
+#include <stddef.h>
+#include <string.h>
+
+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);
+static inline bool strisglob(const char *str)
+{
+       return strpbrk(str, "*?[") != NULL;
+}
+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));
+}
+
+char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
+
+static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
+{
+       return asprintf_expr_inout_ints(var, true, nints, ints);
+}
+
+static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints)
+{
+       return asprintf_expr_inout_ints(var, false, nints, ints);
+}
+
+
+#endif /* PERF_STRING_H */
index 9026408ea55bda68f477092d4ed36ebf56f1c14c..ef86bf517e01bba00db51b332cc547ec3537f4ba 100644 (file)
@@ -6,6 +6,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include "string2.h"
 #include "strlist.h"
 #include <string.h>
 #include <api/fs/fs.h>
index 46cfdccc32bcdc83210c3662da2195bc8f4c3720..850ca54d17a51f01e875789b317d274a1b22bde1 100644 (file)
@@ -98,18 +98,6 @@ int copyfile(const char *from, const char *to);
 int copyfile_mode(const char *from, const char *to, mode_t mode);
 int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size);
 
-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);
-static inline bool strisglob(const char *str)
-{
-       return strpbrk(str, "*?[") != NULL;
-}
-int strtailcmp(const char *s1, const char *s2);
-char *strxfrchar(char *s, char from, char to);
 unsigned long convert_unit(unsigned long value, char *unit);
 ssize_t readn(int fd, void *buf, size_t n);
 ssize_t writen(int fd, void *buf, size_t n);
@@ -121,14 +109,6 @@ void event_attr_init(struct perf_event_attr *attr);
 size_t hex_width(u64 v);
 int hex2u64(const char *ptr, u64 *val);
 
-char *ltrim(char *s);
-char *rtrim(char *s);
-
-static inline char *trim(char *s)
-{
-       return ltrim(rtrim(s));
-}
-
 void dump_stack(void);
 void sighandler_dump_stack(int sig);
 
@@ -175,18 +155,6 @@ int gzip_decompress_to_file(const char *input, int output_fd);
 int lzma_decompress_to_file(const char *input, int output_fd);
 #endif
 
-char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
-
-static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
-{
-       return asprintf_expr_inout_ints(var, true, nints, ints);
-}
-
-static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints)
-{
-       return asprintf_expr_inout_ints(var, false, nints, ints);
-}
-
 int get_stack_size(const char *str, unsigned long *_size);
 
 int fetch_kernel_version(unsigned int *puint,