projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Run clang-format on the whole tree
[lttng-tools.git]
/
src
/
common
/
path.cpp
diff --git
a/src/common/path.cpp
b/src/common/path.cpp
index 1699cc5a6de28d0075002ee0266220399fd8c79d..cc7cbbc469c0c0c530f79db032bc8353ebc7e20d 100644
(file)
--- a/
src/common/path.cpp
+++ b/
src/common/path.cpp
@@
-8,8
+8,8
@@
*/
#define _LGPL_SOURCE
*/
#define _LGPL_SOURCE
-#include <common/macros.hpp>
#include <common/common.hpp>
#include <common/common.hpp>
+#include <common/macros.hpp>
#include <common/path.hpp>
/*
#include <common/path.hpp>
/*
@@
-21,8
+21,7
@@
*
* Return a newly-allocated string.
*/
*
* Return a newly-allocated string.
*/
-static
-char *utils_partial_realpath(const char *path)
+static char *utils_partial_realpath(const char *path)
{
char *cut_path = NULL, *try_path = NULL, *try_path_prev = NULL;
const char *next, *prev, *end;
{
char *cut_path = NULL, *try_path = NULL, *try_path_prev = NULL;
const char *next, *prev, *end;
@@
-40,7
+39,7
@@
char *utils_partial_realpath(const char *path)
* the path given as argument
*/
end = path + strlen(path);
* the path given as argument
*/
end = path + strlen(path);
- if (*(end
-
1) == '/') {
+ if (*(end
-
1) == '/') {
end--;
}
end--;
}
@@
-48,7
+47,7
@@
char *utils_partial_realpath(const char *path)
next = path;
prev = next;
/* Only to ensure try_path is not NULL to enter the while */
next = path;
prev = next;
/* Only to ensure try_path is not NULL to enter the while */
- try_path = (char *)next;
+ try_path = (char *)
next;
/* Resolve the canonical path of the first part of the path */
while (try_path != NULL && next != end) {
/* Resolve the canonical path of the first part of the path */
while (try_path != NULL && next != end) {
@@
-70,7
+69,7
@@
char *utils_partial_realpath(const char *path)
goto error;
}
goto error;
}
- try_path_buf =
(char *) zmalloc
(LTTNG_PATH_MAX);
+ try_path_buf =
zmalloc<char>
(LTTNG_PATH_MAX);
if (!try_path_buf) {
PERROR("zmalloc");
goto error;
if (!try_path_buf) {
PERROR("zmalloc");
goto error;
@@
-108,7
+107,7
@@
char *utils_partial_realpath(const char *path)
}
/* Allocate memory for the resolved path. */
}
/* Allocate memory for the resolved path. */
- resolved_path =
(char *) zmalloc
(LTTNG_PATH_MAX);
+ resolved_path =
zmalloc<char>
(LTTNG_PATH_MAX);
if (resolved_path == NULL) {
PERROR("zmalloc resolved path");
goto error;
if (resolved_path == NULL) {
PERROR("zmalloc resolved path");
goto error;
@@
-135,18
+134,17
@@
char *utils_partial_realpath(const char *path)
}
/* Concatenate the strings */
}
/* Concatenate the strings */
- snprintf(resolved_path, LTTNG_PATH_MAX, "%s%s",
- try_path_prev, cut_path);
+ snprintf(resolved_path, LTTNG_PATH_MAX, "%s%s", try_path_prev, cut_path);
/* Free the allocated memory */
free(cut_path);
free(try_path_prev);
cut_path = NULL;
try_path_prev = NULL;
/* 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
- */
+
/*
+
* Else, we just copy the path in our resolved_path to
+
* return it as is
+
*/
} else {
strncpy(resolved_path, path, LTTNG_PATH_MAX);
}
} else {
strncpy(resolved_path, path, LTTNG_PATH_MAX);
}
@@
-164,8
+162,7
@@
error:
return NULL;
}
return NULL;
}
-static
-int expand_double_slashes_dot_and_dotdot(char *path)
+static int expand_double_slashes_dot_and_dotdot(char *path)
{
size_t expanded_path_len, path_len;
const char *curr_char, *path_last_char, *next_slash, *prev_slash;
{
size_t expanded_path_len, path_len;
const char *curr_char, *path_last_char, *next_slash, *prev_slash;
@@
-197,7
+194,7
@@
int expand_double_slashes_dot_and_dotdot(char *path)
/* Compute how long is the previous token. */
curr_token_len = next_slash - curr_char;
/* Compute how long is the previous token. */
curr_token_len = next_slash - curr_char;
- switch(curr_token_len) {
+ switch
(curr_token_len) {
case 0:
/*
* The pointer has not move meaning that curr_char is
case 0:
/*
* The pointer has not move meaning that curr_char is
@@
-230,7
+227,8
@@
int expand_double_slashes_dot_and_dotdot(char *path)
* previous forward slash and substract that
* len to the resulting path.
*/
* previous forward slash and substract that
* len to the resulting path.
*/
- prev_slash = (const char *) lttng_memrchr(path, '/', expanded_path_len);
+ prev_slash =
+ (const char *) lttng_memrchr(path, '/', expanded_path_len);
/*
* If prev_slash is NULL, we reached the
* beginning of the path. We can't go back any
/*
* If prev_slash is NULL, we reached the
* beginning of the path. We can't go back any
@@
-274,8
+272,7
@@
error:
* The returned string was allocated in the function, it is thus of
* the responsibility of the caller to free this memory.
*/
* The returned string was allocated in the function, it is thus of
* the responsibility of the caller to free this memory.
*/
-static
-char *_utils_expand_path(const char *path, bool keep_symlink)
+static char *_utils_expand_path(const char *path, bool keep_symlink)
{
int ret;
char *absolute_path = NULL;
{
int ret;
char *absolute_path = NULL;
@@
-288,7
+285,7
@@
char *_utils_expand_path(const char *path, bool keep_symlink)
}
/* Allocate memory for the absolute_path */
}
/* Allocate memory for the absolute_path */
- absolute_path =
(char *) zmalloc
(LTTNG_PATH_MAX);
+ absolute_path =
zmalloc<char>
(LTTNG_PATH_MAX);
if (absolute_path == NULL) {
PERROR("zmalloc expand path");
goto error;
if (absolute_path == NULL) {
PERROR("zmalloc expand path");
goto error;
@@
-316,11
+313,12
@@
char *_utils_expand_path(const char *path, bool keep_symlink)
* Get the number of character in the CWD and allocate an array
* to can hold it and the path provided by the caller.
*/
* Get the number of character in the CWD and allocate an array
* to can hold it and the path provided by the caller.
*/
- ret = snprintf(absolute_path, LTTNG_PATH_MAX, "%s/%s",
- current_working_dir, path);
+ ret = snprintf(absolute_path, LTTNG_PATH_MAX, "%s/%s", current_working_dir, path);
if (ret >= LTTNG_PATH_MAX) {
ERR("Concatenating current working directory %s and path %s exceeds maximal size of %i bytes",
if (ret >= LTTNG_PATH_MAX) {
ERR("Concatenating current working directory %s and path %s exceeds maximal size of %i bytes",
- current_working_dir, path, LTTNG_PATH_MAX);
+ current_working_dir,
+ path,
+ LTTNG_PATH_MAX);
goto error;
}
}
goto error;
}
}
This page took
0.027434 seconds
and
4
git commands to generate.