From: Jérémie Galarneau Date: Wed, 17 Jul 2024 20:39:54 +0000 (+0000) Subject: urcu: add lfht_iteration_adapter helper X-Git-Url: http://git.lttng.org./?a=commitdiff_plain;h=ef2f8a02adc70fba061f88381a3d477fa78ba3be;p=lttng-tools.git urcu: add lfht_iteration_adapter helper The urcu lfht macros often make use of caa_container_of (and other equivalent variations) which use offsetof. Unfortunately, offsetof is conditionally supported by compilers for non-POD types. The tree already has lttng::utils::container_of to work around this problem. This new utils makes it possible to iterate on all of the elements of an lfht without using those macros. Those iterations are the main reason such warnings are emitted. The interface of lfht_iteration_adapter also allows the use of ranged-for loops. Change-Id: I61906e025bd0dd7512f02180700f3ddb3c9cf3ca Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/save.cpp b/src/bin/lttng-sessiond/save.cpp index 67fa01de6..b5b91ed7d 100644 --- a/src/bin/lttng-sessiond/save.cpp +++ b/src/bin/lttng-sessiond/save.cpp @@ -1195,7 +1195,6 @@ static int save_agent_events(struct config_writer *writer, struct agent *agent) struct agent_event *agent_event; struct ltt_ust_event fake_event; - memset(&fake_event, 0, sizeof(fake_event)); agent_event = lttng::utils::container_of(node, &agent_event::node); /* diff --git a/src/bin/lttng-sessiond/snapshot.cpp b/src/bin/lttng-sessiond/snapshot.cpp index d4fb5f069..d326e30dd 100644 --- a/src/bin/lttng-sessiond/snapshot.cpp +++ b/src/bin/lttng-sessiond/snapshot.cpp @@ -42,8 +42,6 @@ static int output_init(const ltt_session::locked_ref& session, { int ret = 0, i; - memset(output, 0, sizeof(struct snapshot_output)); - /* * max_size of -1ULL means unset. Set to default (unlimited). */ @@ -178,7 +176,7 @@ error: struct snapshot_output *snapshot_output_alloc() { - return zmalloc(); + return new snapshot_output; } /* @@ -233,7 +231,8 @@ void snapshot_output_destroy(struct snapshot_output *obj) consumer_output_send_destroy_relayd(obj->consumer); consumer_output_put(obj->consumer); } - free(obj); + + delete obj; } /* diff --git a/src/bin/lttng-sessiond/snapshot.hpp b/src/bin/lttng-sessiond/snapshot.hpp index bdc520643..4933d190c 100644 --- a/src/bin/lttng-sessiond/snapshot.hpp +++ b/src/bin/lttng-sessiond/snapshot.hpp @@ -20,23 +20,23 @@ struct consumer_output; struct snapshot_output { - uint32_t id; - uint64_t max_size; + uint32_t id = 0; + uint64_t max_size = 0; /* Number of snapshot taken with that output. */ - uint64_t nb_snapshot; - char name[NAME_MAX]; - struct consumer_output *consumer; - int kernel_sockets_copied; - int ust_sockets_copied; + uint64_t nb_snapshot = 0; + char name[NAME_MAX] = {}; + struct consumer_output *consumer = nullptr; + bool kernel_sockets_copied = false; + bool ust_sockets_copied = false; /* * Contains the string with "-