X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Ffd-tracker%2Ffd-tracker.cpp;h=398ec971ddd5fdf5c8e0ff61e987efbad3ac1432;hb=64803277bbdbe0a943360d918298a48157d9da55;hp=f1058aa523cdd3f0ded6b0689bc033f6f214f144;hpb=e032c6fd0419a73188f7143b18625b43a8d8f7c3;p=lttng-tools.git diff --git a/src/common/fd-tracker/fd-tracker.cpp b/src/common/fd-tracker/fd-tracker.cpp index f1058aa52..398ec971d 100644 --- a/src/common/fd-tracker/fd-tracker.cpp +++ b/src/common/fd-tracker/fd-tracker.cpp @@ -16,16 +16,16 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include "fd-tracker.h" -#include "inode.h" +#include "fd-tracker.hpp" +#include "inode.hpp" /* Tracker lock must be taken by the user. */ #define TRACKED_COUNT(tracker) \ @@ -130,6 +130,8 @@ static struct { unsigned long value; } seed = { .lock = PTHREAD_MUTEX_INITIALIZER, + .initialized = false, + .value = 0, }; static int match_fd(struct cds_lfht_node *node, const void *key); @@ -186,7 +188,7 @@ static void unsuspendable_fd_destroy(struct unsuspendable_fd *entry) static struct unsuspendable_fd *unsuspendable_fd_create( const char *name, int fd) { - struct unsuspendable_fd *entry = (unsuspendable_fd *) zmalloc(sizeof(*entry)); + struct unsuspendable_fd *entry = zmalloc(); if (!entry) { goto error; @@ -363,7 +365,7 @@ end: struct fd_tracker *fd_tracker_create(const char *unlinked_file_path, unsigned int capacity) { - struct fd_tracker *tracker = (fd_tracker *) zmalloc(sizeof(struct fd_tracker)); + struct fd_tracker *tracker = zmalloc(); if (!tracker) { goto end; @@ -501,7 +503,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), } }; @@ -524,7 +526,7 @@ struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker, } } - handle = (fs_handle_tracked *) zmalloc(sizeof(*handle)); + handle = zmalloc(); if (!handle) { goto end; } @@ -618,7 +620,7 @@ int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker, unsigned int active_fds; struct unsuspendable_fd **entries; - entries = (unsuspendable_fd **) zmalloc(fd_count * sizeof(*entries)); + entries = calloc(fd_count); if (!entries) { ret = -1; goto end; @@ -717,7 +719,7 @@ int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker, * Maintain a local copy of fds_in as the user's callback may modify its * contents (e.g. setting the fd(s) to -1 after close). */ - fds = (int *) malloc(sizeof(*fds) * fd_count); + fds = malloc(sizeof(*fds) * fd_count); if (!fds) { ret = -1; goto end;