X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=aaf577bcfd1a47e172f9c49be4657e3c15d319c5;hp=337713eb78ab39493bb745c994d7d43df9400d0f;hb=f5436bfcf6797b979b308a9af782750f9d079686;hpb=7591bab11eceedc6a0d1e02fd6f85592267a63b5 diff --git a/src/common/utils.c b/src/common/utils.c index 337713eb7..aaf577bcf 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -37,6 +36,7 @@ #include #include #include +#include #include "utils.h" #include "defaults.h" @@ -55,7 +55,7 @@ LTTNG_HIDDEN char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) { - char *cut_path, *try_path = NULL, *try_path_prev = NULL; + char *cut_path = NULL, *try_path = NULL, *try_path_prev = NULL; const char *next, *prev, *end; /* Safety net */ @@ -92,9 +92,9 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) } /* Cut the part we will be trying to resolve */ - cut_path = strndup(path, next - path); + cut_path = lttng_strndup(path, next - path); if (cut_path == NULL) { - PERROR("strndup"); + PERROR("lttng_strndup"); goto error; } @@ -124,7 +124,8 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) /* Free the allocated memory */ free(cut_path); - }; + cut_path = NULL; + } /* Allocate memory for the resolved path if necessary */ if (resolved_path == NULL) { @@ -161,6 +162,8 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) /* Free the allocated memory */ free(cut_path); free(try_path_prev); + cut_path = NULL; + try_path_prev = NULL; /* * Else, we just copy the path in our resolved_path to * return it as is @@ -174,6 +177,7 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) error: free(resolved_path); + free(cut_path); return NULL; } @@ -226,9 +230,9 @@ char *utils_expand_path(const char *path) while ((next = strstr(absolute_path, "/./"))) { /* We prepare the start_path not containing it */ - start_path = strndup(absolute_path, next - absolute_path); + start_path = lttng_strndup(absolute_path, next - absolute_path); if (!start_path) { - PERROR("strndup"); + PERROR("lttng_strndup"); goto error; } /* And we concatenate it with the part after this string */ @@ -246,9 +250,9 @@ char *utils_expand_path(const char *path) } /* Then we prepare the start_path not containing it */ - start_path = strndup(absolute_path, previous - absolute_path); + start_path = lttng_strndup(absolute_path, previous - absolute_path); if (!start_path) { - PERROR("strndup"); + PERROR("lttng_strndup"); goto error; } @@ -763,10 +767,6 @@ int utils_unlink_stream_file(const char *path_name, char *file_name, uint64_t si ret = unlink(path); } else { ret = run_as_unlink(path, uid, gid); - if (ret < 0) { - errno = -ret; - ret = -1; - } } if (ret < 0) { goto error;