Fix -Wcast-qual warnings
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Fri, 1 Oct 2021 09:00:32 +0000 (10:00 +0100)
committerAndreas Schneider <asn@samba.org>
Thu, 8 Sep 2022 09:48:52 +0000 (11:48 +0200)
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 <Alexander.Richardson@cl.cam.ac.uk>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
CompilerChecks.cmake
src/socket_wrapper.c

index 195d6192ee3773d82efec8bc8fa1e164f6298c63..8d18fbfcf2ef2e55b56a3e151a99687ad18d7835 100644 (file)
@@ -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)
index 5804e936ff791953d040301a7a8106b004cd30ad..ec8321fe0afcf35660e39a2954e7f342f530d9cc 100644 (file)
@@ -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)
 {