Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Move extra string util functions to util/string2.h

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>

+72 -41
+1
tools/perf/bench/mem-functions.c
··· 12 12 #include <subcmd/parse-options.h> 13 13 #include "../util/header.h" 14 14 #include "../util/cloexec.h" 15 + #include "../util/string2.h" 15 16 #include "bench.h" 16 17 #include "mem-memcpy-arch.h" 17 18 #include "mem-memset-arch.h"
+1
tools/perf/builtin-script.c
··· 21 21 #include "util/cpumap.h" 22 22 #include "util/thread_map.h" 23 23 #include "util/stat.h" 24 + #include "util/string2.h" 24 25 #include "util/thread-stack.h" 25 26 #include "util/time-utils.h" 26 27 #include "print_binary.h"
+1
tools/perf/builtin-stat.c
··· 64 64 #include "util/session.h" 65 65 #include "util/tool.h" 66 66 #include "util/group.h" 67 + #include "util/string2.h" 67 68 #include "asm/bug.h" 68 69 69 70 #include <linux/time64.h>
+1
tools/perf/builtin-trace.c
··· 37 37 #include "util/bpf-loader.h" 38 38 #include "callchain.h" 39 39 #include "print_binary.h" 40 + #include "string2.h" 40 41 #include "syscalltbl.h" 41 42 #include "rb_resort.h" 42 43
+1
tools/perf/ui/browser.c
··· 1 1 #include "../util.h" 2 + #include "../string2.h" 2 3 #include "../config.h" 3 4 #include "../../perf.h" 4 5 #include "libslang.h"
+1
tools/perf/ui/browsers/hists.c
··· 20 20 #include "map.h" 21 21 #include "annotate.h" 22 22 #include "srcline.h" 23 + #include "string2.h" 23 24 24 25 #include "sane_ctype.h" 25 26
+1
tools/perf/ui/gtk/hists.c
··· 4 4 #include "../sort.h" 5 5 #include "../hist.h" 6 6 #include "../helpline.h" 7 + #include "../string2.h" 7 8 #include "gtk.h" 8 9 9 10 #define MAX_COLUMNS 32
+1
tools/perf/ui/stdio/hist.c
··· 5 5 #include "../../util/sort.h" 6 6 #include "../../util/evsel.h" 7 7 #include "../../util/srcline.h" 8 + #include "../../util/string2.h" 8 9 #include "../../util/sane_ctype.h" 9 10 10 11 static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
+1
tools/perf/util/annotate.c
··· 19 19 #include "annotate.h" 20 20 #include "evsel.h" 21 21 #include "block-range.h" 22 + #include "string2.h" 22 23 #include "arch/common.h" 23 24 #include <regex.h> 24 25 #include <pthread.h>
+1
tools/perf/util/dso.c
··· 8 8 #include "auxtrace.h" 9 9 #include "util.h" 10 10 #include "debug.h" 11 + #include "string2.h" 11 12 #include "vdso.h" 12 13 13 14 static const char * const debuglink_paths[] = {
+1
tools/perf/util/dwarf-aux.c
··· 22 22 #include "util.h" 23 23 #include "debug.h" 24 24 #include "dwarf-aux.h" 25 + #include "string2.h" 25 26 26 27 /** 27 28 * cu_find_realpath - Find the realpath of the target file
+1 -1
tools/perf/util/event.c
··· 8 8 #include "hist.h" 9 9 #include "machine.h" 10 10 #include "sort.h" 11 - #include "string.h" 11 + #include "string2.h" 12 12 #include "strlist.h" 13 13 #include "thread.h" 14 14 #include "thread_map.h"
+1
tools/perf/util/header.c
··· 1 1 #include <inttypes.h> 2 2 #include "util.h" 3 + #include "string2.h" 3 4 #include <sys/types.h> 4 5 #include <byteswap.h> 5 6 #include <unistd.h>
+1 -1
tools/perf/util/parse-events.c
··· 7 7 #include <subcmd/parse-options.h> 8 8 #include "parse-events.h" 9 9 #include <subcmd/exec-cmd.h> 10 - #include "string.h" 10 + #include "string2.h" 11 11 #include "symbol.h" 12 12 #include "cache.h" 13 13 #include "header.h"
+1
tools/perf/util/pmu.c
··· 15 15 #include "header.h" 16 16 #include "pmu-events/pmu-events.h" 17 17 #include "cache.h" 18 + #include "string2.h" 18 19 19 20 struct perf_pmu_format { 20 21 char *name;
+1
tools/perf/util/probe-event.c
··· 47 47 #include "probe-finder.h" 48 48 #include "probe-file.h" 49 49 #include "session.h" 50 + #include "string2.h" 50 51 51 52 #include "sane_ctype.h" 52 53
+1
tools/perf/util/probe-file.c
··· 28 28 #include "probe-file.h" 29 29 #include "session.h" 30 30 #include "perf_regs.h" 31 + #include "string2.h" 31 32 32 33 /* 4096 - 2 ('\n' + '\0') */ 33 34 #define MAX_CMDLEN 4094
+1
tools/perf/util/probe-finder.c
··· 41 41 #include "symbol.h" 42 42 #include "probe-finder.h" 43 43 #include "probe-file.h" 44 + #include "string2.h" 44 45 45 46 /* Kprobe tracer basic type is up to u64 */ 46 47 #define MAX_BASIC_TYPE_BITS 64
+1 -1
tools/perf/util/strfilter.c
··· 1 1 #include "util.h" 2 - #include "string.h" 2 + #include "string2.h" 3 3 #include "strfilter.h" 4 4 5 5 #include "sane_ctype.h"
+10 -6
tools/perf/util/string.c
··· 1 - #include "util.h" 2 - #include "linux/string.h" 1 + #include "string2.h" 2 + #include <linux/kernel.h> 3 + #include <linux/string.h> 4 + #include <stdlib.h> 3 5 4 6 #include "sane_ctype.h" 5 7 ··· 103 101 void argv_free(char **argv) 104 102 { 105 103 char **p; 106 - for (p = argv; *p; p++) 107 - zfree(p); 104 + for (p = argv; *p; p++) { 105 + free(*p); 106 + *p = NULL; 107 + } 108 108 109 109 free(argv); 110 110 } ··· 126 122 char **argv_split(const char *str, int *argcp) 127 123 { 128 124 int argc = count_argc(str); 129 - char **argv = zalloc(sizeof(*argv) * (argc+1)); 125 + char **argv = calloc(argc + 1, sizeof(*argv)); 130 126 char **argvp; 131 127 132 128 if (argv == NULL) ··· 383 379 goto out_err_overflow; 384 380 385 381 if (i > 0) 386 - printed += snprintf(e + printed, size - printed, " %s ", or_and); 382 + printed += scnprintf(e + printed, size - printed, " %s ", or_and); 387 383 printed += scnprintf(e + printed, size - printed, 388 384 "%s %s %d", var, eq_neq, ints[i]); 389 385 }
+42
tools/perf/util/string2.h
··· 1 + #ifndef PERF_STRING_H 2 + #define PERF_STRING_H 3 + 4 + #include <linux/types.h> 5 + #include <stddef.h> 6 + #include <string.h> 7 + 8 + s64 perf_atoll(const char *str); 9 + char **argv_split(const char *str, int *argcp); 10 + void argv_free(char **argv); 11 + bool strglobmatch(const char *str, const char *pat); 12 + bool strglobmatch_nocase(const char *str, const char *pat); 13 + bool strlazymatch(const char *str, const char *pat); 14 + static inline bool strisglob(const char *str) 15 + { 16 + return strpbrk(str, "*?[") != NULL; 17 + } 18 + int strtailcmp(const char *s1, const char *s2); 19 + char *strxfrchar(char *s, char from, char to); 20 + 21 + char *ltrim(char *s); 22 + char *rtrim(char *s); 23 + 24 + static inline char *trim(char *s) 25 + { 26 + return ltrim(rtrim(s)); 27 + } 28 + 29 + char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); 30 + 31 + static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints) 32 + { 33 + return asprintf_expr_inout_ints(var, true, nints, ints); 34 + } 35 + 36 + static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints) 37 + { 38 + return asprintf_expr_inout_ints(var, false, nints, ints); 39 + } 40 + 41 + 42 + #endif /* PERF_STRING_H */
+1
tools/perf/util/thread_map.c
··· 6 6 #include <sys/types.h> 7 7 #include <sys/stat.h> 8 8 #include <unistd.h> 9 + #include "string2.h" 9 10 #include "strlist.h" 10 11 #include <string.h> 11 12 #include <api/fs/fs.h>
-32
tools/perf/util/util.h
··· 98 98 int copyfile_mode(const char *from, const char *to, mode_t mode); 99 99 int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); 100 100 101 - s64 perf_atoll(const char *str); 102 - char **argv_split(const char *str, int *argcp); 103 - void argv_free(char **argv); 104 - bool strglobmatch(const char *str, const char *pat); 105 - bool strglobmatch_nocase(const char *str, const char *pat); 106 - bool strlazymatch(const char *str, const char *pat); 107 - static inline bool strisglob(const char *str) 108 - { 109 - return strpbrk(str, "*?[") != NULL; 110 - } 111 - int strtailcmp(const char *s1, const char *s2); 112 - char *strxfrchar(char *s, char from, char to); 113 101 unsigned long convert_unit(unsigned long value, char *unit); 114 102 ssize_t readn(int fd, void *buf, size_t n); 115 103 ssize_t writen(int fd, void *buf, size_t n); ··· 108 120 109 121 size_t hex_width(u64 v); 110 122 int hex2u64(const char *ptr, u64 *val); 111 - 112 - char *ltrim(char *s); 113 - char *rtrim(char *s); 114 - 115 - static inline char *trim(char *s) 116 - { 117 - return ltrim(rtrim(s)); 118 - } 119 123 120 124 void dump_stack(void); 121 125 void sighandler_dump_stack(int sig); ··· 154 174 #ifdef HAVE_LZMA_SUPPORT 155 175 int lzma_decompress_to_file(const char *input, int output_fd); 156 176 #endif 157 - 158 - char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); 159 - 160 - static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints) 161 - { 162 - return asprintf_expr_inout_ints(var, true, nints, ints); 163 - } 164 - 165 - static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints) 166 - { 167 - return asprintf_expr_inout_ints(var, false, nints, ints); 168 - } 169 177 170 178 int get_stack_size(const char *str, unsigned long *_size); 171 179