diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-05-24 09:49:25 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-04 09:28:50 -0400 |
commit | 4f5aeecd0d1233cbd0ccd60f4d6701404884471a (patch) | |
tree | 2503cc5703d121c746f58135947347b1fae77240 | |
parent | 7869e5889477e4e32e4024d665431b35e8b7b693 (diff) |
perf tools: Remove dead quote.[ch] code
In c68677014bac ("perf tools: Remove support for command aliases") we
removed the only remaining use of a function provided by these files, so
ditch it.
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: https://lkml.kernel.org/n/tip-mgnzqbi46gucs48d7bzfwr55@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/perf.c | 1 | ||||
-rw-r--r-- | tools/perf/util/Build | 1 | ||||
-rw-r--r-- | tools/perf/util/quote.c | 62 | ||||
-rw-r--r-- | tools/perf/util/quote.h | 31 |
4 files changed, 0 insertions, 95 deletions
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 51c81509a315..a11cb006f968 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include "util/env.h" | 12 | #include "util/env.h" |
13 | #include <subcmd/exec-cmd.h> | 13 | #include <subcmd/exec-cmd.h> |
14 | #include "util/config.h" | 14 | #include "util/config.h" |
15 | #include "util/quote.h" | ||
16 | #include <subcmd/run-command.h> | 15 | #include <subcmd/run-command.h> |
17 | #include "util/parse-events.h" | 16 | #include "util/parse-events.h" |
18 | #include <subcmd/parse-options.h> | 17 | #include <subcmd/parse-options.h> |
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 5d4c45b76895..b604ef334dc9 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
@@ -24,7 +24,6 @@ libperf-y += libstring.o | |||
24 | libperf-y += bitmap.o | 24 | libperf-y += bitmap.o |
25 | libperf-y += hweight.o | 25 | libperf-y += hweight.o |
26 | libperf-y += smt.o | 26 | libperf-y += smt.o |
27 | libperf-y += quote.o | ||
28 | libperf-y += strbuf.o | 27 | libperf-y += strbuf.o |
29 | libperf-y += string.o | 28 | libperf-y += string.o |
30 | libperf-y += strlist.o | 29 | libperf-y += strlist.o |
diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c deleted file mode 100644 index 22eaa201aa27..000000000000 --- a/tools/perf/util/quote.c +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | #include <errno.h> | ||
3 | #include <stdlib.h> | ||
4 | #include "strbuf.h" | ||
5 | #include "quote.h" | ||
6 | #include "util.h" | ||
7 | |||
8 | /* Help to copy the thing properly quoted for the shell safety. | ||
9 | * any single quote is replaced with '\'', any exclamation point | ||
10 | * is replaced with '\!', and the whole thing is enclosed in a | ||
11 | * | ||
12 | * E.g. | ||
13 | * original sq_quote result | ||
14 | * name ==> name ==> 'name' | ||
15 | * a b ==> a b ==> 'a b' | ||
16 | * a'b ==> a'\''b ==> 'a'\''b' | ||
17 | * a!b ==> a'\!'b ==> 'a'\!'b' | ||
18 | */ | ||
19 | static inline int need_bs_quote(char c) | ||
20 | { | ||
21 | return (c == '\'' || c == '!'); | ||
22 | } | ||
23 | |||
24 | static int sq_quote_buf(struct strbuf *dst, const char *src) | ||
25 | { | ||
26 | char *to_free = NULL; | ||
27 | int ret; | ||
28 | |||
29 | if (dst->buf == src) | ||
30 | to_free = strbuf_detach(dst, NULL); | ||
31 | |||
32 | ret = strbuf_addch(dst, '\''); | ||
33 | while (!ret && *src) { | ||
34 | size_t len = strcspn(src, "'!"); | ||
35 | ret = strbuf_add(dst, src, len); | ||
36 | src += len; | ||
37 | while (!ret && need_bs_quote(*src)) | ||
38 | ret = strbuf_addf(dst, "'\\%c\'", *src++); | ||
39 | } | ||
40 | if (!ret) | ||
41 | ret = strbuf_addch(dst, '\''); | ||
42 | free(to_free); | ||
43 | |||
44 | return ret; | ||
45 | } | ||
46 | |||
47 | int sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen) | ||
48 | { | ||
49 | int i, ret; | ||
50 | |||
51 | /* Copy into destination buffer. */ | ||
52 | ret = strbuf_grow(dst, 255); | ||
53 | for (i = 0; !ret && argv[i]; ++i) { | ||
54 | ret = strbuf_addch(dst, ' '); | ||
55 | if (ret) | ||
56 | break; | ||
57 | ret = sq_quote_buf(dst, argv[i]); | ||
58 | if (maxlen && dst->len > maxlen) | ||
59 | return -ENOSPC; | ||
60 | } | ||
61 | return ret; | ||
62 | } | ||
diff --git a/tools/perf/util/quote.h b/tools/perf/util/quote.h deleted file mode 100644 index 274bf26d3511..000000000000 --- a/tools/perf/util/quote.h +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | #ifndef __PERF_QUOTE_H | ||
3 | #define __PERF_QUOTE_H | ||
4 | |||
5 | #include <stddef.h> | ||
6 | |||
7 | /* Help to copy the thing properly quoted for the shell safety. | ||
8 | * any single quote is replaced with '\'', any exclamation point | ||
9 | * is replaced with '\!', and the whole thing is enclosed in a | ||
10 | * single quote pair. | ||
11 | * | ||
12 | * For example, if you are passing the result to system() as an | ||
13 | * argument: | ||
14 | * | ||
15 | * sprintf(cmd, "foobar %s %s", sq_quote(arg0), sq_quote(arg1)) | ||
16 | * | ||
17 | * would be appropriate. If the system() is going to call ssh to | ||
18 | * run the command on the other side: | ||
19 | * | ||
20 | * sprintf(cmd, "git-diff-tree %s %s", sq_quote(arg0), sq_quote(arg1)); | ||
21 | * sprintf(rcmd, "ssh %s %s", sq_util/quote.host), sq_quote(cmd)); | ||
22 | * | ||
23 | * Note that the above examples leak memory! Remember to free result from | ||
24 | * sq_quote() in a real application. | ||
25 | */ | ||
26 | |||
27 | struct strbuf; | ||
28 | |||
29 | int sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen); | ||
30 | |||
31 | #endif /* __PERF_QUOTE_H */ | ||