Use compiler-agnostic defines to silence warning
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry-channel.cpp
index 03532cd09e65dfdd9fc4105a02ec1c9e6ecc9124..a153eac6e0d5463ec15d2c73101451c68e6b6cba 100644 (file)
@@ -22,7 +22,7 @@ namespace lst = lttng::sessiond::trace;
 namespace lsu = lttng::sessiond::ust;
 
 namespace {
-bool is_max_event_id(uint32_t id)
+bool is_max_event_id(lttng::sessiond::ust::event_id id)
 {
        return id == UINT32_MAX;
 }
@@ -377,25 +377,25 @@ void lsu::registry_channel::add_event(int session_objd,
                                      nonstd::optional<std::string> model_emf_uri,
                                      lttng_buffer_type buffer_type,
                                      const ust_app& app,
-                                     uint32_t& out_event_id)
+                                     lsu::event_id& out_event_id)
 {
-       uint32_t event_id;
+       lsu::event_id event_id;
        struct cds_lfht_node *nptr;
-       lttng::urcu::read_lock_guard read_lock_guard;
+       const lttng::urcu::read_lock_guard read_lock_guard;
 
        /*
         * This should not happen but since it comes from the UST tracer, an
         * external party, don't assert and simply validate values.
         */
        if (session_objd < 0) {
-               LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
+               LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
                        "Invalid session object descriptor provided by application: session descriptor = {}, app = {}",
                        session_objd,
                        app));
        }
 
        if (channel_objd < 0) {
-               LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
+               LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
                        "Invalid channel object descriptor provided by application: channel descriptor = {}, app = {}",
                        channel_objd,
                        app));
@@ -403,7 +403,7 @@ void lsu::registry_channel::add_event(int session_objd,
 
        /* Check if we've reached the maximum possible id. */
        if (is_max_event_id(_next_event_id)) {
-               LTTNG_THROW_ERROR(fmt::format(
+               LTTNG_THROW_ERROR(lttng::format(
                        "Failed to allocate new event id (id would overflow): app = {}", app));
        }
 
@@ -418,7 +418,7 @@ void lsu::registry_channel::add_event(int session_objd,
                                        loglevel_value,
                                        std::move(model_emf_uri)));
 
-       DBG3("%s", fmt::format("UST registry creating event: event = {}", *event).c_str());
+       DBG3("%s", lttng::format("UST registry creating event: event = {}", *event).c_str());
 
        /*
         * This is an add unique with a custom match function for event. The node
@@ -439,7 +439,7 @@ void lsu::registry_channel::add_event(int session_objd,
                                nptr, &lttng::sessiond::ust::registry_event::_node);
                        event_id = existing_event->id;
                } else {
-                       LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
+                       LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
                                "UST registry create event add unique failed for event: event = {}",
                                *event));
                }
@@ -497,20 +497,14 @@ void lsu::registry_channel::set_as_registered()
 void lsu::registry_channel::_accept_on_event_classes(
        lttng::sessiond::trace::trace_class_visitor& visitor) const
 {
-       std::vector<const lttng::sessiond::ust::registry_event *> sorted_event_classes;
-
-       {
-               lttng::urcu::read_lock_guard read_lock_guard;
-               struct lttng_ht_iter iter;
-               const lttng::sessiond::ust::registry_event *event;
-
-               DIAGNOSTIC_PUSH
-               DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-               cds_lfht_for_each_entry (_events->ht, &iter.iter, event, _node) {
-                       sorted_event_classes.emplace_back(event);
-               }
-               DIAGNOSTIC_POP
-       }
+       const lttng::urcu::lfht_iteration_adapter<lsu::registry_event,
+                                                 decltype(lsu::registry_event::_node),
+                                                 &lsu::registry_event::_node>
+               events_view(*_events->ht);
+
+       /* Copy the event ptrs from the _events ht to this vector which we'll sort. */
+       std::vector<const lttng::sessiond::ust::registry_event *> sorted_event_classes(
+               events_view.begin(), events_view.end());
 
        std::sort(sorted_event_classes.begin(),
                  sorted_event_classes.end(),
This page took 0.026101 seconds and 4 git commands to generate.