From f5c3e25c9910d305a26f267fcfa0bfe8d97834ec 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=utf8 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 Reviewed-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- CompilerChecks.cmake | 2 +- src/socket_wrapper.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CompilerChecks.cmake b/CompilerChecks.cmake index 195d619..8d18fbf 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 5804e93..ec8321f 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -5325,7 +5325,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) @@ -5557,7 +5557,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) @@ -5581,7 +5581,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) { @@ -5860,7 +5860,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) { -- 2.34.1