common: replace container_of with a C++ safe implementation
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry-session.cpp
index 255a5ec8176ce96dc17c4e6e5a446549735aea8d..6e21cee00c6d314419761d6a494d7b41c2084bec 100644 (file)
@@ -88,7 +88,7 @@ void destroy_channel_rcu(struct rcu_head *head)
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
        lsu::registry_channel *chan =
-               caa_container_of(head, lsu::registry_channel, _rcu_head);
+               lttng::utils::container_of(head, &lsu::registry_channel::_rcu_head);
        DIAGNOSTIC_POP
 
        delete chan;
@@ -98,8 +98,10 @@ void destroy_channel_rcu(struct rcu_head *head)
  * Destroy every element of the registry and free the memory. This does NOT
  * free the registry pointer since it might not have been allocated before so
  * it's the caller responsability.
+ *
+ * Called from ~registry_session(), must not throw.
  */
-void destroy_channel(lsu::registry_channel *chan, bool notify)
+void destroy_channel(lsu::registry_channel *chan, bool notify) noexcept
 {
        struct lttng_ht_iter iter;
        lttng::sessiond::ust::registry_event *event;
@@ -147,7 +149,7 @@ void destroy_enum_rcu(struct rcu_head *head)
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
        lsu::registry_enum *reg_enum =
-               caa_container_of(head, lsu::registry_enum, rcu_head);
+               lttng::utils::container_of(head, &lsu::registry_enum::rcu_head);
        DIAGNOSTIC_POP
 
        destroy_enum(reg_enum);
@@ -286,8 +288,10 @@ lsu::registry_session::registry_session(const struct lst::abi& in_abi,
 /*
  * For a given enumeration in a registry, delete the entry and destroy
  * the enumeration.
+ *
+ * Note that this is used by ~registry_session() and must not throw.
  */
-void lsu::registry_session::_destroy_enum(lsu::registry_enum *reg_enum)
+void lsu::registry_session::_destroy_enum(lsu::registry_enum *reg_enum) noexcept
 {
        int ret;
        lttng::urcu::read_lock_guard read_lock_guard;
@@ -430,7 +434,7 @@ lttng::sessiond::ust::registry_channel& lsu::registry_session::get_channel(
 
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-       auto chan = caa_container_of(node, lsu::registry_channel, _node);
+       auto chan = lttng::utils::container_of(node, &lsu::registry_channel::_node);
        DIAGNOSTIC_POP
        return *chan;
 }
@@ -650,7 +654,7 @@ lsu::registry_session::get_enumeration(const char *enum_name, uint64_t enum_id)
 
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-       reg_enum = caa_container_of(node, lsu::registry_enum, node);
+       reg_enum = lttng::utils::container_of(node, &lsu::registry_enum::node);
        DIAGNOSTIC_POP
 
        return lsu::registry_enum::const_rcu_protected_reference{*reg_enum, std::move(rcu_lock)};
@@ -678,7 +682,7 @@ lsu::registry_enum *lsu::registry_session::_lookup_enum(
 
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-       reg_enum = caa_container_of(node, lsu::registry_enum, node);
+       reg_enum = lttng::utils::container_of(node, &lsu::registry_enum::node);
        DIAGNOSTIC_POP
 
 end:
This page took 0.024619 seconds and 4 git commands to generate.