From 601ab0c8abaf4f512b61a4ecbb1f0e4a4c4a374e Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Fri, 1 Oct 2021 10:00:32 +0100 Subject: [PATCH] Fix -Wcast-qual warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this change I get the following -Werror build failure when building samba on macOS: ``` ../../third_party/socket_wrapper/socket_wrapper.c:5420:15: error: cast from 'const struct cmsghdr *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]         __fds_in.p = CMSG_DATA(cmsg);                      ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/socket.h:631:51: note: expanded from macro 'CMSG_DATA' #define CMSG_DATA(cmsg)         ((unsigned char *)(cmsg) + \                                                   ^ ``` Signed-off-by: Alex Richardson --- CompilerChecks.cmake | 2 +- src/socket_wrapper.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CompilerChecks.cmake b/CompilerChecks.cmake index 4fa1a83..883b03d 100644 --- a/CompilerChecks.cmake +++ b/CompilerChecks.cmake @@ -22,7 +22,7 @@ if (UNIX) add_c_compiler_flag("-Wshadow" SUPPORTED_COMPILER_FLAGS) add_c_compiler_flag("-Wmissing-prototypes" SUPPORTED_COMPILER_FLAGS) add_c_compiler_flag("-Wcast-align" SUPPORTED_COMPILER_FLAGS) - #add_c_compiler_flag("-Wcast-qual" SUPPORTED_COMPILER_FLAGS) + add_c_compiler_flag("-Wcast-qual" SUPPORTED_COMPILER_FLAGS) add_c_compiler_flag("-Werror=address" SUPPORTED_COMPILER_FLAGS) add_c_compiler_flag("-Wstrict-prototypes" SUPPORTED_COMPILER_FLAGS) add_c_compiler_flag("-Werror=strict-prototypes" SUPPORTED_COMPILER_FLAGS) diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 44cfad8..b63010b 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -5324,7 +5324,7 @@ union __swrap_cmsghdr { struct cmsghdr *cmsg; }; -static int swrap_sendmsg_unix_scm_rights(const struct cmsghdr *cmsg, +static int swrap_sendmsg_unix_scm_rights(struct cmsghdr *cmsg, uint8_t **cm_data, size_t *cm_data_space, int *scm_rights_pipe_fd) @@ -5556,7 +5556,7 @@ static int swrap_sendmsg_unix_scm_rights(const struct cmsghdr *cmsg, return 0; } -static int swrap_sendmsg_unix_sol_socket(const struct cmsghdr *cmsg, +static int swrap_sendmsg_unix_sol_socket(struct cmsghdr *cmsg, uint8_t **cm_data, size_t *cm_data_space, int *scm_rights_pipe_fd) @@ -5580,7 +5580,7 @@ static int swrap_sendmsg_unix_sol_socket(const struct cmsghdr *cmsg, return rc; } -static int swrap_recvmsg_unix_scm_rights(const struct cmsghdr *cmsg, +static int swrap_recvmsg_unix_scm_rights(struct cmsghdr *cmsg, uint8_t **cm_data, size_t *cm_data_space) { @@ -5859,7 +5859,7 @@ static int swrap_recvmsg_unix_scm_rights(const struct cmsghdr *cmsg, return 0; } -static int swrap_recvmsg_unix_sol_socket(const struct cmsghdr *cmsg, +static int swrap_recvmsg_unix_sol_socket(struct cmsghdr *cmsg, uint8_t **cm_data, size_t *cm_data_space) { -- GitLab