X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Ffd-handle.cpp;h=6bc1e9b5246e4ab3d6a7bfa0ef342e9c94edf065;hb=28ab034a2c3582d07d3423d2d746731f87d3969f;hp=7473f071789982ca1c169812ef6d109430269269;hpb=c9e313bc594f40a86eed237dce222c0fc99c957f;p=lttng-tools.git diff --git a/src/common/fd-handle.cpp b/src/common/fd-handle.cpp index 7473f0717..6bc1e9b52 100644 --- a/src/common/fd-handle.cpp +++ b/src/common/fd-handle.cpp @@ -5,12 +5,13 @@ * */ -#include -#include - #include "fd-handle.hpp" + #include +#include +#include + struct fd_handle { struct urcu_ref ref; int fd; @@ -19,13 +20,13 @@ struct fd_handle { static void fd_handle_release(struct urcu_ref *ref) { int ret; - struct fd_handle *handle = container_of(ref, struct fd_handle, ref); + struct fd_handle *handle = lttng::utils::container_of(ref, &fd_handle::ref); LTTNG_ASSERT(handle->fd >= 0); ret = close(handle->fd); if (ret == -1) { PERROR("Failed to close file descriptor of fd_handle upon release: fd = %d", - handle->fd); + handle->fd); } free(handle); @@ -37,11 +38,11 @@ struct fd_handle *fd_handle_create(int fd) if (fd < 0) { ERR("Attempted to create an fd_handle from an invalid file descriptor: fd = %d", - fd); + fd); goto end; } - handle = (fd_handle *) zmalloc(sizeof(*handle)); + handle = zmalloc(); if (!handle) { PERROR("Failed to allocate fd_handle"); goto end; @@ -84,7 +85,8 @@ struct fd_handle *fd_handle_copy(const struct fd_handle *handle) const int new_fd = dup(handle->fd); if (new_fd < 0) { - PERROR("Failed to duplicate file descriptor while copying fd_handle: fd = %d", handle->fd); + PERROR("Failed to duplicate file descriptor while copying fd_handle: fd = %d", + handle->fd); goto end; }