sessiond: registry_session: mark functions as noexcept
[lttng-tools.git] / src / common / fd-tracker / inode.cpp
index 404ba360b2ab40f8ee3d4c35bfd93d4622651c6e..95a0f27426c9f943c86aee36d1be11947446f16b 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <common/string-utils/format.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/utils.hpp>
 #include <inttypes.h>
 #include <lttng/constant.h>
 #include <sys/stat.h>
 #include <urcu/rculfhash.h>
 #include <urcu/ref.h>
 
-#include "inode.h"
+#include "inode.hpp"
 
+namespace {
 struct inode_id {
        dev_t device;
        ino_t inode;
 };
+} /* namespace */
 
 struct lttng_inode_registry {
        /* Hashtable of inode_id to lttng_inode. */
@@ -60,13 +62,17 @@ struct lttng_unlinked_file_pool {
        unsigned int next_id;
 };
 
-static struct {
+namespace {
+struct {
        pthread_mutex_t lock;
        bool initialized;
        unsigned long value;
 } seed = {
                .lock = PTHREAD_MUTEX_INITIALIZER,
+               .initialized = false,
+               .value = 0,
 };
+} /* namespace */
 
 static unsigned long lttng_inode_id_hash(const struct inode_id *id)
 {
@@ -248,7 +254,7 @@ static void lttng_inode_get(struct lttng_inode *inode)
 struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
                const char *path)
 {
-       struct lttng_unlinked_file_pool *pool = (lttng_unlinked_file_pool *) zmalloc(sizeof(*pool));
+       struct lttng_unlinked_file_pool *pool = zmalloc<lttng_unlinked_file_pool>();
 
        if (!pool) {
                goto error;
@@ -432,7 +438,7 @@ static struct lttng_inode *lttng_inode_create(const struct inode_id *id,
        reference_acquired = lttng_directory_handle_get(directory_handle);
        LTTNG_ASSERT(reference_acquired);
 
-       inode = (lttng_inode *) zmalloc(sizeof(*inode));
+       inode = zmalloc<lttng_inode>();
        if (!inode) {
                goto end;
        }
@@ -453,7 +459,7 @@ end:
 
 struct lttng_inode_registry *lttng_inode_registry_create(void)
 {
-       struct lttng_inode_registry *registry = (lttng_inode_registry *) zmalloc(sizeof(*registry));
+       struct lttng_inode_registry *registry = zmalloc<lttng_inode_registry>();
 
        if (!registry) {
                goto end;
This page took 0.024637 seconds and 4 git commands to generate.