X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=bd61fff3d52ad8c6c16d68b0ca9e195009225018;hb=77368158bbbbdf027c10e701bda0baf8a480361b;hp=d6c67bb0f368bac63699b85c05dc399d8d292a08;hpb=159b042f34366d0fde5dcd73b4231c558922a664;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index d6c67bb0f..bd61fff3d 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -294,7 +294,7 @@ int expand_double_slashes_dot_and_dotdot(char *path) * Copy the current token which is neither a '.' nor a '..'. */ path[expanded_path_len++] = '/'; - memcpy(&path[expanded_path_len], curr_char, curr_token_len); + memmove(&path[expanded_path_len], curr_char, curr_token_len); expanded_path_len += curr_token_len; } @@ -679,8 +679,8 @@ int utils_mkdir(const char *path, mode_t mode, int uid, int gid) int ret; struct lttng_directory_handle *handle; const struct lttng_credentials creds = { - .uid = (uid_t) uid, - .gid = (gid_t) gid, + .uid = LTTNG_OPTIONAL_INIT_VALUE(uid), + .gid = LTTNG_OPTIONAL_INIT_VALUE(gid), }; handle = lttng_directory_handle_create(NULL); @@ -708,8 +708,8 @@ int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid) int ret; struct lttng_directory_handle *handle; const struct lttng_credentials creds = { - .uid = (uid_t) uid, - .gid = (gid_t) gid, + .uid = LTTNG_OPTIONAL_INIT_VALUE(uid), + .gid = LTTNG_OPTIONAL_INIT_VALUE(gid), }; handle = lttng_directory_handle_create(NULL); @@ -736,7 +736,7 @@ int utils_stream_file_path(const char *path_name, const char *file_name, char *out_stream_path, size_t stream_path_len) { int ret; - char count_str[MAX_INT_DEC_LEN(count) + 1] = {}; + char count_str[MAX_INT_DEC_LEN(count) + 1] = {}; const char *path_separator; if (path_name && (path_name[0] == '\0' || @@ -754,7 +754,7 @@ int utils_stream_file_path(const char *path_name, const char *file_name, assert(ret > 0 && ret < sizeof(count_str)); } - ret = snprintf(out_stream_path, stream_path_len, "%s%s%s%s%s", + ret = snprintf(out_stream_path, stream_path_len, "%s%s%s%s%s", path_name, path_separator, file_name, count_str, suffix); if (ret < 0 || ret >= stream_path_len) { @@ -1274,8 +1274,14 @@ int utils_get_group_id(const char *name, bool warn, gid_t *gid) } } if (ret) { - PERROR("Failed to get group file entry for group name \"%s\"", - name); + if (ret == ESRCH) { + DBG("Could not find group file entry for group name '%s'", + name); + } else { + PERROR("Failed to get group file entry for group name '%s'", + name); + } + ret = -1; goto error; }