diff options
Diffstat (limited to 'tools/perf/util/path.c')
| -rw-r--r-- | tools/perf/util/path.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index a501a40dd2cb..fd1f2faaade4 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c | |||
| @@ -17,7 +17,7 @@ static char bad_path[] = "/bad-path/"; | |||
| 17 | * Two hacks: | 17 | * Two hacks: |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | static char *get_perf_dir(void) | 20 | static const char *get_perf_dir(void) |
| 21 | { | 21 | { |
| 22 | return "."; | 22 | return "."; |
| 23 | } | 23 | } |
| @@ -38,8 +38,9 @@ size_t strlcpy(char *dest, const char *src, size_t size) | |||
| 38 | static char *get_pathname(void) | 38 | static char *get_pathname(void) |
| 39 | { | 39 | { |
| 40 | static char pathname_array[4][PATH_MAX]; | 40 | static char pathname_array[4][PATH_MAX]; |
| 41 | static int index; | 41 | static int idx; |
| 42 | return pathname_array[3 & ++index]; | 42 | |
| 43 | return pathname_array[3 & ++idx]; | ||
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | static char *cleanup_path(char *path) | 46 | static char *cleanup_path(char *path) |
| @@ -161,20 +162,24 @@ int perf_mkstemp(char *path, size_t len, const char *template) | |||
| 161 | } | 162 | } |
| 162 | 163 | ||
| 163 | 164 | ||
| 164 | const char *make_relative_path(const char *abs, const char *base) | 165 | const char *make_relative_path(const char *abs_path, const char *base) |
| 165 | { | 166 | { |
| 166 | static char buf[PATH_MAX + 1]; | 167 | static char buf[PATH_MAX + 1]; |
| 167 | int baselen; | 168 | int baselen; |
| 169 | |||
| 168 | if (!base) | 170 | if (!base) |
| 169 | return abs; | 171 | return abs_path; |
| 172 | |||
| 170 | baselen = strlen(base); | 173 | baselen = strlen(base); |
| 171 | if (prefixcmp(abs, base)) | 174 | if (prefixcmp(abs_path, base)) |
| 172 | return abs; | 175 | return abs_path; |
| 173 | if (abs[baselen] == '/') | 176 | if (abs_path[baselen] == '/') |
| 174 | baselen++; | 177 | baselen++; |
| 175 | else if (base[baselen - 1] != '/') | 178 | else if (base[baselen - 1] != '/') |
| 176 | return abs; | 179 | return abs_path; |
| 177 | strcpy(buf, abs + baselen); | 180 | |
| 181 | strcpy(buf, abs_path + baselen); | ||
| 182 | |||
| 178 | return buf; | 183 | return buf; |
| 179 | } | 184 | } |
| 180 | 185 | ||
