From 0114db0ec2407029052eb61a0189c9b1cd64d520 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 10 Jun 2022 15:10:32 -0400 Subject: [PATCH] common: replace container_of with a C++ safe implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As more code moves to a more idiomatic C++ style, structures like typically end up becoming classes that use different access controls, virtual functions, etc. This, in turn, makes them adopt a non standard layout and causes GCC and clang to emit the following warning when container_of is used: error: 'offsetof' within non-standard-layout type 'foo' is conditionally-supported [-Werror=invalid-offsetof] This new implementation of container_of makes use of a pointer to a data member to find the parent's address. The use of ptr_to_member against the null dummy_parent makes me uneasy as it seems equivalent to performing arithmetic on a null pointer, which I understand is undefined behavior (C++11 Standard 5.7.5). However, Boost.Instrusive uses an approach that seems roughly equivalent to lttng::utils::container_of() [1]. It seems like a reasonable compromise that works on all mainstream compilers. [1] https://github.com/boostorg/intrusive/blob/3c5c8cec3f0356a028a4b56ba6cac2256340dab1/include/boost/intrusive/detail/parent_from_member.hpp#L92 Change-Id: Ia6287e1648bce85dfe6de936f17ec5df46ea648d Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/connection.cpp | 6 +- src/bin/lttng-relayd/ctf-trace.cpp | 6 +- src/bin/lttng-relayd/index.cpp | 6 +- src/bin/lttng-relayd/live.cpp | 2 +- src/bin/lttng-relayd/main.cpp | 2 +- src/bin/lttng-relayd/session.cpp | 4 +- .../lttng-relayd/sessiond-trace-chunks.cpp | 15 ++- src/bin/lttng-relayd/stream.cpp | 6 +- src/bin/lttng-relayd/viewer-stream.cpp | 4 +- src/bin/lttng-sessiond/agent.cpp | 22 ++-- src/bin/lttng-sessiond/buffer-registry.cpp | 14 +- src/bin/lttng-sessiond/condition-internal.cpp | 12 +- src/bin/lttng-sessiond/consumer.cpp | 8 +- src/bin/lttng-sessiond/dispatch.cpp | 4 +- .../event-notifier-error-accounting.cpp | 11 +- src/bin/lttng-sessiond/event.cpp | 4 +- src/bin/lttng-sessiond/lttng-syscall.cpp | 2 +- .../notification-thread-events.cpp | 35 +++-- src/bin/lttng-sessiond/save.cpp | 8 +- src/bin/lttng-sessiond/session.cpp | 8 +- src/bin/lttng-sessiond/snapshot.cpp | 2 +- src/bin/lttng-sessiond/thread.cpp | 2 +- src/bin/lttng-sessiond/trace-ust.cpp | 24 ++-- src/bin/lttng-sessiond/tracker.cpp | 10 +- src/bin/lttng-sessiond/ust-app.cpp | 52 ++++---- .../lttng-sessiond/ust-registry-session.cpp | 10 +- src/bin/lttng-sessiond/ust-registry.cpp | 4 +- src/common/actions/action.cpp | 2 +- src/common/actions/list.cpp | 6 +- src/common/actions/notify.cpp | 4 +- src/common/actions/rate-policy.cpp | 12 +- src/common/actions/rotate-session.cpp | 4 +- src/common/actions/snapshot-session.cpp | 8 +- src/common/actions/start-session.cpp | 8 +- src/common/actions/stop-session.cpp | 4 +- src/common/compat/directory-handle.cpp | 4 +- src/common/conditions/buffer-usage.cpp | 72 +++++------ src/common/conditions/condition.cpp | 2 +- src/common/conditions/event-rule-matches.cpp | 77 +++++------ .../conditions/session-consumed-size.cpp | 45 ++++--- src/common/conditions/session-rotation.cpp | 40 +++--- src/common/consumer/consumer-stream.cpp | 4 +- src/common/consumer/consumer.cpp | 14 +- src/common/error-query.cpp | 36 +++--- src/common/evaluation.cpp | 5 +- src/common/event-expr/event-expr.cpp | 88 ++++++------- src/common/event-field-value.cpp | 121 ++++++++---------- src/common/event-rule/event-rule.cpp | 2 +- src/common/event-rule/jul-logging.cpp | 58 ++++----- src/common/event-rule/kernel-kprobe.cpp | 18 +-- src/common/event-rule/kernel-syscall.cpp | 28 ++-- src/common/event-rule/kernel-tracepoint.cpp | 48 +++---- src/common/event-rule/kernel-uprobe.cpp | 18 +-- src/common/event-rule/log4j-logging.cpp | 58 ++++----- src/common/event-rule/python-logging.cpp | 60 ++++----- src/common/event-rule/user-tracepoint.cpp | 66 +++++----- src/common/fd-handle.cpp | 2 +- src/common/fd-tracker/fd-tracker.cpp | 16 +-- src/common/fd-tracker/inode.cpp | 12 +- src/common/hashtable/hashtable.cpp | 20 +-- src/common/kernel-probe.cpp | 62 ++++----- src/common/location.cpp | 2 +- src/common/macros.hpp | 22 ++-- src/common/session-descriptor.cpp | 7 +- src/common/trace-chunk.cpp | 36 +++--- src/common/trigger.cpp | 2 +- src/common/userspace-probe.cpp | 109 ++++++++-------- src/lib/lttng-ctl/rotate.cpp | 20 ++- 68 files changed, 719 insertions(+), 786 deletions(-) diff --git a/src/bin/lttng-relayd/connection.cpp b/src/bin/lttng-relayd/connection.cpp index fb53862a4..711de3a5c 100644 --- a/src/bin/lttng-relayd/connection.cpp +++ b/src/bin/lttng-relayd/connection.cpp @@ -37,7 +37,7 @@ struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connectio DBG2("Relay connection by sock %d not found", sock); goto end; } - conn = caa_container_of(node, struct relay_connection, sock_n); + conn = lttng::utils::container_of(node, &relay_connection::sock_n); if (!connection_get(conn)) { conn = NULL; } @@ -110,7 +110,7 @@ end: static void rcu_free_connection(struct rcu_head *head) { struct relay_connection *conn = - caa_container_of(head, struct relay_connection, rcu_node); + lttng::utils::container_of(head, &relay_connection::rcu_node); lttcomm_destroy_sock(conn->sock); if (conn->viewer_session) { @@ -132,7 +132,7 @@ static void destroy_connection(struct relay_connection *conn) static void connection_release(struct urcu_ref *ref) { struct relay_connection *conn = - caa_container_of(ref, struct relay_connection, ref); + lttng::utils::container_of(ref, &relay_connection::ref); if (conn->in_socket_ht) { struct lttng_ht_iter iter; diff --git a/src/bin/lttng-relayd/ctf-trace.cpp b/src/bin/lttng-relayd/ctf-trace.cpp index cad67b78e..ba4a29092 100644 --- a/src/bin/lttng-relayd/ctf-trace.cpp +++ b/src/bin/lttng-relayd/ctf-trace.cpp @@ -23,7 +23,7 @@ static pthread_mutex_t last_relay_ctf_trace_id_lock = PTHREAD_MUTEX_INITIALIZER; static void rcu_destroy_ctf_trace(struct rcu_head *rcu_head) { struct ctf_trace *trace = - caa_container_of(rcu_head, struct ctf_trace, rcu_node); + lttng::utils::container_of(rcu_head, &ctf_trace::rcu_node); free(trace); } @@ -53,7 +53,7 @@ static void ctf_trace_destroy(struct ctf_trace *trace) static void ctf_trace_release(struct urcu_ref *ref) { struct ctf_trace *trace = - caa_container_of(ref, struct ctf_trace, ref); + lttng::utils::container_of(ref, &ctf_trace::ref); int ret; struct lttng_ht_iter iter; @@ -156,7 +156,7 @@ struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session, DBG("CTF Trace path %s not found", subpath); goto end; } - trace = caa_container_of(node, struct ctf_trace, node); + trace = lttng::utils::container_of(node, &ctf_trace::node); if (!ctf_trace_get(trace)) { trace = NULL; } diff --git a/src/bin/lttng-relayd/index.cpp b/src/bin/lttng-relayd/index.cpp index e7846a5b9..a20ae2658 100644 --- a/src/bin/lttng-relayd/index.cpp +++ b/src/bin/lttng-relayd/index.cpp @@ -120,7 +120,7 @@ struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream, lttng_ht_lookup(stream->indexes_ht, &net_seq_num, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (node) { - index = caa_container_of(node, struct relay_index, index_n); + index = lttng::utils::container_of(node, &relay_index::index_n); } else { struct relay_index *oldindex; @@ -200,7 +200,7 @@ static void index_destroy(struct relay_index *index) static void index_destroy_rcu(struct rcu_head *rcu_head) { struct relay_index *index = - caa_container_of(rcu_head, struct relay_index, rcu_node); + lttng::utils::container_of(rcu_head, &relay_index::rcu_node); index_destroy(index); } @@ -208,7 +208,7 @@ static void index_destroy_rcu(struct rcu_head *rcu_head) /* Stream lock must be held by the caller. */ static void index_release(struct urcu_ref *ref) { - struct relay_index *index = caa_container_of(ref, struct relay_index, ref); + struct relay_index *index = lttng::utils::container_of(ref, &relay_index::ref); struct relay_stream *stream = index->stream; int ret; struct lttng_ht_iter iter; diff --git a/src/bin/lttng-relayd/live.cpp b/src/bin/lttng-relayd/live.cpp index ef830d4ba..abbec8c20 100644 --- a/src/bin/lttng-relayd/live.cpp +++ b/src/bin/lttng-relayd/live.cpp @@ -970,7 +970,7 @@ void *thread_dispatcher(void *data __attribute__((unused))) /* Continue thread execution */ break; } - conn = caa_container_of(node, struct relay_connection, qnode); + conn = lttng::utils::container_of(node, &relay_connection::qnode); DBG("Dispatching viewer request waiting on sock %d", conn->sock->fd); diff --git a/src/bin/lttng-relayd/main.cpp b/src/bin/lttng-relayd/main.cpp index e1c74e358..41c5e1d44 100644 --- a/src/bin/lttng-relayd/main.cpp +++ b/src/bin/lttng-relayd/main.cpp @@ -1329,7 +1329,7 @@ static void *relay_thread_dispatcher(void *data __attribute__((unused))) /* Continue thread execution */ break; } - new_conn = caa_container_of(node, struct relay_connection, qnode); + new_conn = lttng::utils::container_of(node, &relay_connection::qnode); DBG("Dispatching request waiting on sock %d", new_conn->sock->fd); diff --git a/src/bin/lttng-relayd/session.cpp b/src/bin/lttng-relayd/session.cpp index a776587b3..6e29fbc74 100644 --- a/src/bin/lttng-relayd/session.cpp +++ b/src/bin/lttng-relayd/session.cpp @@ -464,7 +464,7 @@ struct relay_session *session_get_by_id(uint64_t id) DBG("Session find by ID %" PRIu64 " id NOT found", id); goto end; } - session = caa_container_of(node, struct relay_session, session_n); + session = lttng::utils::container_of(node, &relay_session::session_n); DBG("Session find by ID %" PRIu64 " id found", id); if (!session_get(session)) { session = NULL; @@ -609,7 +609,7 @@ static void destroy_session(struct relay_session *session) static void session_release(struct urcu_ref *ref) { struct relay_session *session = - caa_container_of(ref, struct relay_session, ref); + lttng::utils::container_of(ref, &relay_session::ref); destroy_session(session); } diff --git a/src/bin/lttng-relayd/sessiond-trace-chunks.cpp b/src/bin/lttng-relayd/sessiond-trace-chunks.cpp index 60f1b9754..eba9a1989 100644 --- a/src/bin/lttng-relayd/sessiond-trace-chunks.cpp +++ b/src/bin/lttng-relayd/sessiond-trace-chunks.cpp @@ -93,15 +93,15 @@ int trace_chunk_registry_ht_key_match(struct cds_lfht_node *node, (struct trace_chunk_registry_ht_key *) _key; struct trace_chunk_registry_ht_element *registry; - registry = container_of(node, typeof(*registry), ht_node); + registry = lttng::utils::container_of(node, &trace_chunk_registry_ht_element::ht_node); return key->sessiond_uuid == registry->key.sessiond_uuid; } static void trace_chunk_registry_ht_element_free(struct rcu_head *node) { - struct trace_chunk_registry_ht_element *element = - container_of(node, typeof(*element), rcu_node); + struct trace_chunk_registry_ht_element *element = lttng::utils::container_of( + node, &trace_chunk_registry_ht_element::rcu_node); free(element); } @@ -110,7 +110,7 @@ static void trace_chunk_registry_ht_element_release(struct urcu_ref *ref) { struct trace_chunk_registry_ht_element *element = - container_of(ref, typeof(*element), ref); + lttng::utils::container_of(ref, &trace_chunk_registry_ht_element::ref); char uuid_str[LTTNG_UUID_STR_LEN]; lttng_uuid_to_str(element->key.sessiond_uuid, uuid_str); @@ -167,7 +167,8 @@ struct trace_chunk_registry_ht_element *trace_chunk_registry_ht_element_find( &iter); node = cds_lfht_iter_get_node(&iter); if (node) { - element = container_of(node, typeof(*element), ht_node); + element = lttng::utils::container_of( + node, &trace_chunk_registry_ht_element::ht_node); /* * Only consider the look-up as successful if a reference * could be acquired. @@ -236,8 +237,8 @@ int trace_chunk_registry_ht_element_create( * was already published and release the reference to the copy * we created if successful. */ - published_element = container_of(published_node, - typeof(*published_element), ht_node); + published_element = lttng::utils::container_of(published_node, + &trace_chunk_registry_ht_element::ht_node); if (trace_chunk_registry_ht_element_get(published_element)) { DBG("Acquired reference to trace chunk registry of sessiond {%s}", uuid_str); diff --git a/src/bin/lttng-relayd/stream.cpp b/src/bin/lttng-relayd/stream.cpp index 9f7bfcb15..fbecdc558 100644 --- a/src/bin/lttng-relayd/stream.cpp +++ b/src/bin/lttng-relayd/stream.cpp @@ -54,7 +54,7 @@ struct relay_stream *stream_get_by_id(uint64_t stream_id) DBG("Relay stream %" PRIu64 " not found", stream_id); goto end; } - stream = caa_container_of(node, struct relay_stream, node); + stream = lttng::utils::container_of(node, &relay_stream::node); if (!stream_get(stream)) { stream = NULL; } @@ -760,7 +760,7 @@ static void stream_destroy(struct relay_stream *stream) static void stream_destroy_rcu(struct rcu_head *rcu_head) { struct relay_stream *stream = - caa_container_of(rcu_head, struct relay_stream, rcu_node); + lttng::utils::container_of(rcu_head, &relay_stream::rcu_node); stream_destroy(stream); } @@ -772,7 +772,7 @@ static void stream_destroy_rcu(struct rcu_head *rcu_head) static void stream_release(struct urcu_ref *ref) { struct relay_stream *stream = - caa_container_of(ref, struct relay_stream, ref); + lttng::utils::container_of(ref, &relay_stream::ref); struct relay_session *session; session = stream->trace->session; diff --git a/src/bin/lttng-relayd/viewer-stream.cpp b/src/bin/lttng-relayd/viewer-stream.cpp index 2790903ad..f37d8e330 100644 --- a/src/bin/lttng-relayd/viewer-stream.cpp +++ b/src/bin/lttng-relayd/viewer-stream.cpp @@ -48,7 +48,7 @@ static void viewer_stream_destroy(struct relay_viewer_stream *vstream) static void viewer_stream_destroy_rcu(struct rcu_head *head) { struct relay_viewer_stream *vstream = - caa_container_of(head, struct relay_viewer_stream, rcu_node); + lttng::utils::container_of(head, &relay_viewer_stream::rcu_node); viewer_stream_destroy(vstream); } @@ -269,7 +269,7 @@ struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id) DBG("Relay viewer stream %" PRIu64 " not found", id); goto end; } - vstream = caa_container_of(node, struct relay_viewer_stream, stream_n); + vstream = lttng::utils::container_of(node, &relay_viewer_stream::stream_n); if (!viewer_stream_get(vstream)) { vstream = NULL; } diff --git a/src/bin/lttng-sessiond/agent.cpp b/src/bin/lttng-sessiond/agent.cpp index 2a880a19c..31f1634bd 100644 --- a/src/bin/lttng-sessiond/agent.cpp +++ b/src/bin/lttng-sessiond/agent.cpp @@ -202,9 +202,9 @@ static void add_unique_agent_event(struct lttng_ht *ht, static void destroy_event_agent_rcu(struct rcu_head *head) { struct lttng_ht_node_str *node = - caa_container_of(head, struct lttng_ht_node_str, head); + lttng::utils::container_of(head, <tng_ht_node_str::head); struct agent_event *event = - caa_container_of(node, struct agent_event, node); + lttng::utils::container_of(node, &agent_event::node); agent_destroy_event(event); } @@ -215,9 +215,9 @@ static void destroy_event_agent_rcu(struct rcu_head *head) static void destroy_app_agent_rcu(struct rcu_head *head) { struct lttng_ht_node_ulong *node = - caa_container_of(head, struct lttng_ht_node_ulong, head); + lttng::utils::container_of(head, <tng_ht_node_ulong::head); struct agent_app *app = - caa_container_of(node, struct agent_app, node); + lttng::utils::container_of(node, &agent_app::node); free(app); } @@ -1013,7 +1013,7 @@ struct agent_app *agent_find_app_by_sock(int sock) if (node == NULL) { goto error; } - app = caa_container_of(node, struct agent_app, node); + app = lttng::utils::container_of(node, &agent_app::node); DBG3("Agent app pid %d found by sock %d.", app->pid, sock); return app; @@ -1388,7 +1388,7 @@ struct agent_event *agent_find_event(const char *name, } DBG3("Agent event found %s.", name); - return caa_container_of(node, struct agent_event, node); + return lttng::utils::container_of(node, &agent_event::node); error: DBG3("Agent event NOT found %s.", name); @@ -1414,7 +1414,7 @@ static void destroy_app_ctx_rcu(struct rcu_head *head) { struct agent_app_ctx *ctx = - caa_container_of(head, struct agent_app_ctx, rcu_node); + lttng::utils::container_of(head, &agent_app_ctx::rcu_node); destroy_app_ctx(ctx); } @@ -1443,7 +1443,7 @@ void agent_destroy(struct agent *agt) * value is not important since we have to continue anyway * destroying the object. */ - event = caa_container_of(node, struct agent_event, node); + event = lttng::utils::container_of(node, &agent_event::node); (void) agent_disable_event(event, agt->domain); ret = lttng_ht_del(agt->events, &iter); @@ -1512,7 +1512,7 @@ void agent_app_ht_clean(void) the_agent_apps_ht_by_sock->ht, &iter.iter, node, node) { struct agent_app *app; - app = caa_container_of(node, struct agent_app, node); + app = lttng::utils::container_of(node, &agent_app::node); agent_destroy_app_by_sock(app->sock->fd); } rcu_read_unlock(); @@ -1598,7 +1598,7 @@ void agent_by_event_notifier_domain_ht_destroy(void) cds_lfht_for_each_entry(the_trigger_agents_ht_by_domain->ht, &iter.iter, node, node) { struct agent *agent = - caa_container_of(node, struct agent, node); + lttng::utils::container_of(node, &agent::node); const int ret = lttng_ht_del( the_trigger_agents_ht_by_domain, &iter); @@ -1629,7 +1629,7 @@ struct agent *agent_find_by_event_notifier_domain( goto end; } - agt = caa_container_of(node, struct agent, node); + agt = lttng::utils::container_of(node, &agent::node); end: return agt; diff --git a/src/bin/lttng-sessiond/buffer-registry.cpp b/src/bin/lttng-sessiond/buffer-registry.cpp index 360af749d..ab7d11ae4 100644 --- a/src/bin/lttng-sessiond/buffer-registry.cpp +++ b/src/bin/lttng-sessiond/buffer-registry.cpp @@ -202,7 +202,7 @@ struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id, if (!node) { goto end; } - reg = caa_container_of(node, struct buffer_reg_uid, node); + reg = lttng::utils::container_of(node, &buffer_reg_uid::node); end: return reg; @@ -314,7 +314,7 @@ struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id) if (!node) { goto end; } - reg = caa_container_of(node, struct buffer_reg_pid, node); + reg = lttng::utils::container_of(node, &buffer_reg_pid::node); end: return reg; @@ -472,7 +472,7 @@ struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key, if (!node) { goto end; } - chan = caa_container_of(node, struct buffer_reg_channel, node); + chan = lttng::utils::container_of(node, &buffer_reg_channel::node); end: return chan; @@ -630,9 +630,9 @@ void buffer_reg_uid_remove(struct buffer_reg_uid *regp) static void rcu_free_buffer_reg_uid(struct rcu_head *head) { struct lttng_ht_node_u64 *node = - caa_container_of(head, struct lttng_ht_node_u64, head); + lttng::utils::container_of(head, <tng_ht_node_u64::head); struct buffer_reg_uid *reg = - caa_container_of(node, struct buffer_reg_uid, node); + lttng::utils::container_of(node, &buffer_reg_uid::node); buffer_reg_session_destroy(reg->registry, reg->domain); free(reg); @@ -641,9 +641,9 @@ static void rcu_free_buffer_reg_uid(struct rcu_head *head) static void rcu_free_buffer_reg_pid(struct rcu_head *head) { struct lttng_ht_node_u64 *node = - caa_container_of(head, struct lttng_ht_node_u64, head); + lttng::utils::container_of(head, <tng_ht_node_u64::head); struct buffer_reg_pid *reg = - caa_container_of(node, struct buffer_reg_pid, node); + lttng::utils::container_of(node, &buffer_reg_pid::node); buffer_reg_session_destroy(reg->registry, LTTNG_DOMAIN_UST); free(reg); diff --git a/src/bin/lttng-sessiond/condition-internal.cpp b/src/bin/lttng-sessiond/condition-internal.cpp index 7daa53625..d932fac13 100644 --- a/src/bin/lttng-sessiond/condition-internal.cpp +++ b/src/bin/lttng-sessiond/condition-internal.cpp @@ -27,8 +27,8 @@ unsigned long lttng_condition_buffer_usage_hash( unsigned long condition_type; struct lttng_condition_buffer_usage *condition; - condition = container_of(_condition, - struct lttng_condition_buffer_usage, parent); + condition = lttng::utils::container_of(_condition, + <tng_condition_buffer_usage::parent); condition_type = (unsigned long) condition->parent.type; hash = hash_key_ulong((void *) condition_type, lttng_ht_seed); @@ -64,8 +64,8 @@ unsigned long lttng_condition_session_consumed_size_hash( struct lttng_condition_session_consumed_size *condition; uint64_t val; - condition = container_of(_condition, - struct lttng_condition_session_consumed_size, parent); + condition = lttng::utils::container_of(_condition, + <tng_condition_session_consumed_size::parent); hash = hash_key_ulong((void *) condition_type, lttng_ht_seed); if (condition->session_name) { @@ -83,8 +83,8 @@ unsigned long lttng_condition_session_rotation_hash( unsigned long hash, condition_type; struct lttng_condition_session_rotation *condition; - condition = container_of(_condition, - struct lttng_condition_session_rotation, parent); + condition = lttng::utils::container_of(_condition, + <tng_condition_session_rotation::parent); condition_type = (unsigned long) condition->parent.type; hash = hash_key_ulong((void *) condition_type, lttng_ht_seed); LTTNG_ASSERT(condition->session_name); diff --git a/src/bin/lttng-sessiond/consumer.cpp b/src/bin/lttng-sessiond/consumer.cpp index b87e1d73d..c0f8eb589 100644 --- a/src/bin/lttng-sessiond/consumer.cpp +++ b/src/bin/lttng-sessiond/consumer.cpp @@ -414,7 +414,7 @@ struct consumer_socket *consumer_find_socket(int key, &iter); node = lttng_ht_iter_get_node_ulong(&iter); if (node != NULL) { - socket = caa_container_of(node, struct consumer_socket, node); + socket = lttng::utils::container_of(node, &consumer_socket::node); } return socket; @@ -481,9 +481,9 @@ void consumer_del_socket(struct consumer_socket *sock, static void destroy_socket_rcu(struct rcu_head *head) { struct lttng_ht_node_ulong *node = - caa_container_of(head, struct lttng_ht_node_ulong, head); + lttng::utils::container_of(head, <tng_ht_node_ulong::head); struct consumer_socket *socket = - caa_container_of(node, struct consumer_socket, node); + lttng::utils::container_of(node, &consumer_socket::node); free(socket); } @@ -566,7 +566,7 @@ void consumer_destroy_output_sockets(struct consumer_output *obj) static void consumer_release_output(struct urcu_ref *ref) { struct consumer_output *obj = - caa_container_of(ref, struct consumer_output, ref); + lttng::utils::container_of(ref, &consumer_output::ref); consumer_destroy_output_sockets(obj); diff --git a/src/bin/lttng-sessiond/dispatch.cpp b/src/bin/lttng-sessiond/dispatch.cpp index 8e80c2985..82bf1c2d3 100644 --- a/src/bin/lttng-sessiond/dispatch.cpp +++ b/src/bin/lttng-sessiond/dispatch.cpp @@ -284,7 +284,7 @@ static void *thread_dispatch_ust_registration(void *data) break; } - ust_cmd = caa_container_of(node, struct ust_command, node); + ust_cmd = lttng::utils::container_of(node, &ust_command::node); DBG("Dispatching UST registration pid:%d ppid:%d uid:%d" " gid:%d sock:%d name:%s (version %d.%d)", @@ -476,7 +476,7 @@ error: if (node == NULL) { break; } - ust_cmd = caa_container_of(node, struct ust_command, node); + ust_cmd = lttng::utils::container_of(node, &ust_command::node); ret = close(ust_cmd->sock); if (ret < 0) { PERROR("close ust sock exit dispatch %d", ust_cmd->sock); diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp index 285cdbf59..70ffb86ef 100644 --- a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp +++ b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp @@ -128,7 +128,7 @@ static void free_ust_error_accounting_entry(struct rcu_head *head) { int i; struct ust_error_accounting_entry *entry = - caa_container_of(head, typeof(*entry), rcu_head); + lttng::utils::container_of(head, &ust_error_accounting_entry::rcu_head); for (i = 0; i < entry->nr_counter_cpu_fds; i++) { lttng_ust_ctl_release_object(-1, entry->cpu_counters[i]); @@ -155,7 +155,7 @@ static void ust_error_accounting_entry_release(struct urcu_ref *entry_ref) { struct ust_error_accounting_entry *entry = - container_of(entry_ref, typeof(*entry), ref); + lttng::utils::container_of(entry_ref, &ust_error_accounting_entry::ref); rcu_read_lock(); cds_lfht_del(error_counter_uid_ht->ht, &entry->node.node); @@ -322,8 +322,7 @@ enum event_notifier_error_accounting_status get_error_counter_index_for_token( lttng_ht_lookup(state->indices_ht, &tracer_token, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (node) { - index_entry = caa_container_of( - node, const struct index_ht_entry, node); + index_entry = lttng::utils::container_of(node, &index_ht_entry::node); *error_counter_index = index_entry->error_counter_index; status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK; } else { @@ -1328,8 +1327,8 @@ void event_notifier_error_accounting_unregister_event_notifier( node = lttng_ht_iter_get_node_u64(&iter); if (node) { int del_ret; - struct index_ht_entry *index_entry = caa_container_of( - node, typeof(*index_entry), node); + struct index_ht_entry *index_entry = + lttng::utils::container_of(node, &index_ht_entry::node); enum lttng_index_allocator_status index_alloc_status; index_alloc_status = lttng_index_allocator_release( diff --git a/src/bin/lttng-sessiond/event.cpp b/src/bin/lttng-sessiond/event.cpp index 797219dff..65b7220ef 100644 --- a/src/bin/lttng-sessiond/event.cpp +++ b/src/bin/lttng-sessiond/event.cpp @@ -267,7 +267,7 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, } do { - uevent = caa_container_of(node, struct ltt_ust_event, node); + uevent = lttng::utils::container_of(node, <t_ust_event::node); LTTNG_ASSERT(uevent); if (uevent->enabled == 0) { @@ -869,7 +869,7 @@ int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt, } do { - aevent = caa_container_of(node, struct agent_event, node); + aevent = lttng::utils::container_of(node, &agent_event::node); ret = event_agent_disable_one(usess, agt, aevent); if (ret != LTTNG_OK) { diff --git a/src/bin/lttng-sessiond/lttng-syscall.cpp b/src/bin/lttng-sessiond/lttng-syscall.cpp index a3030bcf4..8a4ce39ea 100644 --- a/src/bin/lttng-sessiond/lttng-syscall.cpp +++ b/src/bin/lttng-sessiond/lttng-syscall.cpp @@ -210,7 +210,7 @@ static struct syscall *lookup_syscall(struct lttng_ht *ht, const char *name) lttng_ht_lookup(ht, (void *) name, &iter); node = lttng_ht_iter_get_node_str(&iter); if (node) { - ksyscall = caa_container_of(node, struct syscall, node); + ksyscall = lttng::utils::container_of(node, &syscall::node); } return ksyscall; diff --git a/src/bin/lttng-sessiond/notification-thread-events.cpp b/src/bin/lttng-sessiond/notification-thread-events.cpp index d6c0d8135..ef066f49b 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.cpp +++ b/src/bin/lttng-sessiond/notification-thread-events.cpp @@ -225,8 +225,8 @@ int match_client_id(struct cds_lfht_node *node, const void *key) { /* This double-cast is intended to supress pointer-to-cast warning. */ const notification_client_id id = *((notification_client_id *) key); - const struct notification_client *client = caa_container_of( - node, struct notification_client, client_id_ht_node); + const struct notification_client *client = lttng::utils::container_of( + node, ¬ification_client::client_id_ht_node); return client->id == id; } @@ -325,8 +325,8 @@ static int match_session(struct cds_lfht_node *node, const void *key) { const char *name = (const char *) key; - struct session_info *session_info = caa_container_of( - node, struct session_info, sessions_ht_node); + struct session_info *session_info = lttng::utils::container_of( + node, &session_info::sessions_ht_node); return !strcmp(session_info->name, name); } @@ -493,7 +493,7 @@ enum lttng_object_type get_condition_binding_object( static void free_channel_info_rcu(struct rcu_head *node) { - free(caa_container_of(node, struct channel_info, rcu_node)); + free(lttng::utils::container_of(node, &channel_info::rcu_node)); } static @@ -517,7 +517,7 @@ void channel_info_destroy(struct channel_info *channel_info) static void free_session_info_rcu(struct rcu_head *node) { - free(caa_container_of(node, struct session_info, rcu_node)); + free(lttng::utils::container_of(node, &session_info::rcu_node)); } /* Don't call directly, use the ref-counting mechanism. */ @@ -672,7 +672,7 @@ static void notification_client_list_release(struct urcu_ref *list_ref) { struct notification_client_list *list = - container_of(list_ref, typeof(*list), ref); + lttng::utils::container_of(list_ref, ¬ification_client_list::ref); struct notification_client_list_element *client_list_element, *tmp; lttng_condition_put(list->condition); @@ -816,8 +816,8 @@ struct notification_client_list *get_client_list_from_condition( &iter); node = cds_lfht_iter_get_node(&iter); if (node) { - list = container_of(node, struct notification_client_list, - notification_trigger_clients_ht_node); + list = lttng::utils::container_of(node, + ¬ification_client_list::notification_trigger_clients_ht_node); list = notification_client_list_get(list) ? list : NULL; } @@ -1284,7 +1284,7 @@ end: static void free_notification_client_rcu(struct rcu_head *node) { - free(caa_container_of(node, struct notification_client, rcu_node)); + free(lttng::utils::container_of(node, ¬ification_client::rcu_node)); } static @@ -4207,9 +4207,8 @@ bool evaluate_buffer_usage_condition(const struct lttng_condition *condition, bool result = false; uint64_t threshold; enum lttng_condition_type condition_type; - const struct lttng_condition_buffer_usage *use_condition = container_of( - condition, struct lttng_condition_buffer_usage, - parent); + const struct lttng_condition_buffer_usage *use_condition = lttng::utils::container_of( + condition, <tng_condition_buffer_usage::parent); if (use_condition->threshold_bytes.set) { threshold = use_condition->threshold_bytes.value; @@ -4265,9 +4264,8 @@ bool evaluate_session_consumed_size_condition( { uint64_t threshold; const struct lttng_condition_session_consumed_size *size_condition = - container_of(condition, - struct lttng_condition_session_consumed_size, - parent); + lttng::utils::container_of(condition, + <tng_condition_session_consumed_size::parent); threshold = size_condition->consumed_threshold_bytes.value; DBG("Session consumed size condition being evaluated: threshold = %" PRIu64 ", current size = %" PRIu64, @@ -4750,10 +4748,9 @@ int dispatch_one_event_notifier_notification(struct notification_thread_state *s } evaluation = lttng_evaluation_event_rule_matches_create( - container_of(lttng_trigger_get_const_condition( + lttng::utils::container_of(lttng_trigger_get_const_condition( element->trigger), - struct lttng_condition_event_rule_matches, - parent), + <tng_condition_event_rule_matches::parent), notification->capture_buffer, notification->capture_buf_size, false); diff --git a/src/bin/lttng-sessiond/save.cpp b/src/bin/lttng-sessiond/save.cpp index 757b97226..5db70faef 100644 --- a/src/bin/lttng-sessiond/save.cpp +++ b/src/bin/lttng-sessiond/save.cpp @@ -199,7 +199,7 @@ int save_ust_channel_attributes(struct config_writer *writer, * Fetch the monitor timer which is located in the parent of * lttng_ust_channel_attr */ - channel = caa_container_of(attr, struct ltt_ust_channel, attr); + channel = lttng::utils::container_of(attr, <t_ust_channel::attr); ret = config_writer_write_element_unsigned_int(writer, config_element_monitor_timer_interval, channel->monitor_timer_interval); @@ -1155,7 +1155,7 @@ int save_ust_events(struct config_writer *writer, rcu_read_lock(); cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) { - event = caa_container_of(node, struct ltt_ust_event, node); + event = lttng::utils::container_of(node, <t_ust_event::node); if (event->internal) { /* Internal events must not be exposed to clients */ @@ -1243,7 +1243,7 @@ int save_agent_events(struct config_writer *writer, struct ltt_ust_event fake_event; memset(&fake_event, 0, sizeof(fake_event)); - agent_event = caa_container_of(node, struct agent_event, node); + agent_event = lttng::utils::container_of(node, &agent_event::node); /* * Initialize a fake ust event to reuse the same serialization @@ -2135,7 +2135,7 @@ int save_ust_domain(struct config_writer *writer, rcu_read_lock(); cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht, &iter.iter, node, node) { - ust_chan = caa_container_of(node, struct ltt_ust_channel, node); + ust_chan = lttng::utils::container_of(node, <t_ust_channel::node); if (domain == ust_chan->domain) { ret = save_ust_channel(writer, ust_chan, session->ust_session); if (ret != LTTNG_OK) { diff --git a/src/bin/lttng-sessiond/session.cpp b/src/bin/lttng-sessiond/session.cpp index 1846024fc..e9d726103 100644 --- a/src/bin/lttng-sessiond/session.cpp +++ b/src/bin/lttng-sessiond/session.cpp @@ -876,7 +876,7 @@ enum lttng_error_code session_kernel_open_packets(struct ltt_session *session) cds_lfht_first(session->kernel_session->consumer->socks->ht, &iter.iter); node = cds_lfht_iter_get_node(&iter.iter); - socket = container_of(node, typeof(*socket), node.node); + socket = caa_container_of(node, typeof(*socket), node.node); cds_list_for_each_entry(chan, &session->kernel_session->channel_list.head, list) { @@ -979,7 +979,7 @@ void session_release(struct urcu_ref *ref) int ret; struct ltt_ust_session *usess; struct ltt_kernel_session *ksess; - struct ltt_session *session = container_of(ref, typeof(*session), ref); + struct ltt_session *session = lttng::utils::container_of(ref, <t_session::ref); const bool session_published = session->published; LTTNG_ASSERT(!session->chunk_being_archived); @@ -1183,7 +1183,7 @@ struct ltt_session *session_find_by_id(uint64_t id) if (node == NULL) { goto end; } - ls = caa_container_of(node, struct ltt_session, node); + ls = lttng::utils::container_of(node, <t_session::node); DBG3("Session %" PRIu64 " found by id.", id); return session_get(ls) ? ls : NULL; @@ -1456,7 +1456,7 @@ bool sample_session_id_by_name(const char *name, uint64_t *id) goto end; } - ls = caa_container_of(node, struct ltt_session, node_by_name); + ls = lttng::utils::container_of(node, <t_session::node_by_name); *id = ls->id; found = true; diff --git a/src/bin/lttng-sessiond/snapshot.cpp b/src/bin/lttng-sessiond/snapshot.cpp index 1601f17cc..e0ffe69c0 100644 --- a/src/bin/lttng-sessiond/snapshot.cpp +++ b/src/bin/lttng-sessiond/snapshot.cpp @@ -276,7 +276,7 @@ struct snapshot_output *snapshot_find_output_by_id(uint32_t id, DBG3("Snapshot output not found with id %" PRId32, id); goto error; } - output = caa_container_of(node, struct snapshot_output, node); + output = lttng::utils::container_of(node, &snapshot_output::node); error: return output; diff --git a/src/bin/lttng-sessiond/thread.cpp b/src/bin/lttng-sessiond/thread.cpp index 201917396..fd9136fe5 100644 --- a/src/bin/lttng-sessiond/thread.cpp +++ b/src/bin/lttng-sessiond/thread.cpp @@ -54,7 +54,7 @@ void lttng_thread_destroy(struct lttng_thread *thread) static void lttng_thread_release(struct urcu_ref *ref) { - lttng_thread_destroy(container_of(ref, struct lttng_thread, ref)); + lttng_thread_destroy(lttng::utils::container_of(ref, <tng_thread::ref)); } static diff --git a/src/bin/lttng-sessiond/trace-ust.cpp b/src/bin/lttng-sessiond/trace-ust.cpp index 6f423c9c6..4a3e74de7 100644 --- a/src/bin/lttng-sessiond/trace-ust.cpp +++ b/src/bin/lttng-sessiond/trace-ust.cpp @@ -185,7 +185,7 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, DBG2("Trace UST channel %s found by name", name); - return caa_container_of(node, struct ltt_ust_channel, node); + return lttng::utils::container_of(node, <t_ust_channel::node); error: DBG2("Trace UST channel %s not found by name", name); @@ -224,7 +224,7 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, DBG2("Trace UST event %s found", key.name); - return caa_container_of(node, struct ltt_ust_event, node); + return lttng::utils::container_of(node, <t_ust_event::node); error: DBG2("Trace UST event %s NOT found", key.name); @@ -257,7 +257,7 @@ struct agent *trace_ust_find_agent(struct ltt_ust_session *session, if (!node) { goto end; } - agt = caa_container_of(node, struct agent, node); + agt = lttng::utils::container_of(node, &agent::node); end: return agt; @@ -793,7 +793,7 @@ static struct ust_id_tracker_node *id_tracker_lookup( lttng_ht_lookup(id_tracker->ht, (void *) _id, iter); node = lttng_ht_iter_get_node_ulong(iter); if (node) { - return caa_container_of(node, struct ust_id_tracker_node, node); + return lttng::utils::container_of(node, &ust_id_tracker_node::node); } else { return NULL; } @@ -1203,9 +1203,9 @@ end: static void destroy_context_rcu(struct rcu_head *head) { struct lttng_ht_node_ulong *node = - caa_container_of(head, struct lttng_ht_node_ulong, head); + lttng::utils::container_of(head, <tng_ht_node_ulong::head); struct ltt_ust_context *ctx = - caa_container_of(node, struct ltt_ust_context, node); + lttng::utils::container_of(node, <t_ust_context::node); trace_ust_destroy_context(ctx); } @@ -1225,7 +1225,7 @@ static void destroy_contexts(struct lttng_ht *ht) rcu_read_lock(); cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) { /* Remove from ordered list. */ - ctx = caa_container_of(node, struct ltt_ust_context, node); + ctx = lttng::utils::container_of(node, <t_ust_context::node); cds_list_del(&ctx->list); /* Remove from channel's hash table. */ ret = lttng_ht_del(ht, &iter); @@ -1272,9 +1272,9 @@ void trace_ust_destroy_context(struct ltt_ust_context *ctx) static void destroy_event_rcu(struct rcu_head *head) { struct lttng_ht_node_str *node = - caa_container_of(head, struct lttng_ht_node_str, head); + lttng::utils::container_of(head, <tng_ht_node_str::head); struct ltt_ust_event *event = - caa_container_of(node, struct ltt_ust_event, node); + lttng::utils::container_of(node, <t_ust_event::node); trace_ust_destroy_event(event); } @@ -1321,9 +1321,9 @@ static void _trace_ust_destroy_channel(struct ltt_ust_channel *channel) static void destroy_channel_rcu(struct rcu_head *head) { struct lttng_ht_node_str *node = - caa_container_of(head, struct lttng_ht_node_str, head); + lttng::utils::container_of(head, <tng_ht_node_str::head); struct ltt_ust_channel *channel = - caa_container_of(node, struct ltt_ust_channel, node); + lttng::utils::container_of(node, <t_ust_channel::node); _trace_ust_destroy_channel(channel); } @@ -1395,7 +1395,7 @@ static void destroy_channels(struct lttng_ht *channels) rcu_read_lock(); cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) { struct ltt_ust_channel *chan = - caa_container_of(node, struct ltt_ust_channel, node); + lttng::utils::container_of(node, <t_ust_channel::node); trace_ust_delete_channel(channels, chan); trace_ust_destroy_channel(chan); diff --git a/src/bin/lttng-sessiond/tracker.cpp b/src/bin/lttng-sessiond/tracker.cpp index 9e29b7324..10f8dd598 100644 --- a/src/bin/lttng-sessiond/tracker.cpp +++ b/src/bin/lttng-sessiond/tracker.cpp @@ -41,8 +41,8 @@ struct process_attr_tracker_value_node { static void process_attr_tracker_value_node_rcu_free(struct rcu_head *rcu_head) { - struct process_attr_tracker_value_node *node = - container_of(rcu_head, typeof(*node), rcu_head); + struct process_attr_tracker_value_node *node = lttng::utils::container_of( + rcu_head, &process_attr_tracker_value_node::rcu_head); free(node); } @@ -177,9 +177,9 @@ static struct process_attr_tracker_value_node *process_attr_tracker_lookup( node = cds_lfht_iter_get_node(&iter); rcu_read_unlock(); - return node ? container_of(node, struct process_attr_tracker_value_node, - inclusion_set_ht_node) : - NULL; + return node ? lttng::utils::container_of(node, + &process_attr_tracker_value_node::inclusion_set_ht_node) : + NULL; } /* Protected by session mutex held by caller. */ diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index 16848191d..0246501a5 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -287,7 +287,7 @@ static void close_notify_sock_rcu(struct rcu_head *head) { int ret; struct ust_app_notify_sock_obj *obj = - caa_container_of(head, struct ust_app_notify_sock_obj, head); + lttng::utils::container_of(head, &ust_app_notify_sock_obj::head); /* Must have a valid fd here. */ LTTNG_ASSERT(obj->fd >= 0); @@ -380,8 +380,8 @@ void delete_ust_app_event(int sock, struct ust_app_event *ua_event, static void free_ust_app_event_notifier_rule_rcu(struct rcu_head *head) { - struct ust_app_event_notifier_rule *obj = caa_container_of( - head, struct ust_app_event_notifier_rule, rcu_head); + struct ust_app_event_notifier_rule *obj = lttng::utils::container_of( + head, &ust_app_event_notifier_rule::rcu_head); free(obj); } @@ -480,7 +480,7 @@ static void delete_ust_app_channel_rcu(struct rcu_head *head) { struct ust_app_channel *ua_chan = - caa_container_of(head, struct ust_app_channel, rcu_head); + lttng::utils::container_of(head, &ust_app_channel::rcu_head); lttng_ht_destroy(ua_chan->ctx); lttng_ht_destroy(ua_chan->events); @@ -902,7 +902,7 @@ static void delete_ust_app_session_rcu(struct rcu_head *head) { struct ust_app_session *ua_sess = - caa_container_of(head, struct ust_app_session, rcu_head); + lttng::utils::container_of(head, &ust_app_session::rcu_head); lttng_ht_destroy(ua_sess->channels); free(ua_sess); @@ -1126,9 +1126,9 @@ static void delete_ust_app_rcu(struct rcu_head *head) { struct lttng_ht_node_ulong *node = - caa_container_of(head, struct lttng_ht_node_ulong, head); + lttng::utils::container_of(head, <tng_ht_node_ulong::head); struct ust_app *app = - caa_container_of(node, struct ust_app, pid_n); + lttng::utils::container_of(node, &ust_app::pid_n); DBG3("Call RCU deleting app PID %d", app->pid); delete_ust_app(app); @@ -1470,7 +1470,7 @@ struct ust_app *ust_app_find_by_sock(int sock) goto error; } - return caa_container_of(node, struct ust_app, sock_n); + return lttng::utils::container_of(node, &ust_app::sock_n); error: return NULL; @@ -1495,7 +1495,7 @@ static struct ust_app *find_app_by_notify_sock(int sock) goto error; } - return caa_container_of(node, struct ust_app, notify_sock_n); + return lttng::utils::container_of(node, &ust_app::notify_sock_n); error: return NULL; @@ -1535,7 +1535,7 @@ static struct ust_app_event *find_ust_app_event(struct lttng_ht *ht, goto end; } - event = caa_container_of(node, struct ust_app_event, node); + event = lttng::utils::container_of(node, &ust_app_event::node); end: return event; @@ -1565,8 +1565,8 @@ static struct ust_app_event_notifier_rule *find_ust_app_event_notifier_rule( goto end; } - event_notifier_rule = caa_container_of( - node, struct ust_app_event_notifier_rule, node); + event_notifier_rule = lttng::utils::container_of( + node, &ust_app_event_notifier_rule::node); end: return event_notifier_rule; } @@ -2506,7 +2506,7 @@ static struct ust_app_session *lookup_session_by_app( goto error; } - return caa_container_of(node, struct ust_app_session, node); + return lttng::utils::container_of(node, &ust_app_session::node); error: return NULL; @@ -2833,7 +2833,7 @@ struct ust_app_ctx *find_ust_app_context(struct lttng_ht *ht, goto end; } - app_ctx = caa_container_of(node, struct ust_app_ctx, node); + app_ctx = lttng::utils::container_of(node, &ust_app_ctx::node); end: return app_ctx; @@ -2965,7 +2965,7 @@ static int enable_ust_app_channel(struct ust_app_session *ua_sess, goto error; } - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node); ret = enable_ust_channel(app, ua_sess, ua_chan); if (ret < 0) { @@ -3680,7 +3680,7 @@ static int ust_app_channel_allocate(struct ust_app_session *ua_sess, lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter); ua_chan_node = lttng_ht_iter_get_node_str(&iter); if (ua_chan_node != NULL) { - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node); goto end; } @@ -3945,7 +3945,7 @@ struct ust_app *ust_app_find_by_pid(pid_t pid) DBG2("Found UST app by pid %d", pid); - app = caa_container_of(node, struct ust_app, pid_n); + app = lttng::utils::container_of(node, &ust_app::pid_n); error: return app; @@ -4270,7 +4270,7 @@ void ust_app_unregister(int sock) node = lttng_ht_iter_get_node_ulong(&ust_app_sock_iter); LTTNG_ASSERT(node); - lta = caa_container_of(node, struct ust_app, sock_n); + lta = lttng::utils::container_of(node, &ust_app::sock_n); DBG("PID %d unregistering with sock %d", lta->pid, sock); /* @@ -4763,7 +4763,7 @@ int ust_app_disable_channel_glb(struct ltt_ust_session *usess, /* If the session if found for the app, the channel must be there */ LTTNG_ASSERT(ua_chan_node); - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node); /* The channel must not be already disabled */ LTTNG_ASSERT(ua_chan->enabled == 1); @@ -4866,7 +4866,7 @@ int ust_app_disable_event_glb(struct ltt_ust_session *usess, "Skipping", uchan->name, usess->id, app->pid); continue; } - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node); ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name, uevent->filter, uevent->attr.loglevel, @@ -5025,7 +5025,7 @@ int ust_app_enable_event_glb(struct ltt_ust_session *usess, continue; } - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node); /* Get event node */ ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name, @@ -5098,7 +5098,7 @@ int ust_app_create_event_glb(struct ltt_ust_session *usess, /* If the channel is not found, there is a code flow error */ LTTNG_ASSERT(ua_chan_node); - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node); ret = create_ust_app_event(ua_chan, uevent, app); pthread_mutex_unlock(&ua_sess->lock); @@ -5642,7 +5642,7 @@ static int destroy_trace(struct ltt_ust_session *usess, struct ust_app *app) /* Session is being or is deleted. */ goto end; } - ua_sess = caa_container_of(node, struct ust_app_session, node); + ua_sess = lttng::utils::container_of(node, &ust_app_session::node); health_code_update(); destroy_app_session(app, ua_sess); @@ -6326,7 +6326,7 @@ static struct ust_app_session *find_session_by_objd(struct ust_app *app, goto error; } - ua_sess = caa_container_of(node, struct ust_app_session, ust_objd_node); + ua_sess = lttng::utils::container_of(node, &ust_app_session::ust_objd_node); error: return ua_sess; @@ -6354,7 +6354,7 @@ static struct ust_app_channel *find_channel_by_objd(struct ust_app *app, goto error; } - ua_chan = caa_container_of(node, struct ust_app_channel, ust_objd_node); + ua_chan = lttng::utils::container_of(node, &ust_app_channel::ust_objd_node); error: return ua_chan; @@ -7253,7 +7253,7 @@ int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess, /* If the session is found for the app, the channel must be there */ LTTNG_ASSERT(ua_chan_node); - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); + ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node); if (overwrite) { uint64_t _lost; diff --git a/src/bin/lttng-sessiond/ust-registry-session.cpp b/src/bin/lttng-sessiond/ust-registry-session.cpp index b78091a04..6e21cee00 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session.cpp @@ -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; @@ -149,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); @@ -434,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; } @@ -654,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)}; @@ -682,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: diff --git a/src/bin/lttng-sessiond/ust-registry.cpp b/src/bin/lttng-sessiond/ust-registry.cpp index 323fdd6a7..2a7d6217a 100644 --- a/src/bin/lttng-sessiond/ust-registry.cpp +++ b/src/bin/lttng-sessiond/ust-registry.cpp @@ -33,11 +33,11 @@ namespace lsu = lttng::sessiond::ust; */ static void ust_registry_event_destroy_rcu(struct rcu_head *head) { - struct lttng_ht_node_u64 *node = caa_container_of(head, struct lttng_ht_node_u64, head); + struct lttng_ht_node_u64 *node = lttng::utils::container_of(head, <tng_ht_node_u64::head); DIAGNOSTIC_PUSH DIAGNOSTIC_IGNORE_INVALID_OFFSETOF lttng::sessiond::ust::registry_event *event = - caa_container_of(node, lttng::sessiond::ust::registry_event, _node); + lttng::utils::container_of(node, <tng::sessiond::ust::registry_event::_node); DIAGNOSTIC_POP lttng::sessiond::ust::registry_event_destroy(event); diff --git a/src/common/actions/action.cpp b/src/common/actions/action.cpp index 74dec1247..bc9e3580a 100644 --- a/src/common/actions/action.cpp +++ b/src/common/actions/action.cpp @@ -73,7 +73,7 @@ static void action_destroy_ref(struct urcu_ref *ref) { struct lttng_action *action = - container_of(ref, struct lttng_action, ref); + lttng::utils::container_of(ref, <tng_action::ref); action->destroy(action); } diff --git a/src/common/actions/list.cpp b/src/common/actions/list.cpp index 1d962152b..4de7d81e8 100644 --- a/src/common/actions/list.cpp +++ b/src/common/actions/list.cpp @@ -48,7 +48,7 @@ static struct lttng_action_list *action_list_from_action( { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_list, parent); + return lttng::utils::container_of(action, <tng_action_list::parent); } static const struct lttng_action_list *action_list_from_action_const( @@ -56,7 +56,7 @@ static const struct lttng_action_list *action_list_from_action_const( { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_list, parent); + return lttng::utils::container_of(action, <tng_action_list::parent); } static bool lttng_action_list_validate(struct lttng_action *action) @@ -258,8 +258,6 @@ static enum lttng_action_status lttng_action_list_add_error_query_results( { unsigned int i, count; enum lttng_action_status action_status; - const struct lttng_action_list *list = - container_of(action, typeof(*list), parent); action_status = lttng_action_list_get_count(action, &count); if (action_status != LTTNG_ACTION_STATUS_OK) { diff --git a/src/common/actions/notify.cpp b/src/common/actions/notify.cpp index ff117321e..d58dcbe36 100644 --- a/src/common/actions/notify.cpp +++ b/src/common/actions/notify.cpp @@ -21,7 +21,7 @@ static struct lttng_action_notify *action_notify_from_action( { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_notify, parent); + return lttng::utils::container_of(action, <tng_action_notify::parent); } static const struct lttng_action_notify *action_notify_from_action_const( @@ -29,7 +29,7 @@ static const struct lttng_action_notify *action_notify_from_action_const( { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_notify, parent); + return lttng::utils::container_of(action, <tng_action_notify::parent); } static diff --git a/src/common/actions/rate-policy.cpp b/src/common/actions/rate-policy.cpp index c9c7a0519..303b4a781 100644 --- a/src/common/actions/rate-policy.cpp +++ b/src/common/actions/rate-policy.cpp @@ -348,7 +348,7 @@ static struct lttng_rate_policy_every_n *rate_policy_every_n_from_rate_policy( { LTTNG_ASSERT(policy); - return container_of(policy, struct lttng_rate_policy_every_n, parent); + return lttng::utils::container_of(policy, <tng_rate_policy_every_n::parent); } static const struct lttng_rate_policy_every_n * @@ -357,7 +357,7 @@ rate_policy_every_n_from_rate_policy_const( { LTTNG_ASSERT(policy); - return container_of(policy, struct lttng_rate_policy_every_n, parent); + return lttng::utils::container_of(policy, <tng_rate_policy_every_n::parent); } static int lttng_rate_policy_every_n_serialize( @@ -560,8 +560,8 @@ rate_policy_once_after_n_from_rate_policy(struct lttng_rate_policy *policy) { LTTNG_ASSERT(policy); - return container_of( - policy, struct lttng_rate_policy_once_after_n, parent); + return lttng::utils::container_of( + policy, <tng_rate_policy_once_after_n::parent); } static const struct lttng_rate_policy_once_after_n * @@ -570,8 +570,8 @@ rate_policy_once_after_n_from_rate_policy_const( { LTTNG_ASSERT(policy); - return container_of( - policy, struct lttng_rate_policy_once_after_n, parent); + return lttng::utils::container_of( + policy, <tng_rate_policy_once_after_n::parent); } static int lttng_rate_policy_once_after_n_serialize( struct lttng_rate_policy *policy, struct lttng_payload *payload) diff --git a/src/common/actions/rotate-session.cpp b/src/common/actions/rotate-session.cpp index 9c9a2a466..b25731484 100644 --- a/src/common/actions/rotate-session.cpp +++ b/src/common/actions/rotate-session.cpp @@ -49,7 +49,7 @@ static struct lttng_action_rotate_session *action_rotate_session_from_action( { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_rotate_session, parent); + return lttng::utils::container_of(action, <tng_action_rotate_session::parent); } static const struct lttng_action_rotate_session * @@ -57,7 +57,7 @@ action_rotate_session_from_action_const(const struct lttng_action *action) { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_rotate_session, parent); + return lttng::utils::container_of(action, <tng_action_rotate_session::parent); } static bool lttng_action_rotate_session_validate(struct lttng_action *action) diff --git a/src/common/actions/snapshot-session.cpp b/src/common/actions/snapshot-session.cpp index 6639ea55e..6af260c93 100644 --- a/src/common/actions/snapshot-session.cpp +++ b/src/common/actions/snapshot-session.cpp @@ -66,8 +66,8 @@ action_snapshot_session_from_action(struct lttng_action *action) { LTTNG_ASSERT(action); - return container_of( - action, struct lttng_action_snapshot_session, parent); + return lttng::utils::container_of( + action, <tng_action_snapshot_session::parent); } static const struct lttng_action_snapshot_session * @@ -75,8 +75,8 @@ action_snapshot_session_from_action_const(const struct lttng_action *action) { LTTNG_ASSERT(action); - return container_of( - action, struct lttng_action_snapshot_session, parent); + return lttng::utils::container_of( + action, <tng_action_snapshot_session::parent); } static bool lttng_action_snapshot_session_validate(struct lttng_action *action) diff --git a/src/common/actions/start-session.cpp b/src/common/actions/start-session.cpp index 91bb3505e..2c9f79972 100644 --- a/src/common/actions/start-session.cpp +++ b/src/common/actions/start-session.cpp @@ -49,7 +49,7 @@ static struct lttng_action_start_session *action_start_session_from_action( { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_start_session, parent); + return lttng::utils::container_of(action, <tng_action_start_session::parent); } static const struct lttng_action_start_session * @@ -57,7 +57,7 @@ action_start_session_from_action_const(const struct lttng_action *action) { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_start_session, parent); + return lttng::utils::container_of(action, <tng_action_start_session::parent); } static bool lttng_action_start_session_validate(struct lttng_action *action) @@ -90,8 +90,8 @@ static bool lttng_action_start_session_is_equal( bool is_equal = false; struct lttng_action_start_session *a, *b; - a = container_of(_a, struct lttng_action_start_session, parent); - b = container_of(_b, struct lttng_action_start_session, parent); + a = lttng::utils::container_of(_a, <tng_action_start_session::parent); + b = lttng::utils::container_of(_b, <tng_action_start_session::parent); /* Action is not valid if this is not true. */ LTTNG_ASSERT(a->session_name); diff --git a/src/common/actions/stop-session.cpp b/src/common/actions/stop-session.cpp index d395c66d6..08a6665dd 100644 --- a/src/common/actions/stop-session.cpp +++ b/src/common/actions/stop-session.cpp @@ -49,7 +49,7 @@ static struct lttng_action_stop_session *action_stop_session_from_action( { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_stop_session, parent); + return lttng::utils::container_of(action, <tng_action_stop_session::parent); } static const struct lttng_action_stop_session * @@ -57,7 +57,7 @@ action_stop_session_from_action_const(const struct lttng_action *action) { LTTNG_ASSERT(action); - return container_of(action, struct lttng_action_stop_session, parent); + return lttng::utils::container_of(action, <tng_action_stop_session::parent); } static bool lttng_action_stop_session_validate(struct lttng_action *action) diff --git a/src/common/compat/directory-handle.cpp b/src/common/compat/directory-handle.cpp index 904f59e94..cd4bf1769 100644 --- a/src/common/compat/directory-handle.cpp +++ b/src/common/compat/directory-handle.cpp @@ -176,7 +176,7 @@ void lttng_directory_handle_release(struct urcu_ref *ref) { int ret; struct lttng_directory_handle *handle = - container_of(ref, struct lttng_directory_handle, ref); + lttng::utils::container_of(ref, <tng_directory_handle::ref); if (handle->destroy_cb) { handle->destroy_cb(handle, handle->destroy_cb_data); @@ -557,7 +557,7 @@ static void lttng_directory_handle_release(struct urcu_ref *ref) { struct lttng_directory_handle *handle = - container_of(ref, struct lttng_directory_handle, ref); + lttng::utils::container_of(ref, <tng_directory_handle::ref); free(handle->base_path); lttng_directory_handle_invalidate(handle); diff --git a/src/common/conditions/buffer-usage.cpp b/src/common/conditions/buffer-usage.cpp index 57e1c79cb..6830877a1 100644 --- a/src/common/conditions/buffer-usage.cpp +++ b/src/common/conditions/buffer-usage.cpp @@ -33,8 +33,8 @@ void lttng_condition_buffer_usage_destroy(struct lttng_condition *condition) { struct lttng_condition_buffer_usage *usage; - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); free(usage->session_name); free(usage->channel_name); @@ -52,8 +52,8 @@ bool lttng_condition_buffer_usage_validate( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); if (!usage->session_name) { ERR("Invalid buffer condition: a target session name must be set."); goto end; @@ -92,8 +92,8 @@ int lttng_condition_buffer_usage_serialize( } DBG("Serializing buffer usage condition"); - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); session_name_len = strlen(usage->session_name) + 1; channel_name_len = strlen(usage->channel_name) + 1; @@ -142,8 +142,8 @@ bool lttng_condition_buffer_usage_is_equal(const struct lttng_condition *_a, bool is_equal = false; struct lttng_condition_buffer_usage *a, *b; - a = container_of(_a, struct lttng_condition_buffer_usage, parent); - b = container_of(_b, struct lttng_condition_buffer_usage, parent); + a = lttng::utils::container_of(_a, <tng_condition_buffer_usage::parent); + b = lttng::utils::container_of(_b, <tng_condition_buffer_usage::parent); if ((a->threshold_ratio.set && !b->threshold_ratio.set) || (a->threshold_bytes.set && !b->threshold_bytes.set)) { @@ -598,8 +598,8 @@ lttng_condition_buffer_usage_get_threshold_ratio( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); if (!usage->threshold_ratio.set) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -624,8 +624,8 @@ lttng_condition_buffer_usage_set_threshold_ratio( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); usage->threshold_ratio.set = true; usage->threshold_bytes.set = false; usage->threshold_ratio.value = threshold_ratio; @@ -646,8 +646,8 @@ lttng_condition_buffer_usage_get_threshold( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); if (!usage->threshold_bytes.set) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -669,8 +669,8 @@ lttng_condition_buffer_usage_set_threshold( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); usage->threshold_ratio.set = false; usage->threshold_bytes.set = true; usage->threshold_bytes.value = threshold_bytes; @@ -691,8 +691,8 @@ lttng_condition_buffer_usage_get_session_name( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); if (!usage->session_name) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -716,8 +716,8 @@ lttng_condition_buffer_usage_set_session_name( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); session_name_copy = strdup(session_name); if (!session_name_copy) { status = LTTNG_CONDITION_STATUS_ERROR; @@ -745,8 +745,8 @@ lttng_condition_buffer_usage_get_channel_name( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); if (!usage->channel_name) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -770,8 +770,8 @@ lttng_condition_buffer_usage_set_channel_name( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); channel_name_copy = strdup(channel_name); if (!channel_name_copy) { status = LTTNG_CONDITION_STATUS_ERROR; @@ -799,8 +799,8 @@ lttng_condition_buffer_usage_get_domain_type( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); if (!usage->domain.set) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -823,8 +823,8 @@ lttng_condition_buffer_usage_set_domain_type( goto end; } - usage = container_of(condition, struct lttng_condition_buffer_usage, - parent); + usage = lttng::utils::container_of(condition, + <tng_condition_buffer_usage::parent); usage->domain.set = true; usage->domain.type = type; end: @@ -839,8 +839,8 @@ int lttng_evaluation_buffer_usage_serialize( struct lttng_evaluation_buffer_usage *usage; struct lttng_evaluation_buffer_usage_comm comm; - usage = container_of(evaluation, struct lttng_evaluation_buffer_usage, - parent); + usage = lttng::utils::container_of(evaluation, + <tng_evaluation_buffer_usage::parent); comm.buffer_use = usage->buffer_use; comm.buffer_capacity = usage->buffer_capacity; @@ -854,8 +854,8 @@ void lttng_evaluation_buffer_usage_destroy( { struct lttng_evaluation_buffer_usage *usage; - usage = container_of(evaluation, struct lttng_evaluation_buffer_usage, - parent); + usage = lttng::utils::container_of(evaluation, + <tng_evaluation_buffer_usage::parent); free(usage); } @@ -894,8 +894,8 @@ lttng_evaluation_buffer_usage_get_usage_ratio( goto end; } - usage = container_of(evaluation, struct lttng_evaluation_buffer_usage, - parent); + usage = lttng::utils::container_of(evaluation, + <tng_evaluation_buffer_usage::parent); *usage_ratio = (double) usage->buffer_use / (double) usage->buffer_capacity; end: @@ -915,8 +915,8 @@ lttng_evaluation_buffer_usage_get_usage( goto end; } - usage = container_of(evaluation, struct lttng_evaluation_buffer_usage, - parent); + usage = lttng::utils::container_of(evaluation, + <tng_evaluation_buffer_usage::parent); *usage_bytes = usage->buffer_use; end: return status; diff --git a/src/common/conditions/condition.cpp b/src/common/conditions/condition.cpp index 525932eb2..1efab164d 100644 --- a/src/common/conditions/condition.cpp +++ b/src/common/conditions/condition.cpp @@ -32,7 +32,7 @@ void lttng_condition_destroy(struct lttng_condition *condition) static void condition_destroy_ref(struct urcu_ref *ref) { struct lttng_condition *condition = - container_of(ref, struct lttng_condition, ref); + lttng::utils::container_of(ref, <tng_condition::ref); condition->destroy(condition); } diff --git a/src/common/conditions/event-rule-matches.cpp b/src/common/conditions/event-rule-matches.cpp index 0a926755e..d302500c6 100644 --- a/src/common/conditions/event-rule-matches.cpp +++ b/src/common/conditions/event-rule-matches.cpp @@ -55,8 +55,8 @@ static bool lttng_condition_event_rule_matches_validate( goto end; } - event_rule = container_of(condition, - struct lttng_condition_event_rule_matches, parent); + event_rule = lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); if (!event_rule->rule) { ERR("Invalid on event condition: a rule must be set"); goto end; @@ -167,9 +167,8 @@ int serialize_event_expr(const struct lttng_event_expr *expr, case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD: { const struct lttng_event_expr_field *field_expr = - container_of(expr, - const struct lttng_event_expr_field, - parent); + lttng::utils::container_of(expr, + <tng_event_expr_field::parent); /* Serialize the field name. */ DBG("Serializing field event expression's field name: '%s'", @@ -184,9 +183,8 @@ int serialize_event_expr(const struct lttng_event_expr *expr, case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD: { const struct lttng_event_expr_app_specific_context_field *field_expr = - container_of(expr, - const struct lttng_event_expr_app_specific_context_field, - parent); + lttng::utils::container_of(expr, + <tng_event_expr_app_specific_context_field::parent); /* Serialize the provider name. */ DBG("Serializing app-specific context field event expression's " @@ -211,9 +209,8 @@ int serialize_event_expr(const struct lttng_event_expr *expr, case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT: { const struct lttng_event_expr_array_field_element *elem_expr = - container_of(expr, - const struct lttng_event_expr_array_field_element, - parent); + lttng::utils::container_of(expr, + <tng_event_expr_array_field_element::parent); const uint32_t index = elem_expr->index; /* Serialize the index. */ @@ -247,9 +244,8 @@ lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index( const struct lttng_condition *condition, unsigned int index) { const struct lttng_condition_event_rule_matches - *event_rule_matches_cond = container_of(condition, - const struct lttng_condition_event_rule_matches, - parent); + *event_rule_matches_cond = lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); struct lttng_capture_descriptor *desc = NULL; unsigned int count; enum lttng_condition_status status; @@ -290,8 +286,8 @@ static int lttng_condition_event_rule_matches_serialize( } DBG("Serializing on event condition"); - event_rule_matches_condition = container_of(condition, - struct lttng_condition_event_rule_matches, parent); + event_rule_matches_condition = lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); DBG("Serializing on event condition's event rule"); ret = lttng_event_rule_serialize( @@ -388,8 +384,8 @@ static bool lttng_condition_event_rule_matches_is_equal( bool is_equal = false; struct lttng_condition_event_rule_matches *a, *b; - a = container_of(_a, struct lttng_condition_event_rule_matches, parent); - b = container_of(_b, struct lttng_condition_event_rule_matches, parent); + a = lttng::utils::container_of(_a, <tng_condition_event_rule_matches::parent); + b = lttng::utils::container_of(_b, <tng_condition_event_rule_matches::parent); /* Both event rules must be set or both must be unset. */ if ((a->rule && !b->rule) || (!a->rule && b->rule)) { @@ -413,8 +409,8 @@ static void lttng_condition_event_rule_matches_destroy( { struct lttng_condition_event_rule_matches *event_rule_matches_condition; - event_rule_matches_condition = container_of(condition, - struct lttng_condition_event_rule_matches, parent); + event_rule_matches_condition = lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); lttng_event_rule_put(event_rule_matches_condition->rule); lttng_dynamic_pointer_array_reset( @@ -793,8 +789,8 @@ lttng_condition_event_rule_matches_borrow_rule_mutable( goto end; } - event_rule = container_of(condition, - struct lttng_condition_event_rule_matches, parent); + event_rule = lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); if (!event_rule->rule) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -822,9 +818,8 @@ void lttng_condition_event_rule_matches_set_error_counter_index( struct lttng_condition *condition, uint64_t error_counter_index) { struct lttng_condition_event_rule_matches *event_rule_matches_cond = - container_of(condition, - struct lttng_condition_event_rule_matches, - parent); + lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); LTTNG_OPTIONAL_SET(&event_rule_matches_cond->error_counter_index, error_counter_index); @@ -834,9 +829,8 @@ uint64_t lttng_condition_event_rule_matches_get_error_counter_index( const struct lttng_condition *condition) { const struct lttng_condition_event_rule_matches - *event_rule_matches_cond = container_of(condition, - const struct lttng_condition_event_rule_matches, - parent); + *event_rule_matches_cond = lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); return LTTNG_OPTIONAL_GET(event_rule_matches_cond->error_counter_index); } @@ -849,9 +843,8 @@ lttng_condition_event_rule_matches_append_capture_descriptor( int ret; enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK; struct lttng_condition_event_rule_matches *event_rule_matches_cond = - container_of(condition, - struct lttng_condition_event_rule_matches, - parent); + lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); struct lttng_capture_descriptor *descriptor = NULL; const struct lttng_event_rule *rule = NULL; @@ -919,9 +912,8 @@ lttng_condition_event_rule_matches_get_capture_descriptor_count( { enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK; const struct lttng_condition_event_rule_matches - *event_rule_matches_condition = container_of(condition, - const struct lttng_condition_event_rule_matches, - parent); + *event_rule_matches_condition = lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) || !count) { @@ -1020,8 +1012,8 @@ static int lttng_evaluation_event_rule_matches_serialize( struct lttng_evaluation_event_rule_matches *hit; uint32_t capture_payload_size; - hit = container_of(evaluation, - struct lttng_evaluation_event_rule_matches, parent); + hit = lttng::utils::container_of(evaluation, + <tng_evaluation_event_rule_matches::parent); capture_payload_size = (uint32_t) hit->capture_payload.size; ret = lttng_dynamic_buffer_append(&payload->buffer, &capture_payload_size, @@ -1090,8 +1082,8 @@ static void lttng_evaluation_event_rule_matches_destroy( { struct lttng_evaluation_event_rule_matches *hit; - hit = container_of(evaluation, - struct lttng_evaluation_event_rule_matches, parent); + hit = lttng::utils::container_of(evaluation, + <tng_evaluation_event_rule_matches::parent); lttng_dynamic_buffer_reset(&hit->capture_payload); lttng_event_field_value_destroy(hit->captured_values); free(hit); @@ -1445,8 +1437,8 @@ lttng_evaluation_event_rule_matches_get_captured_values( goto end; } - hit = container_of(evaluation, - struct lttng_evaluation_event_rule_matches, parent); + hit = lttng::utils::container_of(evaluation, + <tng_evaluation_event_rule_matches::parent); if (!hit->captured_values) { status = LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_NONE; goto end; @@ -1511,9 +1503,8 @@ lttng_condition_event_rule_matches_get_capture_bytecode_at_index( const struct lttng_condition *condition, unsigned int index) { const struct lttng_condition_event_rule_matches - *event_rule_matches_cond = container_of(condition, - const struct lttng_condition_event_rule_matches, - parent); + *event_rule_matches_cond = lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent); struct lttng_capture_descriptor *desc = NULL; struct lttng_bytecode *bytecode = NULL; unsigned int count; diff --git a/src/common/conditions/session-consumed-size.cpp b/src/common/conditions/session-consumed-size.cpp index abb5db8ce..69951b5c2 100644 --- a/src/common/conditions/session-consumed-size.cpp +++ b/src/common/conditions/session-consumed-size.cpp @@ -28,8 +28,8 @@ void lttng_condition_session_consumed_size_destroy(struct lttng_condition *condi { struct lttng_condition_session_consumed_size *consumed_size; - consumed_size = container_of(condition, - struct lttng_condition_session_consumed_size, parent); + consumed_size = lttng::utils::container_of(condition, + <tng_condition_session_consumed_size::parent); free(consumed_size->session_name); free(consumed_size); @@ -46,8 +46,8 @@ bool lttng_condition_session_consumed_size_validate( goto end; } - consumed = container_of(condition, struct lttng_condition_session_consumed_size, - parent); + consumed = lttng::utils::container_of(condition, + <tng_condition_session_consumed_size::parent); if (!consumed->session_name) { ERR("Invalid session consumed size condition: a target session name must be set."); goto end; @@ -78,9 +78,8 @@ int lttng_condition_session_consumed_size_serialize( } DBG("Serializing session consumed size condition"); - consumed = container_of(condition, - struct lttng_condition_session_consumed_size, - parent); + consumed = lttng::utils::container_of(condition, + <tng_condition_session_consumed_size::parent); session_name_len = strlen(consumed->session_name) + 1; if (session_name_len > LTTNG_NAME_MAX) { @@ -114,8 +113,8 @@ bool lttng_condition_session_consumed_size_is_equal(const struct lttng_condition bool is_equal = false; struct lttng_condition_session_consumed_size *a, *b; - a = container_of(_a, struct lttng_condition_session_consumed_size, parent); - b = container_of(_b, struct lttng_condition_session_consumed_size, parent); + a = lttng::utils::container_of(_a, <tng_condition_session_consumed_size::parent); + b = lttng::utils::container_of(_b, <tng_condition_session_consumed_size::parent); if (a->consumed_threshold_bytes.set && b->consumed_threshold_bytes.set) { uint64_t a_value, b_value; @@ -368,8 +367,8 @@ lttng_condition_session_consumed_size_get_threshold( goto end; } - consumed = container_of(condition, struct lttng_condition_session_consumed_size, - parent); + consumed = lttng::utils::container_of(condition, + <tng_condition_session_consumed_size::parent); if (!consumed->consumed_threshold_bytes.set) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -391,8 +390,8 @@ lttng_condition_session_consumed_size_set_threshold( goto end; } - consumed = container_of(condition, struct lttng_condition_session_consumed_size, - parent); + consumed = lttng::utils::container_of(condition, + <tng_condition_session_consumed_size::parent); consumed->consumed_threshold_bytes.set = true; consumed->consumed_threshold_bytes.value = consumed_threshold_bytes; end: @@ -412,8 +411,8 @@ lttng_condition_session_consumed_size_get_session_name( goto end; } - consumed = container_of(condition, struct lttng_condition_session_consumed_size, - parent); + consumed = lttng::utils::container_of(condition, + <tng_condition_session_consumed_size::parent); if (!consumed->session_name) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -437,8 +436,8 @@ lttng_condition_session_consumed_size_set_session_name( goto end; } - consumed = container_of(condition, struct lttng_condition_session_consumed_size, - parent); + consumed = lttng::utils::container_of(condition, + <tng_condition_session_consumed_size::parent); session_name_copy = strdup(session_name); if (!session_name_copy) { status = LTTNG_CONDITION_STATUS_ERROR; @@ -461,8 +460,8 @@ int lttng_evaluation_session_consumed_size_serialize( struct lttng_evaluation_session_consumed_size *consumed; struct lttng_evaluation_session_consumed_size_comm comm; - consumed = container_of(evaluation, - struct lttng_evaluation_session_consumed_size, parent); + consumed = lttng::utils::container_of(evaluation, + <tng_evaluation_session_consumed_size::parent); comm.session_consumed = consumed->session_consumed; return lttng_dynamic_buffer_append( &payload->buffer, &comm, sizeof(comm)); @@ -474,8 +473,8 @@ void lttng_evaluation_session_consumed_size_destroy( { struct lttng_evaluation_session_consumed_size *consumed; - consumed = container_of(evaluation, struct lttng_evaluation_session_consumed_size, - parent); + consumed = lttng::utils::container_of(evaluation, + <tng_evaluation_session_consumed_size::parent); free(consumed); } @@ -511,8 +510,8 @@ lttng_evaluation_session_consumed_size_get_consumed_size( goto end; } - consumed = container_of(evaluation, struct lttng_evaluation_session_consumed_size, - parent); + consumed = lttng::utils::container_of(evaluation, + <tng_evaluation_session_consumed_size::parent); *session_consumed = consumed->session_consumed; end: return status; diff --git a/src/common/conditions/session-rotation.cpp b/src/common/conditions/session-rotation.cpp index 82e843465..7f0896f92 100644 --- a/src/common/conditions/session-rotation.cpp +++ b/src/common/conditions/session-rotation.cpp @@ -87,8 +87,8 @@ bool lttng_condition_session_rotation_validate( goto end; } - rotation = container_of(condition, - struct lttng_condition_session_rotation, parent); + rotation = lttng::utils::container_of(condition, + <tng_condition_session_rotation::parent); if (!rotation->session_name) { ERR("Invalid session rotation condition: a target session name must be set."); goto end; @@ -115,8 +115,8 @@ int lttng_condition_session_rotation_serialize( } DBG("Serializing session rotation condition"); - rotation = container_of(condition, struct lttng_condition_session_rotation, - parent); + rotation = lttng::utils::container_of(condition, + <tng_condition_session_rotation::parent); session_name_len = strlen(rotation->session_name) + 1; if (session_name_len > LTTNG_NAME_MAX) { @@ -146,8 +146,8 @@ bool lttng_condition_session_rotation_is_equal(const struct lttng_condition *_a, bool is_equal = false; struct lttng_condition_session_rotation *a, *b; - a = container_of(_a, struct lttng_condition_session_rotation, parent); - b = container_of(_b, struct lttng_condition_session_rotation, parent); + a = lttng::utils::container_of(_a, <tng_condition_session_rotation::parent); + b = lttng::utils::container_of(_b, <tng_condition_session_rotation::parent); /* Both session names must be set or both must be unset. */ if ((a->session_name && !b->session_name) || @@ -172,8 +172,8 @@ void lttng_condition_session_rotation_destroy( { struct lttng_condition_session_rotation *rotation; - rotation = container_of(condition, - struct lttng_condition_session_rotation, parent); + rotation = lttng::utils::container_of(condition, + <tng_condition_session_rotation::parent); free(rotation->session_name); free(rotation); @@ -474,8 +474,8 @@ lttng_condition_session_rotation_get_session_name( goto end; } - rotation = container_of(condition, struct lttng_condition_session_rotation, - parent); + rotation = lttng::utils::container_of(condition, + <tng_condition_session_rotation::parent); if (!rotation->session_name) { status = LTTNG_CONDITION_STATUS_UNSET; goto end; @@ -499,8 +499,8 @@ lttng_condition_session_rotation_set_session_name( goto end; } - rotation = container_of(condition, - struct lttng_condition_session_rotation, parent); + rotation = lttng::utils::container_of(condition, + <tng_condition_session_rotation::parent); session_name_copy = strdup(session_name); if (!session_name_copy) { status = LTTNG_CONDITION_STATUS_ERROR; @@ -522,8 +522,8 @@ int lttng_evaluation_session_rotation_serialize( struct lttng_evaluation_session_rotation *rotation; struct lttng_evaluation_session_rotation_comm comm = {}; - rotation = container_of(evaluation, - struct lttng_evaluation_session_rotation, parent); + rotation = lttng::utils::container_of(evaluation, + <tng_evaluation_session_rotation::parent); comm.id = rotation->id; comm.has_location = !!rotation->location; ret = lttng_dynamic_buffer_append( @@ -546,8 +546,8 @@ void lttng_evaluation_session_rotation_destroy( { struct lttng_evaluation_session_rotation *rotation; - rotation = container_of(evaluation, - struct lttng_evaluation_session_rotation, parent); + rotation = lttng::utils::container_of(evaluation, + <tng_evaluation_session_rotation::parent); lttng_trace_archive_location_put(rotation->location); free(rotation); } @@ -564,8 +564,8 @@ lttng_evaluation_session_rotation_get_id( goto end; } - rotation = container_of(evaluation, - struct lttng_evaluation_session_rotation, parent); + rotation = lttng::utils::container_of(evaluation, + <tng_evaluation_session_rotation::parent); *id = rotation->id; end: return status; @@ -591,8 +591,8 @@ lttng_evaluation_session_rotation_completed_get_location( goto end; } - rotation = container_of(evaluation, - struct lttng_evaluation_session_rotation, parent); + rotation = lttng::utils::container_of(evaluation, + <tng_evaluation_session_rotation::parent); *location = rotation->location; end: return status; diff --git a/src/common/consumer/consumer-stream.cpp b/src/common/consumer/consumer-stream.cpp index c22c7e5f3..33f97c77e 100644 --- a/src/common/consumer/consumer-stream.cpp +++ b/src/common/consumer/consumer-stream.cpp @@ -35,9 +35,9 @@ static void free_stream_rcu(struct rcu_head *head) { struct lttng_ht_node_u64 *node = - caa_container_of(head, struct lttng_ht_node_u64, head); + lttng::utils::container_of(head, <tng_ht_node_u64::head); struct lttng_consumer_stream *stream = - caa_container_of(node, struct lttng_consumer_stream, node); + lttng::utils::container_of(node, <tng_consumer_stream::node); pthread_mutex_destroy(&stream->lock); free(stream); diff --git a/src/common/consumer/consumer.cpp b/src/common/consumer/consumer.cpp index a5691b1c2..ae8469ea2 100644 --- a/src/common/consumer/consumer.cpp +++ b/src/common/consumer/consumer.cpp @@ -209,7 +209,7 @@ static struct lttng_consumer_stream *find_stream(uint64_t key, lttng_ht_lookup(ht, &key, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (node != NULL) { - stream = caa_container_of(node, struct lttng_consumer_stream, node); + stream = lttng::utils::container_of(node, <tng_consumer_stream::node); } rcu_read_unlock(); @@ -257,7 +257,7 @@ struct lttng_consumer_channel *consumer_find_channel(uint64_t key) lttng_ht_lookup(the_consumer_data.channel_ht, &key, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (node != NULL) { - channel = caa_container_of(node, struct lttng_consumer_channel, node); + channel = lttng::utils::container_of(node, <tng_consumer_channel::node); } return channel; @@ -292,9 +292,9 @@ static void steal_channel_key(uint64_t key) static void free_channel_rcu(struct rcu_head *head) { struct lttng_ht_node_u64 *node = - caa_container_of(head, struct lttng_ht_node_u64, head); + lttng::utils::container_of(head, <tng_ht_node_u64::head); struct lttng_consumer_channel *channel = - caa_container_of(node, struct lttng_consumer_channel, node); + lttng::utils::container_of(node, <tng_consumer_channel::node); switch (the_consumer_data.type) { case LTTNG_CONSUMER_KERNEL: @@ -316,9 +316,9 @@ static void free_channel_rcu(struct rcu_head *head) static void free_relayd_rcu(struct rcu_head *head) { struct lttng_ht_node_u64 *node = - caa_container_of(head, struct lttng_ht_node_u64, head); + lttng::utils::container_of(head, <tng_ht_node_u64::head); struct consumer_relayd_sock_pair *relayd = - caa_container_of(node, struct consumer_relayd_sock_pair, node); + lttng::utils::container_of(node, &consumer_relayd_sock_pair::node); /* * Close all sockets. This is done in the call RCU since we don't want the @@ -705,7 +705,7 @@ struct consumer_relayd_sock_pair *consumer_find_relayd(uint64_t key) lttng_ht_lookup(the_consumer_data.relayd_ht, &key, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (node != NULL) { - relayd = caa_container_of(node, struct consumer_relayd_sock_pair, node); + relayd = lttng::utils::container_of(node, &consumer_relayd_sock_pair::node); } error: diff --git a/src/common/error-query.cpp b/src/common/error-query.cpp index 8c1bb9541..38265fe8b 100644 --- a/src/common/error-query.cpp +++ b/src/common/error-query.cpp @@ -256,8 +256,7 @@ void lttng_error_query_destroy(struct lttng_error_query *query) case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER: { struct lttng_error_query_trigger *trigger_query = - container_of(query, typeof(*trigger_query), - parent); + lttng::utils::container_of(query, <tng_error_query_trigger::parent); lttng_trigger_put(trigger_query->trigger); free(trigger_query); @@ -265,9 +264,8 @@ void lttng_error_query_destroy(struct lttng_error_query *query) } case LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION: { - struct lttng_error_query_condition *condition_query = - container_of(query, typeof(*condition_query), - parent); + struct lttng_error_query_condition *condition_query = lttng::utils::container_of( + query, <tng_error_query_condition::parent); lttng_trigger_put(condition_query->trigger); free(condition_query); @@ -275,9 +273,8 @@ void lttng_error_query_destroy(struct lttng_error_query *query) } case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION: { - struct lttng_error_query_action *action_query = - container_of(query, typeof(*action_query), - parent); + struct lttng_error_query_action *action_query = lttng::utils::container_of( + query, <tng_error_query_action::parent); lttng_trigger_put(action_query->trigger); lttng_action_path_destroy(action_query->action_path); @@ -297,7 +294,8 @@ int lttng_error_query_result_counter_serialize( const struct lttng_error_query_result_counter *counter_result; LTTNG_ASSERT(result->type == LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER); - counter_result = container_of(result, typeof(*counter_result), parent); + counter_result = lttng::utils::container_of( + result, <tng_error_query_result_counter::parent); lttng_error_query_result_counter_comm comm = { .value = counter_result->value, @@ -662,7 +660,7 @@ int lttng_error_query_trigger_serialize(const struct lttng_error_query *query, { int ret; const struct lttng_error_query_trigger *query_trigger = - container_of(query, typeof(*query_trigger), parent); + lttng::utils::container_of(query, <tng_error_query_trigger::parent); if (!lttng_trigger_validate(query_trigger->trigger)) { ret = -1; @@ -684,7 +682,7 @@ int lttng_error_query_condition_serialize(const struct lttng_error_query *query, { int ret; const struct lttng_error_query_condition *query_trigger = - container_of(query, typeof(*query_trigger), parent); + lttng::utils::container_of(query, <tng_error_query_condition::parent); if (!lttng_trigger_validate(query_trigger->trigger)) { ret = -1; @@ -706,7 +704,7 @@ int lttng_error_query_action_serialize(const struct lttng_error_query *query, { int ret; const struct lttng_error_query_action *query_action = - container_of(query, typeof(*query_action), parent); + lttng::utils::container_of(query, <tng_error_query_action::parent); if (!lttng_trigger_validate(query_action->trigger)) { ret = -1; @@ -737,7 +735,7 @@ const struct lttng_trigger *lttng_error_query_trigger_borrow_target( const struct lttng_error_query *query) { const struct lttng_error_query_trigger *query_trigger = - container_of(query, typeof(*query_trigger), parent); + lttng::utils::container_of(query, <tng_error_query_trigger::parent); return query_trigger->trigger; } @@ -746,7 +744,7 @@ const struct lttng_trigger *lttng_error_query_condition_borrow_target( const struct lttng_error_query *query) { const struct lttng_error_query_condition *query_trigger = - container_of(query, typeof(*query_trigger), parent); + lttng::utils::container_of(query, <tng_error_query_condition::parent); return query_trigger->trigger; } @@ -755,17 +753,16 @@ const struct lttng_trigger *lttng_error_query_action_borrow_trigger_target( const struct lttng_error_query *query) { const struct lttng_error_query_action *query_action = - container_of(query, typeof(*query_action), parent); + lttng::utils::container_of(query, <tng_error_query_action::parent); return query_action->trigger; } struct lttng_action *lttng_error_query_action_borrow_action_target( - const struct lttng_error_query *query, - struct lttng_trigger *trigger) + const struct lttng_error_query *query, struct lttng_trigger *trigger) { const struct lttng_error_query_action *query_action = - container_of(query, typeof(*query_action), parent); + lttng::utils::container_of(query, <tng_error_query_action::parent); return get_trigger_action_from_path( trigger, query_action->action_path); @@ -1071,7 +1068,8 @@ enum lttng_error_query_result_status lttng_error_query_result_counter_get_value( goto end; } - counter_result = container_of(result, typeof(*counter_result), parent); + counter_result = lttng::utils::container_of( + result, <tng_error_query_result_counter::parent); *value = counter_result->value; status = LTTNG_ERROR_QUERY_RESULT_STATUS_OK; diff --git a/src/common/evaluation.cpp b/src/common/evaluation.cpp index a0fbc9dd9..e6ebeec8e 100644 --- a/src/common/evaluation.cpp +++ b/src/common/evaluation.cpp @@ -118,9 +118,8 @@ ssize_t lttng_evaluation_create_from_payload( LTTNG_ASSERT(condition->type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES); ret = lttng_evaluation_event_rule_matches_create_from_payload( - container_of(condition, - const struct lttng_condition_event_rule_matches, - parent), + lttng::utils::container_of(condition, + <tng_condition_event_rule_matches::parent), &evaluation_view, evaluation); if (ret < 0) { goto end; diff --git a/src/common/event-expr/event-expr.cpp b/src/common/event-expr/event-expr.cpp index 1b592bdb1..0dd0398f2 100644 --- a/src/common/event-expr/event-expr.cpp +++ b/src/common/event-expr/event-expr.cpp @@ -56,10 +56,8 @@ struct lttng_event_expr_field *create_field_event_expr( enum lttng_event_expr_type type, const char *name) { - struct lttng_event_expr_field *expr = - container_of( - create_empty_expr(type, sizeof(*expr)), - struct lttng_event_expr_field, parent); + struct lttng_event_expr_field *expr = lttng::utils::container_of( + create_empty_expr(type, sizeof(*expr)), <tng_event_expr_field::parent); if (!expr) { goto error; @@ -127,11 +125,10 @@ struct lttng_event_expr *lttng_event_expr_app_specific_context_field_create( goto error; } - expr = container_of(create_empty_expr( + expr = lttng::utils::container_of(create_empty_expr( LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD, sizeof(*expr)), - struct lttng_event_expr_app_specific_context_field, - parent); + <tng_event_expr_app_specific_context_field::parent); if (!expr) { goto error; } @@ -172,11 +169,10 @@ struct lttng_event_expr *lttng_event_expr_array_field_element_create( goto error; } - expr = container_of(create_empty_expr( + expr = lttng::utils::container_of(create_empty_expr( LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT, sizeof(*expr)), - struct lttng_event_expr_array_field_element, - parent); + <tng_event_expr_array_field_element::parent); if (!expr) { goto error; } @@ -202,8 +198,8 @@ const char *lttng_event_expr_event_payload_field_get_name( goto end; } - ret = container_of(expr, - const struct lttng_event_expr_field, parent)->name; + ret = lttng::utils::container_of(expr, + <tng_event_expr_field::parent)->name; end: return ret; @@ -218,8 +214,8 @@ const char *lttng_event_expr_channel_context_field_get_name( goto end; } - ret = container_of(expr, - const struct lttng_event_expr_field, parent)->name; + ret = lttng::utils::container_of(expr, + <tng_event_expr_field::parent)->name; end: return ret; @@ -234,9 +230,8 @@ const char *lttng_event_expr_app_specific_context_field_get_provider_name( goto end; } - ret = container_of(expr, - const struct lttng_event_expr_app_specific_context_field, - parent)->provider_name; + ret = lttng::utils::container_of(expr, + <tng_event_expr_app_specific_context_field::parent)->provider_name; end: return ret; @@ -251,9 +246,8 @@ const char *lttng_event_expr_app_specific_context_field_get_type_name( goto end; } - ret = container_of(expr, - const struct lttng_event_expr_app_specific_context_field, - parent)->type_name; + ret = lttng::utils::container_of(expr, + <tng_event_expr_app_specific_context_field::parent)->type_name; end: return ret; @@ -269,9 +263,8 @@ lttng_event_expr_array_field_element_get_parent_expr( goto end; } - ret = container_of(expr, - const struct lttng_event_expr_array_field_element, - parent)->array_field_expr; + ret = lttng::utils::container_of(expr, + <tng_event_expr_array_field_element::parent)->array_field_expr; end: return ret; @@ -288,9 +281,8 @@ enum lttng_event_expr_status lttng_event_expr_array_field_element_get_index( goto end; } - *index = container_of(expr, - const struct lttng_event_expr_array_field_element, - parent)->index; + *index = lttng::utils::container_of(expr, + <tng_event_expr_array_field_element::parent)->index; end: return ret; @@ -321,13 +313,11 @@ bool lttng_event_expr_is_equal(const struct lttng_event_expr *expr_a, case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD: { const struct lttng_event_expr_field *field_expr_a = - container_of(expr_a, - const struct lttng_event_expr_field, - parent); + lttng::utils::container_of(expr_a, + <tng_event_expr_field::parent); const struct lttng_event_expr_field *field_expr_b = - container_of(expr_b, - const struct lttng_event_expr_field, - parent); + lttng::utils::container_of(expr_b, + <tng_event_expr_field::parent); if (strcmp(field_expr_a->name, field_expr_b->name) != 0) { goto not_equal; @@ -338,13 +328,11 @@ bool lttng_event_expr_is_equal(const struct lttng_event_expr *expr_a, case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD: { const struct lttng_event_expr_app_specific_context_field *field_expr_a = - container_of(expr_a, - const struct lttng_event_expr_app_specific_context_field, - parent); + lttng::utils::container_of(expr_a, + <tng_event_expr_app_specific_context_field::parent); const struct lttng_event_expr_app_specific_context_field *field_expr_b = - container_of(expr_b, - const struct lttng_event_expr_app_specific_context_field, - parent); + lttng::utils::container_of(expr_b, + <tng_event_expr_app_specific_context_field::parent); if (strcmp(field_expr_a->provider_name, field_expr_b->provider_name) != 0) { @@ -361,13 +349,11 @@ bool lttng_event_expr_is_equal(const struct lttng_event_expr *expr_a, case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT: { const struct lttng_event_expr_array_field_element *elem_expr_a = - container_of(expr_a, - const struct lttng_event_expr_array_field_element, - parent); + lttng::utils::container_of(expr_a, + <tng_event_expr_array_field_element::parent); const struct lttng_event_expr_array_field_element *elem_expr_b = - container_of(expr_b, - const struct lttng_event_expr_array_field_element, - parent); + lttng::utils::container_of(expr_b, + <tng_event_expr_array_field_element::parent); if (!lttng_event_expr_is_equal(elem_expr_a->array_field_expr, elem_expr_b->array_field_expr)) { @@ -404,8 +390,8 @@ void lttng_event_expr_destroy(struct lttng_event_expr *expr) case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD: { struct lttng_event_expr_field *field_expr = - container_of(expr, - struct lttng_event_expr_field, parent); + lttng::utils::container_of(expr, + <tng_event_expr_field::parent); free(field_expr->name); break; @@ -413,9 +399,8 @@ void lttng_event_expr_destroy(struct lttng_event_expr *expr) case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD: { struct lttng_event_expr_app_specific_context_field *field_expr = - container_of(expr, - struct lttng_event_expr_app_specific_context_field, - parent); + lttng::utils::container_of(expr, + <tng_event_expr_app_specific_context_field::parent); free(field_expr->provider_name); free(field_expr->type_name); @@ -424,9 +409,8 @@ void lttng_event_expr_destroy(struct lttng_event_expr *expr) case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT: { struct lttng_event_expr_array_field_element *elem_expr = - container_of(expr, - struct lttng_event_expr_array_field_element, - parent); + lttng::utils::container_of(expr, + <tng_event_expr_array_field_element::parent); lttng_event_expr_destroy(elem_expr->array_field_expr); break; diff --git a/src/common/event-field-value.cpp b/src/common/event-field-value.cpp index 3ab12728c..8017fd081 100644 --- a/src/common/event-field-value.cpp +++ b/src/common/event-field-value.cpp @@ -39,10 +39,10 @@ struct lttng_event_field_value *lttng_event_field_value_uint_create( { struct lttng_event_field_value_uint *field_val; - field_val = container_of(create_empty_field_val( + field_val = lttng::utils::container_of(create_empty_field_val( LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT, sizeof(*field_val)), - struct lttng_event_field_value_uint, parent); + <tng_event_field_value_uint::parent); if (!field_val) { goto error; } @@ -62,10 +62,10 @@ struct lttng_event_field_value *lttng_event_field_value_int_create( { struct lttng_event_field_value_int *field_val; - field_val = container_of(create_empty_field_val( + field_val = lttng::utils::container_of(create_empty_field_val( LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT, sizeof(*field_val)), - struct lttng_event_field_value_int, parent); + <tng_event_field_value_int::parent); if (!field_val) { goto error; } @@ -86,8 +86,8 @@ struct lttng_event_field_value_enum *create_enum_field_val( { struct lttng_event_field_value_enum *field_val; - field_val = container_of(create_empty_field_val(type, size), - struct lttng_event_field_value_enum, parent); + field_val = lttng::utils::container_of(create_empty_field_val(type, size), + <tng_event_field_value_enum::parent); if (!field_val) { goto error; } @@ -107,10 +107,10 @@ struct lttng_event_field_value *lttng_event_field_value_enum_uint_create( { struct lttng_event_field_value_enum_uint *field_val; - field_val = container_of(create_enum_field_val( + field_val = lttng::utils::container_of(create_enum_field_val( LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM, sizeof(*field_val)), - struct lttng_event_field_value_enum_uint, parent); + <tng_event_field_value_enum_uint::parent); if (!field_val) { goto error; } @@ -130,10 +130,10 @@ struct lttng_event_field_value *lttng_event_field_value_enum_int_create( { struct lttng_event_field_value_enum_int *field_val; - field_val = container_of(create_enum_field_val( + field_val = lttng::utils::container_of(create_enum_field_val( LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM, sizeof(*field_val)), - struct lttng_event_field_value_enum_int, parent); + <tng_event_field_value_enum_int::parent); if (!field_val) { goto error; } @@ -150,11 +150,11 @@ end: struct lttng_event_field_value *lttng_event_field_value_real_create(double val) { - struct lttng_event_field_value_real *field_val = container_of( + struct lttng_event_field_value_real *field_val = lttng::utils::container_of( create_empty_field_val( LTTNG_EVENT_FIELD_VALUE_TYPE_REAL, sizeof(*field_val)), - struct lttng_event_field_value_real, parent); + <tng_event_field_value_real::parent); if (!field_val) { goto error; @@ -173,11 +173,11 @@ end: struct lttng_event_field_value *lttng_event_field_value_string_create_with_size( const char *val, size_t size) { - struct lttng_event_field_value_string *field_val = container_of( + struct lttng_event_field_value_string *field_val = lttng::utils::container_of( create_empty_field_val( LTTNG_EVENT_FIELD_VALUE_TYPE_STRING, sizeof(*field_val)), - struct lttng_event_field_value_string, parent); + <tng_event_field_value_string::parent); if (!field_val) { goto error; @@ -214,11 +214,11 @@ void destroy_field_val(void *field_val) struct lttng_event_field_value *lttng_event_field_value_array_create(void) { - struct lttng_event_field_value_array *field_val = container_of( + struct lttng_event_field_value_array *field_val = lttng::utils::container_of( create_empty_field_val( LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY, sizeof(*field_val)), - struct lttng_event_field_value_array, parent); + <tng_event_field_value_array::parent); if (!field_val) { goto error; @@ -245,8 +245,8 @@ void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val) case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM: { struct lttng_event_field_value_enum *enum_field_val = - container_of(field_val, - struct lttng_event_field_value_enum, parent); + lttng::utils::container_of(field_val, + <tng_event_field_value_enum::parent); lttng_dynamic_pointer_array_reset(&enum_field_val->labels); break; @@ -254,8 +254,8 @@ void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val) case LTTNG_EVENT_FIELD_VALUE_TYPE_STRING: { struct lttng_event_field_value_string *str_field_val = - container_of(field_val, - struct lttng_event_field_value_string, parent); + lttng::utils::container_of(field_val, + <tng_event_field_value_string::parent); free(str_field_val->val); break; @@ -263,9 +263,8 @@ void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val) case LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY: { struct lttng_event_field_value_array *array_field_expr = - container_of(field_val, - struct lttng_event_field_value_array, - parent); + lttng::utils::container_of(field_val, + <tng_event_field_value_array::parent); lttng_dynamic_pointer_array_reset(&array_field_expr->elems); break; @@ -296,8 +295,8 @@ int lttng_event_field_value_enum_append_label_with_size( } ret = lttng_dynamic_pointer_array_add_pointer( - &container_of(field_val, - struct lttng_event_field_value_enum, parent)->labels, + <tng::utils::container_of(field_val, + <tng_event_field_value_enum::parent)->labels, new_label); if (ret == 0) { new_label = NULL; @@ -324,8 +323,8 @@ int lttng_event_field_value_array_append( LTTNG_ASSERT(array_field_val); LTTNG_ASSERT(field_val); return lttng_dynamic_pointer_array_add_pointer( - &container_of(array_field_val, - struct lttng_event_field_value_array, parent)->elems, + <tng::utils::container_of(array_field_val, + <tng_event_field_value_array::parent)->elems, field_val); } @@ -334,8 +333,8 @@ int lttng_event_field_value_array_append_unavailable( { LTTNG_ASSERT(array_field_val); return lttng_dynamic_pointer_array_add_pointer( - &container_of(array_field_val, - struct lttng_event_field_value_array, parent)->elems, + <tng::utils::container_of(array_field_val, + <tng_event_field_value_array::parent)->elems, NULL); } @@ -368,21 +367,17 @@ lttng_event_field_value_unsigned_int_get_value( switch (field_val->type) { case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT: - *val = container_of(field_val, - const struct lttng_event_field_value_uint, - parent)->val; + *val = lttng::utils::container_of(field_val, + <tng_event_field_value_uint::parent)->val; break; case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM: { - const struct lttng_event_field_value_enum *field_val_enum = container_of( - field_val, - const struct lttng_event_field_value_enum, - parent); - const struct lttng_event_field_value_enum_uint - *field_val_enum_uint = container_of( - field_val_enum, - const struct lttng_event_field_value_enum_uint, - parent); + const struct lttng_event_field_value_enum *field_val_enum = + lttng::utils::container_of( + field_val, <tng_event_field_value_enum::parent); + const struct lttng_event_field_value_enum_uint *field_val_enum_uint = + lttng::utils::container_of(field_val_enum, + <tng_event_field_value_enum_uint::parent); *val = field_val_enum_uint->val; break; } @@ -410,21 +405,17 @@ lttng_event_field_value_signed_int_get_value( switch (field_val->type) { case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT: - *val = container_of(field_val, - const struct lttng_event_field_value_int, - parent)->val; + *val = lttng::utils::container_of(field_val, + <tng_event_field_value_int::parent)->val; break; case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM: { - const struct lttng_event_field_value_enum *field_val_enum = container_of( + const struct lttng_event_field_value_enum *field_val_enum = lttng::utils::container_of( field_val, - const struct lttng_event_field_value_enum, - parent); - const struct lttng_event_field_value_enum_int - *field_val_enum_uint = container_of( - field_val_enum, - const struct lttng_event_field_value_enum_int, - parent); + <tng_event_field_value_enum::parent); + const struct lttng_event_field_value_enum_int *field_val_enum_uint = + lttng::utils::container_of(field_val_enum, + <tng_event_field_value_enum_int::parent); *val = field_val_enum_uint->val; break; } @@ -451,8 +442,8 @@ lttng_event_field_value_real_get_value( goto end; } - *val = container_of(field_val, - const struct lttng_event_field_value_real, parent)->val; + *val = lttng::utils::container_of(field_val, + <tng_event_field_value_real::parent)->val; status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK; end: @@ -479,9 +470,8 @@ lttng_event_field_value_enum_get_label_count( } *count = (unsigned int) lttng_dynamic_pointer_array_get_count( - &container_of(field_val, - const struct lttng_event_field_value_enum, - parent)->labels); + <tng::utils::container_of(field_val, + <tng_event_field_value_enum::parent)->labels); status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK; end: @@ -500,8 +490,8 @@ const char *lttng_event_field_value_enum_get_label_at_index( goto end; } - enum_field_val = container_of(field_val, - const struct lttng_event_field_value_enum, parent); + enum_field_val = lttng::utils::container_of(field_val, + <tng_event_field_value_enum::parent); if (index >= lttng_dynamic_pointer_array_get_count(&enum_field_val->labels)) { ret = NULL; @@ -526,8 +516,8 @@ enum lttng_event_field_value_status lttng_event_field_value_string_get_value( goto end; } - *value = container_of(field_val, - const struct lttng_event_field_value_string, parent)->val; + *value = lttng::utils::container_of(field_val, + <tng_event_field_value_string::parent)->val; status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK; end: @@ -547,9 +537,8 @@ enum lttng_event_field_value_status lttng_event_field_value_array_get_length( } *length = (unsigned int) lttng_dynamic_pointer_array_get_count( - &container_of(field_val, - const struct lttng_event_field_value_array, - parent)->elems); + <tng::utils::container_of(field_val, + <tng_event_field_value_array::parent)->elems); status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK; end: @@ -571,8 +560,8 @@ lttng_event_field_value_array_get_element_at_index( goto end; } - array_field_val = container_of(field_val, - const struct lttng_event_field_value_array, parent); + array_field_val = lttng::utils::container_of( + field_val, <tng_event_field_value_array::parent); if (index >= lttng_dynamic_pointer_array_get_count(&array_field_val->elems)) { status = LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID; diff --git a/src/common/event-rule/event-rule.cpp b/src/common/event-rule/event-rule.cpp index 8c1b81dbd..5139eed5a 100644 --- a/src/common/event-rule/event-rule.cpp +++ b/src/common/event-rule/event-rule.cpp @@ -65,7 +65,7 @@ enum lttng_domain_type lttng_event_rule_get_domain_type( static void lttng_event_rule_release(struct urcu_ref *ref) { struct lttng_event_rule *event_rule = - container_of(ref, typeof(*event_rule), ref); + lttng::utils::container_of(ref, <tng_event_rule::ref); LTTNG_ASSERT(event_rule->destroy); event_rule->destroy(event_rule); diff --git a/src/common/event-rule/jul-logging.cpp b/src/common/event-rule/jul-logging.cpp index 14fa179eb..138d9c102 100644 --- a/src/common/event-rule/jul-logging.cpp +++ b/src/common/event-rule/jul-logging.cpp @@ -32,8 +32,8 @@ static void lttng_event_rule_jul_logging_destroy(struct lttng_event_rule *rule) return; } - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); lttng_log_level_rule_destroy(jul_logging->log_level_rule); free(jul_logging->pattern); @@ -53,8 +53,8 @@ static bool lttng_event_rule_jul_logging_validate( goto end; } - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); /* Required field. */ if (!jul_logging->pattern) { @@ -86,8 +86,8 @@ static int lttng_event_rule_jul_logging_serialize( header_offset = payload->buffer.size; DBG("Serializing jul_logging event rule."); - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); pattern_len = strlen(jul_logging->pattern) + 1; @@ -141,8 +141,8 @@ static bool lttng_event_rule_jul_logging_is_equal( bool is_equal = false; struct lttng_event_rule_jul_logging *a, *b; - a = container_of(_a, struct lttng_event_rule_jul_logging, parent); - b = container_of(_b, struct lttng_event_rule_jul_logging, parent); + a = lttng::utils::container_of(_a, <tng_event_rule_jul_logging::parent); + b = lttng::utils::container_of(_b, <tng_event_rule_jul_logging::parent); /* Quick checks. */ @@ -304,8 +304,8 @@ lttng_event_rule_jul_logging_generate_filter_bytecode( LTTNG_ASSERT(rule); - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); status = lttng_event_rule_jul_logging_get_filter(rule, &filter); if (status == LTTNG_EVENT_RULE_STATUS_UNSET) { @@ -357,8 +357,8 @@ static const char *lttng_event_rule_jul_logging_get_internal_filter( struct lttng_event_rule_jul_logging *jul_logging; LTTNG_ASSERT(rule); - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); return jul_logging->internal_filter.filter; } @@ -369,8 +369,8 @@ lttng_event_rule_jul_logging_get_internal_filter_bytecode( struct lttng_event_rule_jul_logging *jul_logging; LTTNG_ASSERT(rule); - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); return jul_logging->internal_filter.bytecode; } @@ -389,7 +389,7 @@ static unsigned long lttng_event_rule_jul_logging_hash( { unsigned long hash; struct lttng_event_rule_jul_logging *tp_rule = - container_of(rule, typeof(*tp_rule), parent); + lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent); hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_JUL_LOGGING, lttng_ht_seed); @@ -418,8 +418,8 @@ static struct lttng_event *lttng_event_rule_jul_logging_generate_lttng_event( enum lttng_event_rule_status status; const struct lttng_log_level_rule *log_level_rule; - jul_logging = container_of( - rule, const struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); local_event = zmalloc(); if (!local_event) { @@ -753,8 +753,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_set_name_pattern( goto end; } - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); pattern_copy = strdup(pattern); if (!pattern_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -783,8 +783,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_get_name_pattern( goto end; } - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); if (!jul_logging->pattern) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -808,8 +808,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_set_filter( goto end; } - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); expression_copy = strdup(expression); if (!expression_copy) { PERROR("Failed to copy filter expression"); @@ -838,8 +838,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_get_filter( goto end; } - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); if (!jul_logging->filter_expression) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -873,8 +873,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_set_log_level_rule( goto end; } - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); if (!log_level_rule_valid(log_level_rule)) { status = LTTNG_EVENT_RULE_STATUS_INVALID; @@ -910,8 +910,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_get_log_level_rule( goto end; } - jul_logging = container_of( - rule, struct lttng_event_rule_jul_logging, parent); + jul_logging = lttng::utils::container_of( + rule, <tng_event_rule_jul_logging::parent); if (jul_logging->log_level_rule == NULL) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; diff --git a/src/common/event-rule/kernel-kprobe.cpp b/src/common/event-rule/kernel-kprobe.cpp index bad894e35..239373aa9 100644 --- a/src/common/event-rule/kernel-kprobe.cpp +++ b/src/common/event-rule/kernel-kprobe.cpp @@ -34,7 +34,7 @@ static void lttng_event_rule_kernel_kprobe_destroy(struct lttng_event_rule *rule { struct lttng_event_rule_kernel_kprobe *kprobe; - kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent); + kprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent); lttng_kernel_probe_location_destroy(kprobe->location); free(kprobe->name); @@ -51,7 +51,7 @@ static bool lttng_event_rule_kernel_kprobe_validate( goto end; } - kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent); + kprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent); /* Required field. */ if (!kprobe->name) { @@ -88,7 +88,7 @@ static int lttng_event_rule_kernel_kprobe_serialize( header_offset = payload->buffer.size; DBG("Serializing kprobe event rule."); - kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent); + kprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent); name_len = strlen(kprobe->name) + 1; kprobe_comm.name_len = name_len; @@ -128,8 +128,8 @@ static bool lttng_event_rule_kernel_kprobe_is_equal(const struct lttng_event_rul bool is_equal = false; struct lttng_event_rule_kernel_kprobe *a, *b; - a = container_of(_a, struct lttng_event_rule_kernel_kprobe, parent); - b = container_of(_b, struct lttng_event_rule_kernel_kprobe, parent); + a = lttng::utils::container_of(_a, <tng_event_rule_kernel_kprobe::parent); + b = lttng::utils::container_of(_b, <tng_event_rule_kernel_kprobe::parent); /* Quick checks */ if (!!a->name != !!b->name) { @@ -188,7 +188,7 @@ lttng_event_rule_kernel_kprobe_hash( { unsigned long hash; struct lttng_event_rule_kernel_kprobe *krule = - container_of(rule, typeof(*krule), parent); + lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent); hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE, lttng_ht_seed); @@ -434,7 +434,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_get_location( goto end; } - kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent); + kprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent); *location = kprobe->location; if (!*location) { @@ -459,7 +459,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_set_event_name( goto end; } - kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent); + kprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent); name_copy = strdup(name); if (!name_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -485,7 +485,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_get_event_name( goto end; } - kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent); + kprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent); if (!kprobe->name) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; diff --git a/src/common/event-rule/kernel-syscall.cpp b/src/common/event-rule/kernel-syscall.cpp index d006eaa05..633c4698b 100644 --- a/src/common/event-rule/kernel-syscall.cpp +++ b/src/common/event-rule/kernel-syscall.cpp @@ -29,7 +29,7 @@ static void lttng_event_rule_kernel_syscall_destroy(struct lttng_event_rule *rul return; } - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); free(syscall->pattern); free(syscall->filter_expression); @@ -48,7 +48,7 @@ static bool lttng_event_rule_kernel_syscall_validate( goto end; } - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); /* Required field. */ if (!syscall->pattern) { @@ -76,7 +76,7 @@ static int lttng_event_rule_kernel_syscall_serialize( } DBG("Serializing syscall event rule"); - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); pattern_len = strlen(syscall->pattern) + 1; @@ -114,8 +114,8 @@ static bool lttng_event_rule_kernel_syscall_is_equal(const struct lttng_event_ru bool is_equal = false; struct lttng_event_rule_kernel_syscall *a, *b; - a = container_of(_a, struct lttng_event_rule_kernel_syscall, parent); - b = container_of(_b, struct lttng_event_rule_kernel_syscall, parent); + a = lttng::utils::container_of(_a, <tng_event_rule_kernel_syscall::parent); + b = lttng::utils::container_of(_b, <tng_event_rule_kernel_syscall::parent); if (!!a->filter_expression != !!b->filter_expression) { goto end; @@ -154,7 +154,7 @@ static enum lttng_error_code lttng_event_rule_kernel_syscall_generate_filter_byt LTTNG_ASSERT(rule); - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); /* Generate the filter bytecode. */ status = lttng_event_rule_kernel_syscall_get_filter(rule, &filter); @@ -202,7 +202,7 @@ static const char *lttng_event_rule_kernel_syscall_get_internal_filter( struct lttng_event_rule_kernel_syscall *syscall; LTTNG_ASSERT(rule); - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); return syscall->internal_filter.filter; } @@ -214,7 +214,7 @@ lttng_event_rule_kernel_syscall_get_internal_filter_bytecode( struct lttng_event_rule_kernel_syscall *syscall; LTTNG_ASSERT(rule); - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); return syscall->internal_filter.bytecode; } @@ -235,7 +235,7 @@ lttng_event_rule_kernel_syscall_hash( { unsigned long hash; struct lttng_event_rule_kernel_syscall *syscall_rule = - container_of(rule, typeof(*syscall_rule), parent); + lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL, lttng_ht_seed); @@ -515,7 +515,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_syscall_set_name_pattern( goto end; } - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); pattern_copy = strdup(pattern); if (!pattern_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -543,7 +543,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_syscall_get_name_pattern( goto end; } - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); if (!syscall->pattern) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -569,7 +569,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_syscall_set_filter( goto end; } - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); expression_copy = strdup(expression); if (!expression_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -597,7 +597,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_syscall_get_filter( goto end; } - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); if (!syscall->filter_expression) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -619,7 +619,7 @@ lttng_event_rule_kernel_syscall_get_emission_site( goto end; } - syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent); + syscall = lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent); emission_site = syscall->emission_site; end: diff --git a/src/common/event-rule/kernel-tracepoint.cpp b/src/common/event-rule/kernel-tracepoint.cpp index 0bedfb501..939b83fbb 100644 --- a/src/common/event-rule/kernel-tracepoint.cpp +++ b/src/common/event-rule/kernel-tracepoint.cpp @@ -31,8 +31,8 @@ static void lttng_event_rule_kernel_tracepoint_destroy(struct lttng_event_rule * return; } - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); free(tracepoint->pattern); free(tracepoint->filter_expression); @@ -51,8 +51,8 @@ static bool lttng_event_rule_kernel_tracepoint_validate( goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); /* Required field. */ if (!tracepoint->pattern) { @@ -80,8 +80,8 @@ static int lttng_event_rule_kernel_tracepoint_serialize( } DBG("Serializing kernel tracepoint event rule."); - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); pattern_len = strlen(tracepoint->pattern) + 1; @@ -124,8 +124,8 @@ static bool lttng_event_rule_kernel_tracepoint_is_equal( bool is_equal = false; struct lttng_event_rule_kernel_tracepoint *a, *b; - a = container_of(_a, struct lttng_event_rule_kernel_tracepoint, parent); - b = container_of(_b, struct lttng_event_rule_kernel_tracepoint, parent); + a = lttng::utils::container_of(_a, <tng_event_rule_kernel_tracepoint::parent); + b = lttng::utils::container_of(_b, <tng_event_rule_kernel_tracepoint::parent); if (!!a->filter_expression != !!b->filter_expression) { goto end; @@ -166,8 +166,8 @@ lttng_event_rule_kernel_tracepoint_generate_filter_bytecode( LTTNG_ASSERT(rule); - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); status = lttng_event_rule_kernel_tracepoint_get_filter(rule, &filter); if (status == LTTNG_EVENT_RULE_STATUS_UNSET) { @@ -221,8 +221,8 @@ static const char *lttng_event_rule_kernel_tracepoint_get_internal_filter( struct lttng_event_rule_kernel_tracepoint *tracepoint; LTTNG_ASSERT(rule); - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); return tracepoint->internal_filter.filter; } @@ -233,8 +233,8 @@ lttng_event_rule_kernel_tracepoint_get_internal_filter_bytecode( struct lttng_event_rule_kernel_tracepoint *tracepoint; LTTNG_ASSERT(rule); - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); return tracepoint->internal_filter.bytecode; } @@ -252,8 +252,8 @@ static unsigned long lttng_event_rule_kernel_tracepoint_hash( const struct lttng_event_rule *rule) { unsigned long hash; - struct lttng_event_rule_kernel_tracepoint *tp_rule = - container_of(rule, typeof(*tp_rule), parent); + struct lttng_event_rule_kernel_tracepoint *tp_rule = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT, lttng_ht_seed); @@ -488,8 +488,8 @@ enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_set_name_pattern goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); pattern_copy = strdup(pattern); if (!pattern_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -518,8 +518,8 @@ enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_get_name_pattern goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); if (!tracepoint->pattern) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -543,8 +543,8 @@ enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_set_filter( goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); expression_copy = strdup(expression); if (!expression_copy) { PERROR("Failed to copy filter expression"); @@ -573,8 +573,8 @@ enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_get_filter( goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_kernel_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_kernel_tracepoint::parent); if (!tracepoint->filter_expression) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; diff --git a/src/common/event-rule/kernel-uprobe.cpp b/src/common/event-rule/kernel-uprobe.cpp index 4e611aca2..cee5b2e65 100644 --- a/src/common/event-rule/kernel-uprobe.cpp +++ b/src/common/event-rule/kernel-uprobe.cpp @@ -25,7 +25,7 @@ static void lttng_event_rule_kernel_uprobe_destroy(struct lttng_event_rule *rule { struct lttng_event_rule_kernel_uprobe *uprobe; - uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent); + uprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent); lttng_userspace_probe_location_destroy(uprobe->location); free(uprobe->name); @@ -42,7 +42,7 @@ static bool lttng_event_rule_kernel_uprobe_validate( goto end; } - uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent); + uprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent); /* Required field. */ if (!uprobe->name) { @@ -78,7 +78,7 @@ static int lttng_event_rule_kernel_uprobe_serialize( header_offset = payload->buffer.size; DBG("Serializing uprobe event rule."); - uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent); + uprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent); name_len = strlen(uprobe->name) + 1; @@ -122,8 +122,8 @@ static bool lttng_event_rule_kernel_uprobe_is_equal(const struct lttng_event_rul bool is_equal = false; struct lttng_event_rule_kernel_uprobe *a, *b; - a = container_of(_a, struct lttng_event_rule_kernel_uprobe, parent); - b = container_of(_b, struct lttng_event_rule_kernel_uprobe, parent); + a = lttng::utils::container_of(_a, <tng_event_rule_kernel_uprobe::parent); + b = lttng::utils::container_of(_b, <tng_event_rule_kernel_uprobe::parent); /* uprobe is invalid if this is not true. */ LTTNG_ASSERT(a->name); @@ -179,7 +179,7 @@ lttng_event_rule_kernel_uprobe_hash( { unsigned long hash; struct lttng_event_rule_kernel_uprobe *urule = - container_of(rule, typeof(*urule), parent); + lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent); hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE, lttng_ht_seed); @@ -438,7 +438,7 @@ lttng_event_rule_kernel_uprobe_get_location_mutable( struct lttng_event_rule_kernel_uprobe *uprobe; LTTNG_ASSERT(rule); - uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent); + uprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent); return uprobe->location; } @@ -456,7 +456,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_set_event_name( goto end; } - uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent); + uprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent); name_copy = strdup(name); if (!name_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -484,7 +484,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_get_event_name( goto end; } - uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent); + uprobe = lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent); if (!uprobe->name) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; diff --git a/src/common/event-rule/log4j-logging.cpp b/src/common/event-rule/log4j-logging.cpp index b7386c0ba..11e775c3f 100644 --- a/src/common/event-rule/log4j-logging.cpp +++ b/src/common/event-rule/log4j-logging.cpp @@ -32,8 +32,8 @@ static void lttng_event_rule_log4j_logging_destroy(struct lttng_event_rule *rule return; } - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); lttng_log_level_rule_destroy(log4j_logging->log_level_rule); free(log4j_logging->pattern); @@ -53,8 +53,8 @@ static bool lttng_event_rule_log4j_logging_validate( goto end; } - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); /* Required field. */ if (!log4j_logging->pattern) { @@ -86,8 +86,8 @@ static int lttng_event_rule_log4j_logging_serialize( header_offset = payload->buffer.size; DBG("Serializing log4j_logging event rule."); - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); pattern_len = strlen(log4j_logging->pattern) + 1; @@ -141,8 +141,8 @@ static bool lttng_event_rule_log4j_logging_is_equal( bool is_equal = false; struct lttng_event_rule_log4j_logging *a, *b; - a = container_of(_a, struct lttng_event_rule_log4j_logging, parent); - b = container_of(_b, struct lttng_event_rule_log4j_logging, parent); + a = lttng::utils::container_of(_a, <tng_event_rule_log4j_logging::parent); + b = lttng::utils::container_of(_b, <tng_event_rule_log4j_logging::parent); /* Quick checks. */ @@ -304,8 +304,8 @@ lttng_event_rule_log4j_logging_generate_filter_bytecode( LTTNG_ASSERT(rule); - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); status = lttng_event_rule_log4j_logging_get_filter(rule, &filter); if (status == LTTNG_EVENT_RULE_STATUS_UNSET) { @@ -357,8 +357,8 @@ static const char *lttng_event_rule_log4j_logging_get_internal_filter( struct lttng_event_rule_log4j_logging *log4j_logging; LTTNG_ASSERT(rule); - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); return log4j_logging->internal_filter.filter; } @@ -369,8 +369,8 @@ lttng_event_rule_log4j_logging_get_internal_filter_bytecode( struct lttng_event_rule_log4j_logging *log4j_logging; LTTNG_ASSERT(rule); - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); return log4j_logging->internal_filter.bytecode; } @@ -389,7 +389,7 @@ static unsigned long lttng_event_rule_log4j_logging_hash( { unsigned long hash; struct lttng_event_rule_log4j_logging *tp_rule = - container_of(rule, typeof(*tp_rule), parent); + lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent); hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING, lttng_ht_seed); @@ -418,8 +418,8 @@ static struct lttng_event *lttng_event_rule_log4j_logging_generate_lttng_event( enum lttng_event_rule_status status; const struct lttng_log_level_rule *log_level_rule; - log4j_logging = container_of( - rule, const struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); local_event = zmalloc(); if (!local_event) { @@ -752,8 +752,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_name_pattern( goto end; } - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); pattern_copy = strdup(pattern); if (!pattern_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -782,8 +782,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_name_pattern( goto end; } - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); if (!log4j_logging->pattern) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -807,8 +807,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_filter( goto end; } - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); expression_copy = strdup(expression); if (!expression_copy) { PERROR("Failed to copy filter expression"); @@ -837,8 +837,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_filter( goto end; } - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); if (!log4j_logging->filter_expression) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -872,8 +872,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_log_level_rule( goto end; } - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); if (!log_level_rule_valid(log_level_rule)) { status = LTTNG_EVENT_RULE_STATUS_INVALID; @@ -909,8 +909,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_log_level_rule( goto end; } - log4j_logging = container_of( - rule, struct lttng_event_rule_log4j_logging, parent); + log4j_logging = lttng::utils::container_of( + rule, <tng_event_rule_log4j_logging::parent); if (log4j_logging->log_level_rule == NULL) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; diff --git a/src/common/event-rule/python-logging.cpp b/src/common/event-rule/python-logging.cpp index 25e967702..47b1e0366 100644 --- a/src/common/event-rule/python-logging.cpp +++ b/src/common/event-rule/python-logging.cpp @@ -32,8 +32,8 @@ static void lttng_event_rule_python_logging_destroy(struct lttng_event_rule *rul return; } - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); lttng_log_level_rule_destroy(python_logging->log_level_rule); free(python_logging->pattern); @@ -53,8 +53,8 @@ static bool lttng_event_rule_python_logging_validate( goto end; } - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); /* Required field. */ if (!python_logging->pattern) { @@ -86,8 +86,8 @@ static int lttng_event_rule_python_logging_serialize( header_offset = payload->buffer.size; DBG("Serializing python_logging event rule."); - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); pattern_len = strlen(python_logging->pattern) + 1; @@ -141,8 +141,8 @@ static bool lttng_event_rule_python_logging_is_equal( bool is_equal = false; struct lttng_event_rule_python_logging *a, *b; - a = container_of(_a, struct lttng_event_rule_python_logging, parent); - b = container_of(_b, struct lttng_event_rule_python_logging, parent); + a = lttng::utils::container_of(_a, <tng_event_rule_python_logging::parent); + b = lttng::utils::container_of(_b, <tng_event_rule_python_logging::parent); /* Quick checks. */ @@ -304,8 +304,8 @@ lttng_event_rule_python_logging_generate_filter_bytecode( LTTNG_ASSERT(rule); - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); status = lttng_event_rule_python_logging_get_filter(rule, &filter); if (status == LTTNG_EVENT_RULE_STATUS_UNSET) { @@ -357,8 +357,8 @@ static const char *lttng_event_rule_python_logging_get_internal_filter( struct lttng_event_rule_python_logging *python_logging; LTTNG_ASSERT(rule); - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); return python_logging->internal_filter.filter; } @@ -369,8 +369,8 @@ lttng_event_rule_python_logging_get_internal_filter_bytecode( struct lttng_event_rule_python_logging *python_logging; LTTNG_ASSERT(rule); - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); return python_logging->internal_filter.bytecode; } @@ -389,7 +389,7 @@ static unsigned long lttng_event_rule_python_logging_hash( { unsigned long hash; struct lttng_event_rule_python_logging *tp_rule = - container_of(rule, typeof(*tp_rule), parent); + lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent); hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING, lttng_ht_seed); @@ -418,8 +418,8 @@ static struct lttng_event *lttng_event_rule_python_logging_generate_lttng_event( enum lttng_event_rule_status status; const struct lttng_log_level_rule *log_level_rule; - python_logging = container_of( - rule, const struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); local_event = zmalloc(); if (!local_event) { @@ -752,8 +752,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_set_name_pattern( goto end; } - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); pattern_copy = strdup(pattern); if (!pattern_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -782,8 +782,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_get_name_pattern( goto end; } - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); if (!python_logging->pattern) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -807,8 +807,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_set_filter( goto end; } - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); expression_copy = strdup(expression); if (!expression_copy) { PERROR("Failed to copy filter expression"); @@ -829,7 +829,7 @@ end: enum lttng_event_rule_status lttng_event_rule_python_logging_get_filter( const struct lttng_event_rule *rule, const char **expression) { - struct lttng_event_rule_python_logging *python_logging; + const struct lttng_event_rule_python_logging *python_logging; enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK; if (!rule || !IS_PYTHON_LOGGING_EVENT_RULE(rule) || !expression) { @@ -837,8 +837,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_get_filter( goto end; } - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); if (!python_logging->filter_expression) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -874,8 +874,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_set_log_level_rule( goto end; } - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); if (!log_level_rule_valid(log_level_rule)) { status = LTTNG_EVENT_RULE_STATUS_INVALID; @@ -911,8 +911,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_get_log_level_rule( goto end; } - python_logging = container_of( - rule, struct lttng_event_rule_python_logging, parent); + python_logging = lttng::utils::container_of( + rule, <tng_event_rule_python_logging::parent); if (python_logging->log_level_rule == NULL) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; diff --git a/src/common/event-rule/user-tracepoint.cpp b/src/common/event-rule/user-tracepoint.cpp index 48040fc59..318bc21c8 100644 --- a/src/common/event-rule/user-tracepoint.cpp +++ b/src/common/event-rule/user-tracepoint.cpp @@ -32,8 +32,8 @@ static void lttng_event_rule_user_tracepoint_destroy(struct lttng_event_rule *ru return; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); lttng_log_level_rule_destroy(tracepoint->log_level_rule); lttng_dynamic_pointer_array_reset(&tracepoint->exclusions); @@ -54,8 +54,8 @@ static bool lttng_event_rule_user_tracepoint_validate( goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); /* Required field. */ if (!tracepoint->pattern) { @@ -90,8 +90,8 @@ static int lttng_event_rule_user_tracepoint_serialize( header_offset = payload->buffer.size; DBG("Serializing user tracepoint event rule."); - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(rule, &exclusion_count); LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK); @@ -197,8 +197,8 @@ static bool lttng_event_rule_user_tracepoint_is_equal( unsigned int count_a, count_b; enum lttng_event_rule_status status; - a = container_of(_a, struct lttng_event_rule_user_tracepoint, parent); - b = container_of(_b, struct lttng_event_rule_user_tracepoint, parent); + a = lttng::utils::container_of(_a, <tng_event_rule_user_tracepoint::parent); + b = lttng::utils::container_of(_b, <tng_event_rule_user_tracepoint::parent); status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(_a, &count_a); LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK); @@ -268,8 +268,8 @@ lttng_event_rule_user_tracepoint_generate_filter_bytecode( LTTNG_ASSERT(rule); - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); status = lttng_event_rule_user_tracepoint_get_filter(rule, &filter); if (status == LTTNG_EVENT_RULE_STATUS_UNSET) { @@ -323,8 +323,8 @@ static const char *lttng_event_rule_user_tracepoint_get_internal_filter( struct lttng_event_rule_user_tracepoint *tracepoint; LTTNG_ASSERT(rule); - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); return tracepoint->internal_filter.filter; } @@ -335,8 +335,8 @@ lttng_event_rule_user_tracepoint_get_internal_filter_bytecode( struct lttng_event_rule_user_tracepoint *tracepoint; LTTNG_ASSERT(rule); - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); return tracepoint->internal_filter.bytecode; } @@ -410,7 +410,7 @@ static unsigned long lttng_event_rule_user_tracepoint_hash( unsigned int i, exclusion_count; enum lttng_event_rule_status status; struct lttng_event_rule_user_tracepoint *tp_rule = - container_of(rule, typeof(*tp_rule), parent); + lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent); hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT, lttng_ht_seed); @@ -796,8 +796,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_name_pattern( goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); pattern_copy = strdup(pattern); if (!pattern_copy) { status = LTTNG_EVENT_RULE_STATUS_ERROR; @@ -826,8 +826,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern( goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); if (!tracepoint->pattern) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -851,8 +851,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_filter( goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); expression_copy = strdup(expression); if (!expression_copy) { PERROR("Failed to copy filter expression"); @@ -881,8 +881,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_filter( goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); if (!tracepoint->filter_expression) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -941,8 +941,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_log_level_rule goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); if (!log_level_rule_valid(log_level_rule)) { status = LTTNG_EVENT_RULE_STATUS_INVALID; @@ -978,8 +978,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_log_level_rule goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); if (tracepoint->log_level_rule == NULL) { status = LTTNG_EVENT_RULE_STATUS_UNSET; goto end; @@ -1005,8 +1005,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_add_name_pattern_e goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); if (strlen(exclusion) >= LTTNG_SYMBOL_NAME_LEN) { status = LTTNG_EVENT_RULE_STATUS_INVALID; @@ -1043,8 +1043,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern_e goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); *count = lttng_dynamic_pointer_array_get_count(&tracepoint->exclusions); end: return status; @@ -1064,8 +1064,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern_e goto end; } - tracepoint = container_of( - rule, struct lttng_event_rule_user_tracepoint, parent); + tracepoint = lttng::utils::container_of( + rule, <tng_event_rule_user_tracepoint::parent); if (lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(rule, &count) != LTTNG_EVENT_RULE_STATUS_OK) { goto end; diff --git a/src/common/fd-handle.cpp b/src/common/fd-handle.cpp index 579757782..8a0d95243 100644 --- a/src/common/fd-handle.cpp +++ b/src/common/fd-handle.cpp @@ -19,7 +19,7 @@ struct fd_handle { static void fd_handle_release(struct urcu_ref *ref) { int ret; - struct fd_handle *handle = container_of(ref, struct fd_handle, ref); + struct fd_handle *handle = lttng::utils::container_of(ref, &fd_handle::ref); LTTNG_ASSERT(handle->fd >= 0); ret = close(handle->fd); diff --git a/src/common/fd-tracker/fd-tracker.cpp b/src/common/fd-tracker/fd-tracker.cpp index e1f9b14fb..0c24eab5e 100644 --- a/src/common/fd-tracker/fd-tracker.cpp +++ b/src/common/fd-tracker/fd-tracker.cpp @@ -163,8 +163,8 @@ static int fd_tracker_restore_handle( /* Match function of the tracker's unsuspendable_fds hash table. */ static int match_fd(struct cds_lfht_node *node, const void *key) { - struct unsuspendable_fd *entry = caa_container_of( - node, struct unsuspendable_fd, tracker_node); + struct unsuspendable_fd *entry = lttng::utils::container_of( + node, &unsuspendable_fd::tracker_node); return hash_match_key_ulong( (void *) (unsigned long) entry->fd, (void *) key); @@ -757,8 +757,8 @@ int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker, ret = -EINVAL; goto end_unlock; } - entry = caa_container_of( - node, struct unsuspendable_fd, tracker_node); + entry = lttng::utils::container_of( + node, &unsuspendable_fd::tracker_node); cds_lfht_del(tracker->unsuspendable_fds, node); unsuspendable_fd_destroy(entry); @@ -825,7 +825,7 @@ static int fs_handle_tracked_get_fd(struct fs_handle *_handle) { int ret; struct fs_handle_tracked *handle = - container_of(_handle, struct fs_handle_tracked, parent); + lttng::utils::container_of(_handle, &fs_handle_tracked::parent); /* * TODO This should be optimized as it is a fairly hot path. @@ -866,7 +866,7 @@ end: static void fs_handle_tracked_put_fd(struct fs_handle *_handle) { struct fs_handle_tracked *handle = - container_of(_handle, struct fs_handle_tracked, parent); + lttng::utils::container_of(_handle, &fs_handle_tracked::parent); pthread_mutex_lock(&handle->lock); handle->in_use = false; @@ -877,7 +877,7 @@ static int fs_handle_tracked_unlink(struct fs_handle *_handle) { int ret; struct fs_handle_tracked *handle = - container_of(_handle, struct fs_handle_tracked, parent); + lttng::utils::container_of(_handle, &fs_handle_tracked::parent); pthread_mutex_lock(&handle->tracker->lock); pthread_mutex_lock(&handle->lock); @@ -892,7 +892,7 @@ static int fs_handle_tracked_close(struct fs_handle *_handle) int ret = 0; const char *path = NULL; struct fs_handle_tracked *handle = - container_of(_handle, struct fs_handle_tracked, parent); + lttng::utils::container_of(_handle, &fs_handle_tracked::parent); struct lttng_directory_handle *inode_directory_handle = NULL; if (!handle) { diff --git a/src/common/fd-tracker/inode.cpp b/src/common/fd-tracker/inode.cpp index 95a0f2742..c00f9d81f 100644 --- a/src/common/fd-tracker/inode.cpp +++ b/src/common/fd-tracker/inode.cpp @@ -85,8 +85,8 @@ static unsigned long lttng_inode_id_hash(const struct inode_id *id) static int lttng_inode_match(struct cds_lfht_node *node, const void *key) { const struct inode_id *id = (inode_id *) key; - const struct lttng_inode *inode = caa_container_of( - node, struct lttng_inode, registry_node); + const struct lttng_inode *inode = lttng::utils::container_of( + node, <tng_inode::registry_node); return inode->id.device == id->device && inode->id.inode == id->inode; } @@ -94,7 +94,7 @@ static int lttng_inode_match(struct cds_lfht_node *node, const void *key) static void lttng_inode_free(struct rcu_head *head) { struct lttng_inode *inode = - caa_container_of(head, struct lttng_inode, rcu_head); + lttng::utils::container_of(head, <tng_inode::rcu_head); free(inode); } @@ -243,7 +243,7 @@ static void lttng_inode_destroy(struct lttng_inode *inode) static void lttng_inode_release(struct urcu_ref *ref) { - lttng_inode_destroy(caa_container_of(ref, struct lttng_inode, ref)); + lttng_inode_destroy(lttng::utils::container_of(ref, <tng_inode::ref)); } static void lttng_inode_get(struct lttng_inode *inode) @@ -526,8 +526,8 @@ struct lttng_inode *lttng_inode_registry_get_inode( lttng_inode_match, &id, &iter); node = cds_lfht_iter_get_node(&iter); if (node) { - inode = caa_container_of( - node, struct lttng_inode, registry_node); + inode = lttng::utils::container_of( + node, <tng_inode::registry_node); lttng_inode_get(inode); goto end_unlock; } diff --git a/src/common/hashtable/hashtable.cpp b/src/common/hashtable/hashtable.cpp index 1b40f91f1..3aa3d79d4 100644 --- a/src/common/hashtable/hashtable.cpp +++ b/src/common/hashtable/hashtable.cpp @@ -36,7 +36,7 @@ static unsigned long max_hash_buckets_size = 0; static int match_str(struct cds_lfht_node *node, const void *key) { struct lttng_ht_node_str *match_node = - caa_container_of(node, struct lttng_ht_node_str, node); + lttng::utils::container_of(node, <tng_ht_node_str::node); return hash_match_key_str(match_node->key, (void *) key); } @@ -47,7 +47,7 @@ static int match_str(struct cds_lfht_node *node, const void *key) static int match_ulong(struct cds_lfht_node *node, const void *key) { struct lttng_ht_node_ulong *match_node = - caa_container_of(node, struct lttng_ht_node_ulong, node); + lttng::utils::container_of(node, <tng_ht_node_ulong::node); return hash_match_key_ulong((void *) match_node->key, (void *) key); } @@ -58,7 +58,7 @@ static int match_ulong(struct cds_lfht_node *node, const void *key) static int match_u64(struct cds_lfht_node *node, const void *key) { struct lttng_ht_node_u64 *match_node = - caa_container_of(node, struct lttng_ht_node_u64, node); + lttng::utils::container_of(node, <tng_ht_node_u64::node); return hash_match_key_u64(&match_node->key, (void *) key); } @@ -69,7 +69,7 @@ static int match_u64(struct cds_lfht_node *node, const void *key) static int match_two_u64(struct cds_lfht_node *node, const void *key) { struct lttng_ht_node_two_u64 *match_node = - caa_container_of(node, struct lttng_ht_node_two_u64, node); + lttng::utils::container_of(node, <tng_ht_node_two_u64::node); return hash_match_key_two_u64((void *) &match_node->key, (void *) key); } @@ -413,7 +413,7 @@ struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(struct lttng_ht *ht, if (!node_ptr) { return NULL; } else { - return caa_container_of(node_ptr, struct lttng_ht_node_ulong, node); + return lttng::utils::container_of(node_ptr, <tng_ht_node_ulong::node); } LTTNG_ASSERT(node_ptr == &node->node); } @@ -438,7 +438,7 @@ struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(struct lttng_ht *ht, if (!node_ptr) { return NULL; } else { - return caa_container_of(node_ptr, struct lttng_ht_node_u64, node); + return lttng::utils::container_of(node_ptr, <tng_ht_node_u64::node); } LTTNG_ASSERT(node_ptr == &node->node); } @@ -517,7 +517,7 @@ struct lttng_ht_node_str *lttng_ht_iter_get_node_str( if (!node) { return NULL; } - return caa_container_of(node, struct lttng_ht_node_str, node); + return lttng::utils::container_of(node, <tng_ht_node_str::node); } /* @@ -533,7 +533,7 @@ struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong( if (!node) { return NULL; } - return caa_container_of(node, struct lttng_ht_node_ulong, node); + return lttng::utils::container_of(node, <tng_ht_node_ulong::node); } /* @@ -549,7 +549,7 @@ struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64( if (!node) { return NULL; } - return caa_container_of(node, struct lttng_ht_node_u64, node); + return lttng::utils::container_of(node, <tng_ht_node_u64::node); } /* @@ -565,5 +565,5 @@ struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64( if (!node) { return NULL; } - return caa_container_of(node, struct lttng_ht_node_two_u64, node); + return lttng::utils::container_of(node, <tng_ht_node_two_u64::node); } diff --git a/src/common/kernel-probe.cpp b/src/common/kernel-probe.cpp index 172527f9a..b01b44b96 100644 --- a/src/common/kernel-probe.cpp +++ b/src/common/kernel-probe.cpp @@ -82,9 +82,8 @@ void lttng_kernel_probe_location_symbol_destroy( LTTNG_ASSERT(location); - location_symbol = container_of(location, - struct lttng_kernel_probe_location_symbol, - parent); + location_symbol = lttng::utils::container_of(location, + <tng_kernel_probe_location_symbol::parent); LTTNG_ASSERT(location_symbol); @@ -195,8 +194,8 @@ lttng_kernel_probe_location_address_get_address( goto end; } - address_location = container_of(location, - struct lttng_kernel_probe_location_address, parent); + address_location = lttng::utils::container_of(location, + <tng_kernel_probe_location_address::parent); *offset = address_location->address; end: return ret; @@ -214,8 +213,8 @@ const char *lttng_kernel_probe_location_symbol_get_name( goto end; } - symbol_location = container_of(location, - struct lttng_kernel_probe_location_symbol, parent); + symbol_location = lttng::utils::container_of(location, + <tng_kernel_probe_location_symbol::parent); ret = symbol_location->symbol_name; end: return ret; @@ -239,8 +238,8 @@ lttng_kernel_probe_location_symbol_get_offset( goto end; } - symbol_location = container_of(location, - struct lttng_kernel_probe_location_symbol, parent); + symbol_location = lttng::utils::container_of(location, + <tng_kernel_probe_location_symbol::parent); *offset = symbol_location->offset; end: return ret; @@ -267,8 +266,8 @@ int lttng_kernel_probe_location_symbol_serialize( LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET); original_payload_size = payload->buffer.size; - location_symbol = container_of(location, - struct lttng_kernel_probe_location_symbol, parent); + location_symbol = lttng::utils::container_of(location, + <tng_kernel_probe_location_symbol::parent); if (!location_symbol->symbol_name) { ret = -LTTNG_ERR_INVALID; @@ -319,9 +318,8 @@ int lttng_kernel_probe_location_address_serialize( LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS); original_payload_size = payload->buffer.size; - location_address = container_of(location, - struct lttng_kernel_probe_location_address, - parent); + location_address = lttng::utils::container_of(location, + <tng_kernel_probe_location_address::parent); location_address_comm.address = location_address->address; @@ -518,9 +516,8 @@ unsigned long lttng_kernel_probe_location_address_hash( unsigned long hash = hash_key_ulong( (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS, lttng_ht_seed); - struct lttng_kernel_probe_location_address *address_location = - container_of(location, typeof(*address_location), - parent); + struct lttng_kernel_probe_location_address *address_location = lttng::utils::container_of( + location, <tng_kernel_probe_location_address::parent); hash ^= hash_key_u64(&address_location->address, lttng_ht_seed); @@ -535,10 +532,8 @@ bool lttng_kernel_probe_location_address_is_equal( bool is_equal = false; struct lttng_kernel_probe_location_address *a, *b; - a = container_of(_a, struct lttng_kernel_probe_location_address, - parent); - b = container_of(_b, struct lttng_kernel_probe_location_address, - parent); + a = lttng::utils::container_of(_a, <tng_kernel_probe_location_address::parent); + b = lttng::utils::container_of(_b, <tng_kernel_probe_location_address::parent); if (a->address != b->address) { goto end; @@ -555,11 +550,9 @@ unsigned long lttng_kernel_probe_location_symbol_hash( const struct lttng_kernel_probe_location *location) { unsigned long hash = hash_key_ulong( - (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET, - lttng_ht_seed); - struct lttng_kernel_probe_location_symbol *symbol_location = - container_of(location, typeof(*symbol_location), - parent); + (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET, lttng_ht_seed); + struct lttng_kernel_probe_location_symbol *symbol_location = lttng::utils::container_of( + location, <tng_kernel_probe_location_symbol::parent); hash ^= hash_key_str(symbol_location->symbol_name, lttng_ht_seed); hash ^= hash_key_u64(&symbol_location->offset, lttng_ht_seed); @@ -575,10 +568,10 @@ bool lttng_kernel_probe_location_symbol_is_equal( bool is_equal = false; struct lttng_kernel_probe_location_symbol *a, *b; - a = container_of(_a, struct lttng_kernel_probe_location_symbol, - parent); - b = container_of(_b, struct lttng_kernel_probe_location_symbol, - parent); + a = lttng::utils::container_of(_a, + <tng_kernel_probe_location_symbol::parent); + b = lttng::utils::container_of(_b, + <tng_kernel_probe_location_symbol::parent); LTTNG_ASSERT(a->symbol_name); LTTNG_ASSERT(b->symbol_name); @@ -625,15 +618,12 @@ lttng_kernel_probe_location_symbol_copy( const struct lttng_kernel_probe_location *location) { struct lttng_kernel_probe_location *new_location = NULL; - struct lttng_kernel_probe_location_symbol *symbol_location; enum lttng_kernel_probe_location_status status; const char *symbol_name = NULL; uint64_t offset; LTTNG_ASSERT(location); LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET); - symbol_location = container_of( - location, typeof(*symbol_location), parent); /* Get probe location offset */ status = lttng_kernel_probe_location_symbol_get_offset(location, &offset); @@ -664,17 +654,13 @@ lttng_kernel_probe_location_address_copy( const struct lttng_kernel_probe_location *location) { struct lttng_kernel_probe_location *new_location = NULL; - struct lttng_kernel_probe_location_address *address_location; enum lttng_kernel_probe_location_status status; uint64_t address; LTTNG_ASSERT(location); LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS); - address_location = container_of( - location, typeof(*address_location), parent); - - /* Get probe location fields */ + /* Get probe location fields */ status = lttng_kernel_probe_location_address_get_address(location, &address); if (status != LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK) { ERR("Get kernel probe address failed."); diff --git a/src/common/location.cpp b/src/common/location.cpp index 65c041240..b09430d61 100644 --- a/src/common/location.cpp +++ b/src/common/location.cpp @@ -31,7 +31,7 @@ static void trace_archive_location_destroy_ref(struct urcu_ref *ref) { struct lttng_trace_archive_location *location = - container_of(ref, struct lttng_trace_archive_location, ref); + lttng::utils::container_of(ref, <tng_trace_archive_location::ref); switch (location->type) { case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL: diff --git a/src/common/macros.hpp b/src/common/macros.hpp index ecaaa4cda..37e6cabcf 100644 --- a/src/common/macros.hpp +++ b/src/common/macros.hpp @@ -229,14 +229,6 @@ void *memmove(T *d, const U *s, size_t n) = delete; #define ARRAY_SIZE(array) (sizeof(array) / (sizeof((array)[0]))) #endif -#ifndef container_of -#define container_of(ptr, type, member) \ - ({ \ - const typeof(((type *)NULL)->member) * __ptr = (ptr); \ - (type *)((char *)__ptr - offsetof(type, member)); \ - }) -#endif - #ifndef LTTNG_PACKED #define LTTNG_PACKED __attribute__((__packed__)) #endif @@ -317,4 +309,18 @@ int lttng_strncpy(char *dst, const char *src, size_t dst_len) return 0; } +namespace lttng { +namespace utils { +template +Parent *container_of(const Member *member, const Member Parent::*ptr_to_member) +{ + const Parent *dummy_parent = nullptr; + auto *offset_of_member = reinterpret_cast(&(dummy_parent->*ptr_to_member)); + auto address_of_parent = reinterpret_cast(member) - offset_of_member; + + return reinterpret_cast(address_of_parent); +} +} /* namespace utils */ +} /* namespace lttng */ + #endif /* _MACROS_H */ diff --git a/src/common/session-descriptor.cpp b/src/common/session-descriptor.cpp index 642c6399f..1171b2930 100644 --- a/src/common/session-descriptor.cpp +++ b/src/common/session-descriptor.cpp @@ -847,9 +847,8 @@ int lttng_session_descriptor_serialize( header.base.uri_count = uri_count; if (descriptor->type == LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE) { - const struct lttng_session_descriptor_live *live = - container_of(descriptor, typeof(*live), - base); + const struct lttng_session_descriptor_live *live = lttng::utils::container_of( + descriptor, <tng_session_descriptor_live::base); header.live_timer_us = live->live_timer_us; header_ptr = &header; @@ -918,7 +917,7 @@ lttng_session_descriptor_live_get_timer_interval( { struct lttng_session_descriptor_live *live; - live = container_of(descriptor, typeof(*live), base); + live = lttng::utils::container_of(descriptor, <tng_session_descriptor_live::base); return live->live_timer_us; } diff --git a/src/common/trace-chunk.cpp b/src/common/trace-chunk.cpp index beae46ef3..488d08146 100644 --- a/src/common/trace-chunk.cpp +++ b/src/common/trace-chunk.cpp @@ -237,8 +237,8 @@ end: static int fs_handle_untracked_get_fd(struct fs_handle *_handle) { - struct fs_handle_untracked *handle = container_of( - _handle, struct fs_handle_untracked, parent); + struct fs_handle_untracked *handle = lttng::utils::container_of( + _handle, &fs_handle_untracked::parent); return handle->fd; } @@ -252,8 +252,8 @@ void fs_handle_untracked_put_fd(struct fs_handle *_handle __attribute__((unused) static int fs_handle_untracked_unlink(struct fs_handle *_handle) { - struct fs_handle_untracked *handle = container_of( - _handle, struct fs_handle_untracked, parent); + struct fs_handle_untracked *handle = lttng::utils::container_of( + _handle, &fs_handle_untracked::parent); return lttng_directory_handle_unlink_file( handle->location.directory_handle, @@ -271,8 +271,8 @@ void fs_handle_untracked_destroy(struct fs_handle_untracked *handle) static int fs_handle_untracked_close(struct fs_handle *_handle) { - struct fs_handle_untracked *handle = container_of( - _handle, struct fs_handle_untracked, parent); + struct fs_handle_untracked *handle = lttng::utils::container_of( + _handle, &fs_handle_untracked::parent); int ret = close(handle->fd); fs_handle_untracked_destroy(handle); @@ -1462,8 +1462,8 @@ enum lttng_trace_chunk_status lttng_trace_chunk_open_file( /* * Does not close the fd; we just "unbox" it from the fs_handle. */ - fs_handle_untracked_destroy(container_of( - fs_handle, struct fs_handle_untracked, parent)); + fs_handle_untracked_destroy(lttng::utils::container_of( + fs_handle, &fs_handle_untracked::parent)); } return status; @@ -1861,8 +1861,8 @@ bool lttng_trace_chunk_get(struct lttng_trace_chunk *chunk) static void free_lttng_trace_chunk_registry_element(struct rcu_head *node) { - struct lttng_trace_chunk_registry_element *element = - container_of(node, typeof(*element), rcu_node); + struct lttng_trace_chunk_registry_element *element = lttng::utils::container_of( + node, <tng_trace_chunk_registry_element::rcu_node); free(element); } @@ -1870,8 +1870,7 @@ void free_lttng_trace_chunk_registry_element(struct rcu_head *node) static void lttng_trace_chunk_release(struct urcu_ref *ref) { - struct lttng_trace_chunk *chunk = container_of(ref, typeof(*chunk), - ref); + struct lttng_trace_chunk *chunk = lttng::utils::container_of(ref, <tng_trace_chunk::ref); if (chunk->close_command.is_set) { chunk_command func = close_command_get_post_release_func(chunk->close_command.value); @@ -1903,7 +1902,8 @@ void lttng_trace_chunk_release(struct urcu_ref *ref) */ lttng_trace_chunk_fini(chunk); - element = container_of(chunk, typeof(*element), chunk); + element = lttng::utils::container_of( + chunk, <tng_trace_chunk_registry_element::chunk); if (element->registry) { rcu_read_lock(); cds_lfht_del(element->registry->ht, @@ -2076,9 +2076,8 @@ lttng_trace_chunk_registry_publish_chunk( * already published and release the reference to the copy we * created if successful. */ - published_element = container_of(published_node, - typeof(*published_element), - trace_chunk_registry_ht_node); + published_element = lttng::utils::container_of(published_node, + <tng_trace_chunk_registry_element::trace_chunk_registry_ht_node); published_chunk = &published_element->chunk; if (lttng_trace_chunk_get(published_chunk)) { lttng_trace_chunk_put(&element->chunk); @@ -2136,9 +2135,8 @@ struct lttng_trace_chunk *_lttng_trace_chunk_registry_find_chunk( goto end; } - published_element = container_of(published_node, - typeof(*published_element), - trace_chunk_registry_ht_node); + published_element = lttng::utils::container_of(published_node, + <tng_trace_chunk_registry_element::trace_chunk_registry_ht_node); if (lttng_trace_chunk_get(&published_element->chunk)) { published_chunk = &published_element->chunk; } diff --git a/src/common/trigger.cpp b/src/common/trigger.cpp index 8e6f0734e..161c1abee 100644 --- a/src/common/trigger.cpp +++ b/src/common/trigger.cpp @@ -112,7 +112,7 @@ const struct lttng_action *lttng_trigger_get_const_action( static void trigger_destroy_ref(struct urcu_ref *ref) { struct lttng_trigger *trigger = - container_of(ref, struct lttng_trigger, ref); + lttng::utils::container_of(ref, <tng_trigger::ref); struct lttng_action *action = lttng_trigger_get_action(trigger); struct lttng_condition *condition = lttng_trigger_get_condition(trigger); diff --git a/src/common/userspace-probe.cpp b/src/common/userspace-probe.cpp index 99893b643..9798b12c4 100644 --- a/src/common/userspace-probe.cpp +++ b/src/common/userspace-probe.cpp @@ -117,8 +117,8 @@ void lttng_userspace_probe_location_function_destroy( LTTNG_ASSERT(location); - location_function = container_of(location, - struct lttng_userspace_probe_location_function, parent); + location_function = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); LTTNG_ASSERT(location_function); @@ -136,9 +136,8 @@ void lttng_userspace_probe_location_tracepoint_destroy( LTTNG_ASSERT(location); - location_tracepoint = container_of(location, - struct lttng_userspace_probe_location_tracepoint, - parent); + location_tracepoint = lttng::utils::container_of(location, + <tng_userspace_probe_location_tracepoint::parent); LTTNG_ASSERT(location_tracepoint); @@ -225,8 +224,8 @@ static unsigned long lttng_userspace_probe_location_function_hash( (void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION, lttng_ht_seed); struct lttng_userspace_probe_location_function *function_location = - container_of(location, typeof(*function_location), - parent); + lttng::utils::container_of( + location, <tng_userspace_probe_location_function::parent); hash ^= hash_key_str(function_location->function_name, lttng_ht_seed); hash ^= hash_key_str(function_location->binary_path, lttng_ht_seed); @@ -244,10 +243,10 @@ static bool lttng_userspace_probe_location_function_is_equal( bool is_equal = false; struct lttng_userspace_probe_location_function *a, *b; - a = container_of(_a, struct lttng_userspace_probe_location_function, - parent); - b = container_of(_b, struct lttng_userspace_probe_location_function, - parent); + a = lttng::utils::container_of(_a, + <tng_userspace_probe_location_function::parent); + b = lttng::utils::container_of(_b, + <tng_userspace_probe_location_function::parent); if (a->instrumentation_type != b->instrumentation_type) { goto end; @@ -350,8 +349,8 @@ static unsigned long lttng_userspace_probe_location_tracepoint_hash( unsigned long hash = hash_key_ulong( (void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT, lttng_ht_seed); - struct lttng_userspace_probe_location_tracepoint *tp_location = - container_of(location, typeof(*tp_location), parent); + struct lttng_userspace_probe_location_tracepoint *tp_location = lttng::utils::container_of( + location, <tng_userspace_probe_location_tracepoint::parent); hash ^= hash_key_str(tp_location->probe_name, lttng_ht_seed); hash ^= hash_key_str(tp_location->provider_name, lttng_ht_seed); @@ -370,10 +369,10 @@ static bool lttng_userspace_probe_location_tracepoint_is_equal( bool is_equal = false; struct lttng_userspace_probe_location_tracepoint *a, *b; - a = container_of(_a, struct lttng_userspace_probe_location_tracepoint, - parent); - b = container_of(_b, struct lttng_userspace_probe_location_tracepoint, - parent); + a = lttng::utils::container_of(_a, + <tng_userspace_probe_location_tracepoint::parent); + b = lttng::utils::container_of(_b, + <tng_userspace_probe_location_tracepoint::parent); LTTNG_ASSERT(a->probe_name); LTTNG_ASSERT(b->probe_name); @@ -604,10 +603,10 @@ lttng_userspace_probe_location_function_copy( LTTNG_ASSERT(location); LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION); - function_location = container_of( - location, typeof(*function_location), parent); + function_location = lttng::utils::container_of( + location, <tng_userspace_probe_location_function::parent); - /* Get probe location fields */ + /* Get probe location fields */ binary_path = lttng_userspace_probe_location_function_get_binary_path(location); if (!binary_path) { ERR("Userspace probe binary path is NULL"); @@ -678,8 +677,8 @@ lttng_userspace_probe_location_tracepoint_copy( LTTNG_ASSERT(location); LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT); - tracepoint_location = container_of( - location, typeof(*tracepoint_location), parent); + tracepoint_location = lttng::utils::container_of( + location, <tng_userspace_probe_location_tracepoint::parent); /* Get probe location fields */ binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location); @@ -756,9 +755,8 @@ const char *lttng_userspace_probe_location_function_get_binary_path( goto end; } - function_location = container_of(location, - struct lttng_userspace_probe_location_function, - parent); + function_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); ret = function_location->binary_path; end: return ret; @@ -776,9 +774,8 @@ const char *lttng_userspace_probe_location_tracepoint_get_binary_path( goto end; } - tracepoint_location = container_of(location, - struct lttng_userspace_probe_location_tracepoint, - parent); + tracepoint_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_tracepoint::parent); ret = tracepoint_location->binary_path; end: return ret; @@ -796,8 +793,8 @@ const char *lttng_userspace_probe_location_function_get_function_name( goto end; } - function_location = container_of(location, - struct lttng_userspace_probe_location_function, parent); + function_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); ret = function_location->function_name; end: return ret; @@ -815,8 +812,8 @@ const char *lttng_userspace_probe_location_tracepoint_get_probe_name( goto end; } - tracepoint_location = container_of(location, - struct lttng_userspace_probe_location_tracepoint, parent); + tracepoint_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_tracepoint::parent); ret = tracepoint_location->probe_name; end: return ret; @@ -834,8 +831,8 @@ const char *lttng_userspace_probe_location_tracepoint_get_provider_name( goto end; } - tracepoint_location = container_of(location, - struct lttng_userspace_probe_location_tracepoint, parent); + tracepoint_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_tracepoint::parent); ret = tracepoint_location->provider_name; end: return ret; @@ -853,8 +850,8 @@ int lttng_userspace_probe_location_function_get_binary_fd( goto end; } - function_location = container_of(location, - struct lttng_userspace_probe_location_function, parent); + function_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); ret = function_location->binary_fd_handle ? fd_handle_get_fd(function_location->binary_fd_handle) : -1; end: @@ -875,8 +872,8 @@ lttng_userspace_probe_location_function_get_instrumentation_type( goto end; } - function_location = container_of(location, - struct lttng_userspace_probe_location_function, parent); + function_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); type = function_location->instrumentation_type; end: return type; @@ -900,8 +897,8 @@ lttng_userspace_probe_location_function_set_instrumentation_type( goto end; } - function_location = container_of(location, - struct lttng_userspace_probe_location_function, parent); + function_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); function_location->instrumentation_type = instrumentation_type; end: return status; @@ -919,8 +916,8 @@ int lttng_userspace_probe_location_tracepoint_get_binary_fd( goto end; } - tracepoint_location = container_of(location, - struct lttng_userspace_probe_location_tracepoint, parent); + tracepoint_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_tracepoint::parent); ret = tracepoint_location->binary_fd_handle ? fd_handle_get_fd(tracepoint_location->binary_fd_handle) : -1; end: @@ -1021,9 +1018,8 @@ int lttng_userspace_probe_location_function_serialize( LTTNG_ASSERT(lttng_userspace_probe_location_get_type(location) == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION); - location_function = container_of(location, - struct lttng_userspace_probe_location_function, - parent); + location_function = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); if (!location_function->function_name || !location_function->binary_path) { ret = -LTTNG_ERR_INVALID; goto end; @@ -1098,9 +1094,8 @@ int lttng_userspace_probe_location_tracepoint_serialize( LTTNG_ASSERT(lttng_userspace_probe_location_get_type(location) == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT); - location_tracepoint = container_of(location, - struct lttng_userspace_probe_location_tracepoint, - parent); + location_tracepoint = lttng::utils::container_of(location, + <tng_userspace_probe_location_tracepoint::parent); if (!location_tracepoint->probe_name || !location_tracepoint->provider_name || !location_tracepoint->binary_path) { @@ -1568,8 +1563,8 @@ int lttng_userspace_probe_location_function_set_binary_fd_handle( LTTNG_ASSERT(location); LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION); - function_location = container_of(location, - struct lttng_userspace_probe_location_function, parent); + function_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); fd_handle_put(function_location->binary_fd_handle); fd_handle_get(binary_fd); function_location->binary_fd_handle = binary_fd; @@ -1587,8 +1582,8 @@ int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle( LTTNG_ASSERT(location); LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT); - tracepoint_location = container_of(location, - struct lttng_userspace_probe_location_tracepoint, parent); + tracepoint_location = lttng::utils::container_of(location, + <tng_userspace_probe_location_tracepoint::parent); fd_handle_put(tracepoint_location->binary_fd_handle); fd_handle_get(binary_fd); tracepoint_location->binary_fd_handle = binary_fd; @@ -1617,9 +1612,8 @@ int lttng_userspace_probe_location_function_flatten( goto end; } - probe_function = container_of(location, - struct lttng_userspace_probe_location_function, - parent); + probe_function = lttng::utils::container_of(location, + <tng_userspace_probe_location_function::parent); LTTNG_ASSERT(probe_function->function_name); LTTNG_ASSERT(probe_function->binary_path); @@ -1741,9 +1735,8 @@ int lttng_userspace_probe_location_tracepoint_flatten( ret = -LTTNG_ERR_INVALID; goto end; } - probe_tracepoint = container_of(location, - struct lttng_userspace_probe_location_tracepoint, - parent); + probe_tracepoint = lttng::utils::container_of(location, + <tng_userspace_probe_location_tracepoint::parent); LTTNG_ASSERT(probe_tracepoint->probe_name); LTTNG_ASSERT(probe_tracepoint->provider_name); LTTNG_ASSERT(probe_tracepoint->binary_path); diff --git a/src/lib/lttng-ctl/rotate.cpp b/src/lib/lttng-ctl/rotate.cpp index 106b8fb48..3f1848a80 100644 --- a/src/lib/lttng-ctl/rotate.cpp +++ b/src/lib/lttng-ctl/rotate.cpp @@ -487,9 +487,8 @@ lttng_rotation_schedule_size_threshold_get_threshold( goto end; } - size_schedule = container_of(schedule, - struct lttng_rotation_schedule_size_threshold, - parent); + size_schedule = lttng::utils::container_of(schedule, + <tng_rotation_schedule_size_threshold::parent); if (size_schedule->size.set) { *size_threshold_bytes = size_schedule->size.bytes; } else { @@ -515,9 +514,8 @@ lttng_rotation_schedule_size_threshold_set_threshold( goto end; } - size_schedule = container_of(schedule, - struct lttng_rotation_schedule_size_threshold, - parent); + size_schedule = lttng::utils::container_of(schedule, + <tng_rotation_schedule_size_threshold::parent); size_schedule->size.bytes = size_threshold_bytes; size_schedule->size.set = true; end: @@ -553,9 +551,8 @@ lttng_rotation_schedule_periodic_get_period( goto end; } - periodic_schedule = container_of(schedule, - struct lttng_rotation_schedule_periodic, - parent); + periodic_schedule = lttng::utils::container_of(schedule, + <tng_rotation_schedule_periodic::parent); if (periodic_schedule->period.set) { *period_us = periodic_schedule->period.us; } else { @@ -580,9 +577,8 @@ lttng_rotation_schedule_periodic_set_period( goto end; } - periodic_schedule = container_of(schedule, - struct lttng_rotation_schedule_periodic, - parent); + periodic_schedule = lttng::utils::container_of(schedule, + <tng_rotation_schedule_periodic::parent); periodic_schedule->period.us = period_us; periodic_schedule->period.set = true; end: -- 2.34.1