From: Jérémie Galarneau Date: Sun, 28 Apr 2019 22:06:11 +0000 (-0400) Subject: Fix: directory handle credentials parameter is not const X-Git-Tag: v2.11.0-rc2~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6992f9f122f8bad7a1ed7ecb30b3f318a8ca8711;p=lttng-tools.git Fix: directory handle credentials parameter is not const There is no reason for the "as user" operations on a directory handle not to take the credentials as a const parameter. Not passing credentials as const makes their ownership ambiguous and makes it harder to write const-correct code. Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/compat/directory-handle.c b/src/common/compat/directory-handle.c index 7077378e0..781f2574b 100644 --- a/src/common/compat/directory-handle.c +++ b/src/common/compat/directory-handle.c @@ -418,7 +418,7 @@ LTTNG_HIDDEN int lttng_directory_handle_create_subdirectory_as_user( const struct lttng_directory_handle *handle, const char *subdirectory, - mode_t mode, struct lttng_credentials *creds) + mode_t mode, const struct lttng_credentials *creds) { int ret; @@ -438,7 +438,7 @@ LTTNG_HIDDEN int lttng_directory_handle_create_subdirectory_recursive_as_user( const struct lttng_directory_handle *handle, const char *subdirectory_path, - mode_t mode, struct lttng_credentials *creds) + mode_t mode, const struct lttng_credentials *creds) { int ret; diff --git a/src/common/compat/directory-handle.h b/src/common/compat/directory-handle.h index a24bbd8db..7d2cab339 100644 --- a/src/common/compat/directory-handle.h +++ b/src/common/compat/directory-handle.h @@ -78,7 +78,7 @@ LTTNG_HIDDEN int lttng_directory_handle_create_subdirectory_as_user( const struct lttng_directory_handle *handle, const char *subdirectory, - mode_t mode, struct lttng_credentials *creds); + mode_t mode, const struct lttng_credentials *creds); /* * Recursively create a directory relative to a directory handle. @@ -97,6 +97,6 @@ LTTNG_HIDDEN int lttng_directory_handle_create_subdirectory_recursive_as_user( const struct lttng_directory_handle *handle, const char *subdirectory_path, - mode_t mode, struct lttng_credentials *creds); + mode_t mode, const struct lttng_credentials *creds); #endif /* _COMPAT_PATH_HANDLE_H */ diff --git a/src/common/utils.c b/src/common/utils.c index aada37fe7..f058e2003 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -679,7 +679,7 @@ int utils_mkdir(const char *path, mode_t mode, int uid, int gid) { int ret; struct lttng_directory_handle handle; - struct lttng_credentials creds = { + const struct lttng_credentials creds = { .uid = (uid_t) uid, .gid = (gid_t) gid, }; @@ -703,7 +703,7 @@ int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid) { int ret; struct lttng_directory_handle handle; - struct lttng_credentials creds = { + const struct lttng_credentials creds = { .uid = (uid_t) uid, .gid = (gid_t) gid, };