diff options
author | Josh Poimboeuf <jpoimboe@redhat.com> | 2015-12-15 10:39:33 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-12-16 14:09:39 -0500 |
commit | ce99091730c92bf560712baa0696ea5a461b1fe8 (patch) | |
tree | 98730b87cc0131c5d213625d67fe8ba6f58f492a /tools/perf | |
parent | 1925459b4d92d92e62d67ddc763cda650d2aa79c (diff) |
perf tools: Move strlcpy() from perf to tools/lib/string.c
strlcpy() will be needed by the subcmd library. Move it to the shared
tools/lib/string.c file which can be used by other tools.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/71e2804b973bf39ad3d3b9be10f99f2ea630be46.1450193761.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/cache.h | 7 | ||||
-rw-r--r-- | tools/perf/util/path.c | 18 |
2 files changed, 2 insertions, 23 deletions
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h index 9ca4a58f160d..d723ecb9b959 100644 --- a/tools/perf/util/cache.h +++ b/tools/perf/util/cache.h | |||
@@ -8,6 +8,8 @@ | |||
8 | #include "../perf.h" | 8 | #include "../perf.h" |
9 | #include "../ui/ui.h" | 9 | #include "../ui/ui.h" |
10 | 10 | ||
11 | #include <linux/string.h> | ||
12 | |||
11 | #define CMD_EXEC_PATH "--exec-path" | 13 | #define CMD_EXEC_PATH "--exec-path" |
12 | #define CMD_PERF_DIR "--perf-dir=" | 14 | #define CMD_PERF_DIR "--perf-dir=" |
13 | #define CMD_WORK_TREE "--work-tree=" | 15 | #define CMD_WORK_TREE "--work-tree=" |
@@ -67,9 +69,4 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2 | |||
67 | extern char *perf_pathdup(const char *fmt, ...) | 69 | extern char *perf_pathdup(const char *fmt, ...) |
68 | __attribute__((format (printf, 1, 2))); | 70 | __attribute__((format (printf, 1, 2))); |
69 | 71 | ||
70 | #ifndef __UCLIBC__ | ||
71 | /* Matches the libc/libbsd function attribute so we declare this unconditionally: */ | ||
72 | extern size_t strlcpy(char *dest, const char *src, size_t size); | ||
73 | #endif | ||
74 | |||
75 | #endif /* __PERF_CACHE_H */ | 72 | #endif /* __PERF_CACHE_H */ |
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index 5d13cb45b317..3654d964e49d 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c | |||
@@ -22,24 +22,6 @@ static const char *get_perf_dir(void) | |||
22 | return "."; | 22 | return "."; |
23 | } | 23 | } |
24 | 24 | ||
25 | /* | ||
26 | * If libc has strlcpy() then that version will override this | ||
27 | * implementation: | ||
28 | */ | ||
29 | size_t __weak strlcpy(char *dest, const char *src, size_t size) | ||
30 | { | ||
31 | size_t ret = strlen(src); | ||
32 | |||
33 | if (size) { | ||
34 | size_t len = (ret >= size) ? size - 1 : ret; | ||
35 | |||
36 | memcpy(dest, src, len); | ||
37 | dest[len] = '\0'; | ||
38 | } | ||
39 | |||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | static char *get_pathname(void) | 25 | static char *get_pathname(void) |
44 | { | 26 | { |
45 | static char pathname_array[4][PATH_MAX]; | 27 | static char pathname_array[4][PATH_MAX]; |