Use compiler-agnostic defines to silence warning
[lttng-tools.git] / src / common / unix.cpp
index 1aea70d9f194cbb78d16a2b6058cb1e385bf6051..ea81e1d13bdb28c07a3aaac756666508e23bf710 100644 (file)
@@ -410,7 +410,7 @@ ssize_t lttcomm_send_fds_unix_sock(int sock, const int *fds, size_t nb_fd)
        struct cmsghdr *cmptr;
        struct iovec iov[1];
        ssize_t ret = -1;
-       unsigned int sizeof_fds = nb_fd * sizeof(int);
+       const unsigned int sizeof_fds = nb_fd * sizeof(int);
        char tmp[CMSG_SPACE(sizeof_fds)];
        char dummy = 0;
 
@@ -472,7 +472,7 @@ _lttcomm_send_payload_view_fds_unix_sock(int sock, struct lttng_payload_view *vi
        struct lttng_dynamic_array raw_fds;
        const int fd_count = lttng_payload_view_get_fd_handle_count(view);
 
-       lttng_dynamic_array_init(&raw_fds, sizeof(int), NULL);
+       lttng_dynamic_array_init(&raw_fds, sizeof(int), nullptr);
 
        if (fd_count < 0) {
                ret = -LTTNG_ERR_INVALID;
@@ -534,7 +534,7 @@ ssize_t lttcomm_send_fds_unix_sock_non_block(int sock, const int *fds, size_t nb
        struct cmsghdr *cmptr;
        struct iovec iov[1];
        ssize_t ret = -1;
-       unsigned int sizeof_fds = nb_fd * sizeof(int);
+       const unsigned int sizeof_fds = nb_fd * sizeof(int);
        char tmp[CMSG_SPACE(sizeof_fds)];
        char dummy = 0;
 
@@ -620,7 +620,7 @@ ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
        struct iovec iov[1];
        ssize_t ret = 0;
        struct cmsghdr *cmsg;
-       size_t sizeof_fds = nb_fd * sizeof(int);
+       const size_t sizeof_fds = nb_fd * sizeof(int);
 
 #ifdef __linux__
 /* Account for the struct ucred cmsg in the buffer size */
@@ -685,7 +685,7 @@ retry:
         * need to expect a cmsg of the SCM_CREDENTIALS as the first control
         * message.
         */
-       for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+       for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
                if (cmsg->cmsg_level != SOL_SOCKET) {
                        fprintf(stderr, "Error: The socket needs to be of type SOL_SOCKET\n");
                        ret = -1;
@@ -846,7 +846,7 @@ ssize_t lttcomm_recv_fds_unix_sock_non_block(int sock, int *fds, size_t nb_fd)
        struct iovec iov[1];
        ssize_t ret = 0;
        struct cmsghdr *cmsg;
-       size_t sizeof_fds = nb_fd * sizeof(int);
+       const size_t sizeof_fds = nb_fd * sizeof(int);
 
        LTTNG_ASSERT(sock);
        LTTNG_ASSERT(fds);
@@ -932,7 +932,7 @@ retry:
         * need to expect a cmsg of the SCM_CREDENTIALS as the first control
         * message.
         */
-       for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+       for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
                if (cmsg->cmsg_level != SOL_SOCKET) {
                        fprintf(stderr, "Error: The socket needs to be of type SOL_SOCKET\n");
                        ret = -1;
@@ -983,7 +983,7 @@ ssize_t lttcomm_send_creds_unix_sock(int sock, const void *buf, size_t len)
        ssize_t ret = -1;
 #if defined(__linux__) || defined(__CYGWIN__)
        struct cmsghdr *cmptr;
-       size_t sizeof_cred = sizeof(lttng_sock_cred);
+       const size_t sizeof_cred = sizeof(lttng_sock_cred);
        char anc_buf[CMSG_SPACE(sizeof_cred)];
        lttng_sock_cred *creds;
 
@@ -1048,7 +1048,7 @@ ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len, lttng_sock
        size_t len_last;
 #if defined(__linux__) || defined(__CYGWIN__)
        struct cmsghdr *cmptr;
-       size_t sizeof_cred = sizeof(lttng_sock_cred);
+       const size_t sizeof_cred = sizeof(lttng_sock_cred);
        char anc_buf[CMSG_SPACE(sizeof_cred)];
 #endif /* __linux__, __CYGWIN__ */
 
@@ -1095,7 +1095,7 @@ ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len, lttng_sock
        }
 
        cmptr = CMSG_FIRSTHDR(&msg);
-       if (cmptr == NULL) {
+       if (cmptr == nullptr) {
                fprintf(stderr, "Error: Invalid control message header\n");
                ret = -1;
                goto end;
This page took 0.027241 seconds and 4 git commands to generate.