Refactoring: common code in _lttng_event_destroy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 9 Nov 2021 19:04:15 +0000 (14:04 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 12 Jul 2024 15:39:52 +0000 (11:39 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia615af8efccd9dcce174d6d6c60d769c8f831c8a

src/lib/lttng-ust/lttng-events.c

index 90cd92f21837f4d0909dc5a9d13293fe5b9ad92a..e10fd86c062ad66010002c57b05275c3b6e154df 100644 (file)
@@ -1705,41 +1705,22 @@ void _lttng_event_destroy(struct lttng_ust_event_common *event)
                        &event->priv->enablers_ref_head, node)
                free(enabler_ref);
 
+       /* Remove from event list. */
+       cds_list_del(&event->priv->node);
+       /* Remove from event hash table. */
+       cds_hlist_del(&event->priv->name_hlist_node);
+
        switch (event->type) {
        case LTTNG_UST_EVENT_TYPE_RECORDER:
        {
-               struct lttng_ust_event_recorder *event_recorder = event->child;
-
-               /* Remove from event list. */
-               cds_list_del(&event_recorder->priv->parent.parent.node);
-               /* Remove from event hash table. */
-               cds_hlist_del(&event_recorder->priv->parent.parent.name_hlist_node);
+               struct lttng_ust_event_session_common_private *event_session_priv =
+                       caa_container_of(event->priv, struct lttng_ust_event_session_common_private, parent);
 
-               lttng_destroy_context(event_recorder->priv->parent.ctx);
+               lttng_destroy_context(event_session_priv->ctx);
                break;
        }
        case LTTNG_UST_EVENT_TYPE_NOTIFIER:
-       {
-               struct lttng_ust_event_notifier *event_notifier = event->child;
-
-               /* Remove from event list. */
-               cds_list_del(&event_notifier->priv->parent.node);
-               /* Remove from event hash table. */
-               cds_hlist_del(&event_notifier->priv->parent.name_hlist_node);
                break;
-       }
-       case LTTNG_UST_EVENT_TYPE_COUNTER:
-       {
-               struct lttng_ust_event_counter *event_counter = event->child;
-
-               /* Remove from event list. */
-               cds_list_del(&event_counter->priv->parent.parent.node);
-               /* Remove from event hash table. */
-               cds_hlist_del(&event_counter->priv->parent.parent.name_hlist_node);
-
-               lttng_destroy_context(event_counter->priv->parent.ctx);
-               break;
-       }
        default:
                abort();
        }
This page took 0.026234 seconds and 4 git commands to generate.