X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Ffd-handle.cpp;h=6cf382757cb01cd9f2792b17b1da81375482681e;hb=HEAD;hp=579757782702f175315254b3003b001e1355bbae;hpb=64803277bbdbe0a943360d918298a48157d9da55;p=lttng-tools.git diff --git a/src/common/fd-handle.cpp b/src/common/fd-handle.cpp index 579757782..6cf382757 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); @@ -33,11 +34,11 @@ static void fd_handle_release(struct urcu_ref *ref) struct fd_handle *fd_handle_create(int fd) { - struct fd_handle *handle = NULL; + struct fd_handle *handle = nullptr; if (fd < 0) { ERR("Attempted to create an fd_handle from an invalid file descriptor: fd = %d", - fd); + fd); goto end; } @@ -80,11 +81,12 @@ int fd_handle_get_fd(struct fd_handle *handle) struct fd_handle *fd_handle_copy(const struct fd_handle *handle) { - struct fd_handle *new_handle = NULL; + struct fd_handle *new_handle = nullptr; 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; }