Fix: C++ syntax of macOS compat code
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 19 Nov 2021 16:40:08 +0000 (11:40 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 19 Nov 2021 19:50:33 +0000 (14:50 -0500)
Minors fixes to the macOS compat code to build with a C++ compiler
following the conversion of the binaries.

Change-Id: Ic879d56d0025c838d5a34b0b45d02bae02a12053
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/compat/poll.cpp
src/common/compat/socket.h
src/common/fd-tracker/fd-tracker.cpp

index 928867ffb3f5a9ac5dffbe00d5dd905d89d5e07e..4254ff8bb674fb5bbd743a57c32b04612f574526 100644 (file)
@@ -374,7 +374,7 @@ static int resize_poll_event(struct compat_poll_event_array *array,
                goto error;
        }
 
-       ptr = realloc(array->events, new_size * sizeof(*ptr));
+       ptr = (struct pollfd *) realloc(array->events, new_size * sizeof(*ptr));
        if (ptr == NULL) {
                PERROR("realloc epoll add");
                goto error;
@@ -455,7 +455,7 @@ int compat_poll_create(struct lttng_poll_event *events, int size)
        wait = &events->wait;
 
        /* This *must* be freed by using lttng_poll_free() */
-       wait->events = zmalloc(size * sizeof(struct pollfd));
+       wait->events = (struct pollfd *) zmalloc(size * sizeof(struct pollfd));
        if (wait->events == NULL) {
                PERROR("zmalloc struct pollfd");
                goto error;
@@ -463,7 +463,7 @@ int compat_poll_create(struct lttng_poll_event *events, int size)
 
        wait->alloc_size = wait->init_size = size;
 
-       current->events = zmalloc(size * sizeof(struct pollfd));
+       current->events = (struct pollfd *) zmalloc(size * sizeof(struct pollfd));
        if (current->events == NULL) {
                PERROR("zmalloc struct current pollfd");
                goto error;
index fda00e536413ed22ab69302fcd4aa0fe8f8740dd..b5a37065040fa07eb19443a47d99e0a25f3089e6 100644 (file)
@@ -186,9 +186,10 @@ typedef struct lttng_sock_cred lttng_sock_cred;
 static inline
 int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
 {
+       socklen_t pid_len = (socklen_t) sizeof(*pid);
+
        /* The getsockopt LOCAL_PEERPID option is available since macOS 10.8. */
-       return getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERPID, pid,
-                       &((socklen_t) {sizeof(*pid)}));
+       return getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERPID, pid, &pid_len);
 }
 
 #elif defined(__sun__)
index f1058aa523cdd3f0ded6b0689bc033f6f214f144..e511d6901884cb7992f7da3b6020a1b8625c9b4d 100644 (file)
@@ -501,7 +501,7 @@ struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
                .flags = flags,
                .mode = {
                        .is_set = !!mode,
-                       .value = mode ? *mode : 0,
+                       .value = static_cast<mode_t>(mode ? *mode : 0),
                }
        };
 
This page took 0.026309 seconds and 4 git commands to generate.