From: Michael Jeanson Date: Fri, 19 Nov 2021 16:40:08 +0000 (-0500) Subject: Fix: C++ syntax of macOS compat code X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9730eb85b37e03a16008bbfc93dcb3a4b26ce934;p=lttng-tools.git Fix: C++ syntax of macOS compat code 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/compat/poll.cpp b/src/common/compat/poll.cpp index 928867ffb..4254ff8bb 100644 --- a/src/common/compat/poll.cpp +++ b/src/common/compat/poll.cpp @@ -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; diff --git a/src/common/compat/socket.h b/src/common/compat/socket.h index fda00e536..b5a370650 100644 --- a/src/common/compat/socket.h +++ b/src/common/compat/socket.h @@ -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__) diff --git a/src/common/fd-tracker/fd-tracker.cpp b/src/common/fd-tracker/fd-tracker.cpp index f1058aa52..e511d6901 100644 --- a/src/common/fd-tracker/fd-tracker.cpp +++ b/src/common/fd-tracker/fd-tracker.cpp @@ -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 ? *mode : 0), } };