*
*/
-#include <unistd.h>
-#include <urcu/ref.h>
-
#include "fd-handle.hpp"
+
#include <common/error.hpp>
+#include <unistd.h>
+#include <urcu/ref.h>
+
struct fd_handle {
struct urcu_ref ref;
int fd;
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);
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;
}
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;
}