Fix: syscall event rule: emission sites not compared in is_equal
[lttng-tools.git] / src / bin / lttng-sessiond / save.cpp
index 2055e867de5eac86496a7cd599c0aee488510026..b4ca4c080fdd8f119a98a2fe31682be6d9cec42e 100644 (file)
  */
 
 #define _LGPL_SOURCE
+#include "agent.hpp"
+#include "kernel.hpp"
+#include "lttng-syscall.hpp"
+#include "save.hpp"
+#include "session.hpp"
+#include "trace-ust.hpp"
+
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/runas.hpp>
+#include <common/urcu.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/save-internal.hpp>
+
+#include <fcntl.h>
 #include <inttypes.h>
 #include <string.h>
-#include <urcu/uatomic.h>
 #include <unistd.h>
-
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/utils.h>
-#include <common/runas.h>
-#include <lttng/save-internal.h>
-
-#include "kernel.h"
-#include "save.h"
-#include "session.h"
-#include "lttng-syscall.h"
-#include "trace-ust.h"
-#include "agent.h"
+#include <urcu/uatomic.h>
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_channel_attributes(struct config_writer *writer,
-       struct lttng_channel_attr *attr)
+static int save_kernel_channel_attributes(struct config_writer *writer,
+                                         struct lttng_channel_attr *attr)
 {
        int ret;
 
        ret = config_writer_write_element_string(writer,
-               config_element_overwrite_mode,
-               attr->overwrite ? config_overwrite_mode_overwrite :
-                       config_overwrite_mode_discard);
+                                                config_element_overwrite_mode,
+                                                attr->overwrite ? config_overwrite_mode_overwrite :
+                                                                  config_overwrite_mode_discard);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_subbuf_size, attr->subbuf_size);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_subbuf_size, attr->subbuf_size);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_num_subbuf,
-               attr->num_subbuf);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_num_subbuf, attr->num_subbuf);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_switch_timer_interval,
-               attr->switch_timer_interval);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_switch_timer_interval, attr->switch_timer_interval);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_read_timer_interval,
-               attr->read_timer_interval);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_read_timer_interval, attr->read_timer_interval);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
        ret = config_writer_write_element_string(writer,
-               config_element_output_type,
-               attr->output == LTTNG_EVENT_SPLICE ?
-               config_output_type_splice : config_output_type_mmap);
+                                                config_element_output_type,
+                                                attr->output == LTTNG_EVENT_SPLICE ?
+                                                        config_output_type_splice :
+                                                        config_output_type_mmap);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_tracefile_size, attr->tracefile_size);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_tracefile_size, attr->tracefile_size);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_tracefile_count,
-               attr->tracefile_count);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_tracefile_count, attr->tracefile_count);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_live_timer_interval,
-               attr->live_timer_interval);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_live_timer_interval, attr->live_timer_interval);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
        if (attr->extended.ptr) {
-               struct lttng_channel_extended *ext = NULL;
+               struct lttng_channel_extended *ext = nullptr;
 
                ext = (struct lttng_channel_extended *) attr->extended.ptr;
-               ret = config_writer_write_element_unsigned_int(writer,
-                               config_element_monitor_timer_interval,
-                               ext->monitor_timer_interval);
+               ret = config_writer_write_element_unsigned_int(
+                       writer, config_element_monitor_timer_interval, ext->monitor_timer_interval);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
 
-               ret = config_writer_write_element_signed_int(writer,
-                               config_element_blocking_timeout,
-                               ext->blocking_timeout);
+               ret = config_writer_write_element_signed_int(
+                       writer, config_element_blocking_timeout, ext->blocking_timeout);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -131,65 +127,61 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_channel_attributes(struct config_writer *writer,
-       struct lttng_ust_abi_channel_attr *attr)
+static int save_ust_channel_attributes(struct config_writer *writer,
+                                      struct lttng_ust_abi_channel_attr *attr)
 {
        int ret;
-       struct ltt_ust_channel *channel = NULL;
+       struct ltt_ust_channel *channel = nullptr;
 
        ret = config_writer_write_element_string(writer,
-               config_element_overwrite_mode,
-               attr->overwrite ? config_overwrite_mode_overwrite :
-                       config_overwrite_mode_discard);
+                                                config_element_overwrite_mode,
+                                                attr->overwrite ? config_overwrite_mode_overwrite :
+                                                                  config_overwrite_mode_discard);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_subbuf_size, attr->subbuf_size);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_subbuf_size, attr->subbuf_size);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_num_subbuf,
-               attr->num_subbuf);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_num_subbuf, attr->num_subbuf);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_switch_timer_interval,
-               attr->switch_timer_interval);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_switch_timer_interval, attr->switch_timer_interval);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_read_timer_interval,
-               attr->read_timer_interval);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_read_timer_interval, attr->read_timer_interval);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
        ret = config_writer_write_element_string(writer,
-               config_element_output_type,
-               attr->output == LTTNG_UST_ABI_MMAP ?
-               config_output_type_mmap : config_output_type_splice);
+                                                config_element_output_type,
+                                                attr->output == LTTNG_UST_ABI_MMAP ?
+                                                        config_output_type_mmap :
+                                                        config_output_type_splice);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_signed_int(writer,
-                       config_element_blocking_timeout,
-                       attr->u.s.blocking_timeout);
+       ret = config_writer_write_element_signed_int(
+               writer, config_element_blocking_timeout, attr->u.s.blocking_timeout);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -199,10 +191,9 @@ 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);
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_monitor_timer_interval,
-               channel->monitor_timer_interval);
+       channel = lttng::utils::container_of(attr, &ltt_ust_channel::attr);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_monitor_timer_interval, channel->monitor_timer_interval);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -213,9 +204,8 @@ end:
        return ret;
 }
 
-static
-const char *get_kernel_instrumentation_string(
-       enum lttng_kernel_abi_instrumentation instrumentation)
+static const char *
+get_kernel_instrumentation_string(enum lttng_kernel_abi_instrumentation instrumentation)
 {
        const char *instrumentation_string;
 
@@ -245,15 +235,13 @@ const char *get_kernel_instrumentation_string(
                instrumentation_string = config_event_type_syscall;
                break;
        default:
-               instrumentation_string = NULL;
+               instrumentation_string = nullptr;
        }
 
        return instrumentation_string;
 }
 
-static
-const char *get_kernel_context_type_string(
-       enum lttng_kernel_abi_context_type context_type)
+static const char *get_kernel_context_type_string(enum lttng_kernel_abi_context_type context_type)
 {
        const char *context_type_string;
 
@@ -367,15 +355,13 @@ const char *get_kernel_context_type_string(
                context_type_string = config_event_context_vsgid;
                break;
        default:
-               context_type_string = NULL;
+               context_type_string = nullptr;
        }
 
        return context_type_string;
 }
 
-static
-const char *get_ust_context_type_string(
-       enum lttng_ust_abi_context_type context_type)
+static const char *get_ust_context_type_string(enum lttng_ust_abi_context_type context_type)
 {
        const char *context_type_string;
 
@@ -446,16 +432,14 @@ const char *get_ust_context_type_string(
                 * are stored as a node of type event_perf_context_type.
                 */
        default:
-               context_type_string = NULL;
+               context_type_string = nullptr;
                break;
        }
 
        return context_type_string;
 }
 
-static
-const char *get_buffer_type_string(
-       enum lttng_buffer_type buffer_type)
+static const char *get_buffer_type_string(enum lttng_buffer_type buffer_type)
 {
        const char *buffer_type_string;
 
@@ -470,15 +454,13 @@ const char *get_buffer_type_string(
                buffer_type_string = config_buffer_type_global;
                break;
        default:
-               buffer_type_string = NULL;
+               buffer_type_string = nullptr;
        }
 
        return buffer_type_string;
 }
 
-static
-const char *get_loglevel_type_string(
-       enum lttng_ust_abi_loglevel_type loglevel_type)
+static const char *get_loglevel_type_string(enum lttng_ust_abi_loglevel_type loglevel_type)
 {
        const char *loglevel_type_string;
 
@@ -493,16 +475,14 @@ const char *get_loglevel_type_string(
                loglevel_type_string = config_loglevel_type_single;
                break;
        default:
-               loglevel_type_string = NULL;
+               loglevel_type_string = nullptr;
        }
 
        return loglevel_type_string;
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_function_event(struct config_writer *writer,
-               struct ltt_kernel_event *event)
+static int save_kernel_function_event(struct config_writer *writer, struct ltt_kernel_event *event)
 {
        int ret;
 
@@ -512,8 +492,8 @@ int save_kernel_function_event(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer, config_element_name,
-                       event->event->u.ftrace.symbol_name);
+       ret = config_writer_write_element_string(
+               writer, config_element_name, event->event->u.ftrace.symbol_name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -529,9 +509,7 @@ end:
        return ret;
 }
 
-static
-int save_kernel_kprobe_event(struct config_writer *writer,
-               struct ltt_kernel_event *event)
+static int save_kernel_kprobe_event(struct config_writer *writer, struct ltt_kernel_event *event)
 {
        int ret;
        const char *symbol_name;
@@ -546,15 +524,14 @@ int save_kernel_kprobe_event(struct config_writer *writer,
                 */
                addr = event->event->u.kprobe.addr;
                offset = event->event->u.kprobe.offset;
-               symbol_name = addr ? NULL : event->event->u.kprobe.symbol_name;
+               symbol_name = addr ? nullptr : event->event->u.kprobe.symbol_name;
                break;
        case LTTNG_KERNEL_ABI_KRETPROBE:
                addr = event->event->u.kretprobe.addr;
                offset = event->event->u.kretprobe.offset;
-               symbol_name = addr ? NULL : event->event->u.kretprobe.symbol_name;
+               symbol_name = addr ? nullptr : event->event->u.kretprobe.symbol_name;
                break;
        default:
-               LTTNG_ASSERT(1);
                ERR("Unsupported kernel instrumentation type.");
                ret = LTTNG_ERR_INVALID;
                goto end;
@@ -567,23 +544,23 @@ int save_kernel_kprobe_event(struct config_writer *writer,
        }
 
        if (addr) {
-               ret = config_writer_write_element_unsigned_int( writer,
-                               config_element_address, addr);
+               ret = config_writer_write_element_unsigned_int(
+                       writer, config_element_address, addr);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
        } else if (symbol_name) {
-               ret = config_writer_write_element_string(writer,
-                                config_element_symbol_name, symbol_name);
+               ret = config_writer_write_element_string(
+                       writer, config_element_symbol_name, symbol_name);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
                /* If the offset is non-zero, write it.*/
                if (offset) {
-                       ret = config_writer_write_element_unsigned_int(writer,
-                               config_element_offset, offset);
+                       ret = config_writer_write_element_unsigned_int(
+                               writer, config_element_offset, offset);
                        if (ret) {
                                ret = LTTNG_ERR_SAVE_IO_FAIL;
                                goto end;
@@ -599,7 +576,6 @@ int save_kernel_kprobe_event(struct config_writer *writer,
                goto end;
        }
 
-
        ret = config_writer_close_element(writer);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
@@ -613,9 +589,8 @@ end:
  * Save the userspace probe tracepoint event associated with the event to the
  * config writer.
  */
-static
-int save_kernel_userspace_probe_tracepoint_event(struct config_writer *writer,
-               struct ltt_kernel_event *event)
+static int save_kernel_userspace_probe_tracepoint_event(struct config_writer *writer,
+                                                       struct ltt_kernel_event *event)
 {
        int ret = 0;
        const char *probe_name, *provider_name, *binary_path;
@@ -641,31 +616,29 @@ int save_kernel_userspace_probe_tracepoint_event(struct config_writer *writer,
 
        /* Get the binary path, probe name and provider name. */
        binary_path =
-               lttng_userspace_probe_location_tracepoint_get_binary_path(
-                               userspace_probe_location);
+               lttng_userspace_probe_location_tracepoint_get_binary_path(userspace_probe_location);
        if (!binary_path) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
        probe_name =
-               lttng_userspace_probe_location_tracepoint_get_probe_name(
-                               userspace_probe_location);
+               lttng_userspace_probe_location_tracepoint_get_probe_name(userspace_probe_location);
        if (!probe_name) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       provider_name =
-               lttng_userspace_probe_location_tracepoint_get_provider_name(
-                               userspace_probe_location);
+       provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
+               userspace_probe_location);
        if (!provider_name) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
        /* Open a userspace probe tracepoint attribute. */
-       ret = config_writer_open_element(writer, config_element_userspace_probe_tracepoint_attributes);
+       ret = config_writer_open_element(writer,
+                                        config_element_userspace_probe_tracepoint_attributes);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -673,9 +646,10 @@ int save_kernel_userspace_probe_tracepoint_event(struct config_writer *writer,
 
        switch (lookup_type) {
        case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
-               ret = config_writer_write_element_string(writer,
-                               config_element_userspace_probe_lookup,
-                               config_element_userspace_probe_lookup_tracepoint_sdt);
+               ret = config_writer_write_element_string(
+                       writer,
+                       config_element_userspace_probe_lookup,
+                       config_element_userspace_probe_lookup_tracepoint_sdt);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -688,25 +662,24 @@ int save_kernel_userspace_probe_tracepoint_event(struct config_writer *writer,
        }
 
        /* Write the binary path, provider name and the probe name. */
-       ret = config_writer_write_element_string(writer,
-                       config_element_userspace_probe_location_binary_path,
-                       binary_path);
+       ret = config_writer_write_element_string(
+               writer, config_element_userspace_probe_location_binary_path, binary_path);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-                       config_element_userspace_probe_tracepoint_location_provider_name,
-                       provider_name);
+       ret = config_writer_write_element_string(
+               writer,
+               config_element_userspace_probe_tracepoint_location_provider_name,
+               provider_name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-                       config_element_userspace_probe_tracepoint_location_probe_name,
-                       probe_name);
+       ret = config_writer_write_element_string(
+               writer, config_element_userspace_probe_tracepoint_location_probe_name, probe_name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -727,9 +700,8 @@ end:
  * Save the userspace probe function event associated with the event to the
  * config writer.
  */
-static
-int save_kernel_userspace_probe_function_event(struct config_writer *writer,
-               struct ltt_kernel_event *event)
+static int save_kernel_userspace_probe_function_event(struct config_writer *writer,
+                                                     struct ltt_kernel_event *event)
 {
        int ret = 0;
        const char *function_name, *binary_path;
@@ -745,8 +717,7 @@ int save_kernel_userspace_probe_function_event(struct config_writer *writer,
        }
 
        /* Get lookup method and lookup method type. */
-       lookup_method = lttng_userspace_probe_location_get_lookup_method(
-                       userspace_probe_location);
+       lookup_method = lttng_userspace_probe_location_get_lookup_method(userspace_probe_location);
        if (!lookup_method) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -754,16 +725,14 @@ int save_kernel_userspace_probe_function_event(struct config_writer *writer,
 
        /* Get the binary path and the function name. */
        binary_path =
-               lttng_userspace_probe_location_function_get_binary_path(
-                               userspace_probe_location);
+               lttng_userspace_probe_location_function_get_binary_path(userspace_probe_location);
        if (!binary_path) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
        function_name =
-               lttng_userspace_probe_location_function_get_function_name(
-                               userspace_probe_location);
+               lttng_userspace_probe_location_function_get_function_name(userspace_probe_location);
        if (!function_name) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -771,7 +740,7 @@ int save_kernel_userspace_probe_function_event(struct config_writer *writer,
 
        /* Open a userspace probe function attribute. */
        ret = config_writer_open_element(writer,
-                       config_element_userspace_probe_function_attributes);
+                                        config_element_userspace_probe_function_attributes);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -780,18 +749,20 @@ int save_kernel_userspace_probe_function_event(struct config_writer *writer,
        lookup_type = lttng_userspace_probe_location_lookup_method_get_type(lookup_method);
        switch (lookup_type) {
        case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
-               ret = config_writer_write_element_string(writer,
-                               config_element_userspace_probe_lookup,
-                               config_element_userspace_probe_lookup_function_elf);
+               ret = config_writer_write_element_string(
+                       writer,
+                       config_element_userspace_probe_lookup,
+                       config_element_userspace_probe_lookup_function_elf);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
                break;
        case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
-               ret = config_writer_write_element_string(writer,
-                               config_element_userspace_probe_lookup,
-                               config_element_userspace_probe_lookup_function_default);
+               ret = config_writer_write_element_string(
+                       writer,
+                       config_element_userspace_probe_lookup,
+                       config_element_userspace_probe_lookup_function_default);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -804,17 +775,17 @@ int save_kernel_userspace_probe_function_event(struct config_writer *writer,
        }
 
        /* Write the binary path and the function name. */
-       ret = config_writer_write_element_string(writer,
-                       config_element_userspace_probe_location_binary_path,
-                       binary_path);
+       ret = config_writer_write_element_string(
+               writer, config_element_userspace_probe_location_binary_path, binary_path);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-                       config_element_userspace_probe_function_location_function_name,
-                       function_name);
+       ret = config_writer_write_element_string(
+               writer,
+               config_element_userspace_probe_function_location_function_name,
+               function_name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -831,9 +802,8 @@ end:
        return ret;
 }
 
-static
-int save_kernel_userspace_probe_event(struct config_writer *writer,
-               struct ltt_kernel_event *event)
+static int save_kernel_userspace_probe_event(struct config_writer *writer,
+                                            struct ltt_kernel_event *event)
 {
        int ret;
        struct lttng_userspace_probe_location *userspace_probe_location;
@@ -845,7 +815,7 @@ int save_kernel_userspace_probe_event(struct config_writer *writer,
                goto end;
        }
 
-       switch(lttng_userspace_probe_location_get_type(userspace_probe_location)) {
+       switch (lttng_userspace_probe_location_get_type(userspace_probe_location)) {
        case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
        {
                ret = save_kernel_userspace_probe_function_event(writer, event);
@@ -875,9 +845,7 @@ end:
        return ret;
 }
 
-static
-int save_kernel_event(struct config_writer *writer,
-               struct ltt_kernel_event *event)
+static int save_kernel_event(struct config_writer *writer, struct ltt_kernel_event *event)
 {
        int ret;
        const char *instrumentation_type;
@@ -889,39 +857,35 @@ int save_kernel_event(struct config_writer *writer,
        }
 
        if (event->event->name[0]) {
-               ret = config_writer_write_element_string(writer,
-                       config_element_name, event->event->name);
+               ret = config_writer_write_element_string(
+                       writer, config_element_name, event->event->name);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
        }
 
-       ret = config_writer_write_element_bool(writer, config_element_enabled,
-               event->enabled);
+       ret = config_writer_write_element_bool(writer, config_element_enabled, event->enabled);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       instrumentation_type = get_kernel_instrumentation_string(
-               event->event->instrumentation);
+       instrumentation_type = get_kernel_instrumentation_string(event->event->instrumentation);
        if (!instrumentation_type) {
                ret = LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer, config_element_type,
-               instrumentation_type);
+       ret = config_writer_write_element_string(writer, config_element_type, instrumentation_type);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
        if (event->filter_expression) {
-               ret = config_writer_write_element_string(writer,
-                               config_element_filter,
-                               event->filter_expression);
+               ret = config_writer_write_element_string(
+                       writer, config_element_filter, event->filter_expression);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -929,12 +893,10 @@ int save_kernel_event(struct config_writer *writer,
        }
 
        if (event->event->instrumentation == LTTNG_KERNEL_ABI_FUNCTION ||
-               event->event->instrumentation == LTTNG_KERNEL_ABI_KPROBE ||
-               event->event->instrumentation == LTTNG_KERNEL_ABI_UPROBE ||
-               event->event->instrumentation == LTTNG_KERNEL_ABI_KRETPROBE) {
-
-               ret = config_writer_open_element(writer,
-                       config_element_attributes);
+           event->event->instrumentation == LTTNG_KERNEL_ABI_KPROBE ||
+           event->event->instrumentation == LTTNG_KERNEL_ABI_UPROBE ||
+           event->event->instrumentation == LTTNG_KERNEL_ABI_KRETPROBE) {
+               ret = config_writer_open_element(writer, config_element_attributes);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -988,9 +950,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_events(struct config_writer *writer,
-       struct ltt_kernel_channel *kchan)
+static int save_kernel_events(struct config_writer *writer, struct ltt_kernel_channel *kchan)
 {
        int ret;
        struct ltt_kernel_event *event;
@@ -1001,7 +961,7 @@ int save_kernel_events(struct config_writer *writer,
                goto end;
        }
 
-       cds_list_for_each_entry(event, &kchan->events_list.head, list) {
+       cds_list_for_each_entry (event, &kchan->events_list.head, list) {
                ret = save_kernel_event(writer, event);
                if (ret != LTTNG_OK) {
                        goto end;
@@ -1021,9 +981,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_event(struct config_writer *writer,
-       struct ltt_ust_event *event)
+static int save_ust_event(struct config_writer *writer, struct ltt_ust_event *event)
 {
        int ret;
        const char *loglevel_type_string;
@@ -1035,16 +993,15 @@ int save_ust_event(struct config_writer *writer,
        }
 
        if (event->attr.name[0]) {
-               ret = config_writer_write_element_string(writer,
-                       config_element_name, event->attr.name);
+               ret = config_writer_write_element_string(
+                       writer, config_element_name, event->attr.name);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
        }
 
-       ret = config_writer_write_element_bool(writer, config_element_enabled,
-               event->enabled);
+       ret = config_writer_write_element_bool(writer, config_element_enabled, event->enabled);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1055,23 +1012,23 @@ int save_ust_event(struct config_writer *writer,
                ret = LTTNG_ERR_INVALID;
                goto end;
        }
-       ret = config_writer_write_element_string(writer, config_element_type,
-               config_event_type_tracepoint);
+       ret = config_writer_write_element_string(
+               writer, config_element_type, config_event_type_tracepoint);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       loglevel_type_string = get_loglevel_type_string(
-               (lttng_ust_abi_loglevel_type) event->attr.loglevel_type);
+       loglevel_type_string =
+               get_loglevel_type_string((lttng_ust_abi_loglevel_type) event->attr.loglevel_type);
        if (!loglevel_type_string) {
                ERR("Unsupported UST loglevel type.");
                ret = LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-               config_element_loglevel_type, loglevel_type_string);
+       ret = config_writer_write_element_string(
+               writer, config_element_loglevel_type, loglevel_type_string);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1079,8 +1036,8 @@ int save_ust_event(struct config_writer *writer,
 
        /* The log level is irrelevant if no "filtering" is enabled */
        if (event->attr.loglevel_type != LTTNG_UST_ABI_LOGLEVEL_ALL) {
-               ret = config_writer_write_element_signed_int(writer,
-                               config_element_loglevel, event->attr.loglevel);
+               ret = config_writer_write_element_signed_int(
+                       writer, config_element_loglevel, event->attr.loglevel);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -1088,8 +1045,8 @@ int save_ust_event(struct config_writer *writer,
        }
 
        if (event->filter_expression) {
-               ret = config_writer_write_element_string(writer,
-                       config_element_filter, event->filter_expression);
+               ret = config_writer_write_element_string(
+                       writer, config_element_filter, event->filter_expression);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -1099,18 +1056,17 @@ int save_ust_event(struct config_writer *writer,
        if (event->exclusion && event->exclusion->count) {
                uint32_t i;
 
-               ret = config_writer_open_element(writer,
-                       config_element_exclusions);
+               ret = config_writer_open_element(writer, config_element_exclusions);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
 
                for (i = 0; i < event->exclusion->count; i++) {
-                       ret = config_writer_write_element_string(writer,
+                       ret = config_writer_write_element_string(
+                               writer,
                                config_element_exclusion,
-                               LTTNG_EVENT_EXCLUSION_NAME_AT(
-                                       event->exclusion, i));
+                               LTTNG_EVENT_EXCLUSION_NAME_AT(event->exclusion, i));
                        if (ret) {
                                ret = LTTNG_ERR_SAVE_IO_FAIL;
                                goto end;
@@ -1138,9 +1094,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_events(struct config_writer *writer,
-       struct lttng_ht *events)
+static int save_ust_events(struct config_writer *writer, struct lttng_ht *events)
 {
        int ret;
        struct ltt_ust_event *event;
@@ -1153,21 +1107,22 @@ int save_ust_events(struct config_writer *writer,
                goto end;
        }
 
-       rcu_read_lock();
-       cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) {
-               event = caa_container_of(node, struct ltt_ust_event, node);
+       {
+               lttng::urcu::read_lock_guard read_lock;
 
-               if (event->internal) {
-                       /* Internal events must not be exposed to clients */
-                       continue;
-               }
-               ret = save_ust_event(writer, event);
-               if (ret != LTTNG_OK) {
-                       rcu_read_unlock();
-                       goto end;
+               cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) {
+                       event = lttng::utils::container_of(node, &ltt_ust_event::node);
+
+                       if (event->internal) {
+                               /* Internal events must not be exposed to clients */
+                               continue;
+                       }
+                       ret = save_ust_event(writer, event);
+                       if (ret != LTTNG_OK) {
+                               goto end;
+                       }
                }
        }
-       rcu_read_unlock();
 
        /* /events */
        ret = config_writer_close_element(writer);
@@ -1182,17 +1137,15 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event,
-               struct agent_event *agent_event)
+static int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event,
+                                          struct agent_event *agent_event)
 {
        int ret;
        enum lttng_ust_abi_loglevel_type ust_loglevel_type;
 
        ust_event->enabled = AGENT_EVENT_IS_ENABLED(agent_event);
        ust_event->attr.instrumentation = LTTNG_UST_ABI_TRACEPOINT;
-       if (lttng_strncpy(ust_event->attr.name, agent_event->name,
-                       LTTNG_SYMBOL_NAME_LEN)) {
+       if (lttng_strncpy(ust_event->attr.name, agent_event->name, LTTNG_SYMBOL_NAME_LEN)) {
                ret = LTTNG_ERR_INVALID;
                goto end;
        }
@@ -1223,9 +1176,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_agent_events(struct config_writer *writer,
-               struct agent *agent)
+static int save_agent_events(struct config_writer *writer, struct agent *agent)
 {
        int ret;
        struct lttng_ht_iter iter;
@@ -1237,32 +1188,32 @@ int save_agent_events(struct config_writer *writer,
                goto end;
        }
 
-       rcu_read_lock();
-       cds_lfht_for_each_entry(agent->events->ht, &iter.iter, node, node) {
-               struct agent_event *agent_event;
-               struct ltt_ust_event fake_event;
-
-               memset(&fake_event, 0, sizeof(fake_event));
-               agent_event = caa_container_of(node, struct agent_event, node);
-
-               /*
-                * Initialize a fake ust event to reuse the same serialization
-                * function since UST and agent events contain the same info
-                * (and one could wonder why they don't reuse the same
-                * structures...).
-                */
-               ret = init_ust_event_from_agent_event(&fake_event, agent_event);
-               if (ret != LTTNG_OK) {
-                       rcu_read_unlock();
-                       goto end;
-               }
-               ret = save_ust_event(writer, &fake_event);
-               if (ret != LTTNG_OK) {
-                       rcu_read_unlock();
-                       goto end;
+       {
+               lttng::urcu::read_lock_guard read_lock;
+
+               cds_lfht_for_each_entry (agent->events->ht, &iter.iter, node, node) {
+                       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);
+
+                       /*
+                        * Initialize a fake ust event to reuse the same serialization
+                        * function since UST and agent events contain the same info
+                        * (and one could wonder why they don't reuse the same
+                        * structures...).
+                        */
+                       ret = init_ust_event_from_agent_event(&fake_event, agent_event);
+                       if (ret != LTTNG_OK) {
+                               goto end;
+                       }
+                       ret = save_ust_event(writer, &fake_event);
+                       if (ret != LTTNG_OK) {
+                               goto end;
+                       }
                }
        }
-       rcu_read_unlock();
 
        /* /events */
        ret = config_writer_close_element(writer);
@@ -1277,9 +1228,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_context(struct config_writer *writer,
-       struct lttng_kernel_abi_context *ctx)
+static int save_kernel_context(struct config_writer *writer, struct lttng_kernel_abi_context *ctx)
 {
        int ret = LTTNG_OK;
 
@@ -1294,29 +1243,28 @@ int save_kernel_context(struct config_writer *writer,
        }
 
        if (ctx->ctx == LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER) {
-               ret = config_writer_open_element(writer,
-                               config_element_context_perf);
+               ret = config_writer_open_element(writer, config_element_context_perf);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
 
-               ret = config_writer_write_element_unsigned_int(writer,
-                       config_element_type, ctx->u.perf_counter.type);
+               ret = config_writer_write_element_unsigned_int(
+                       writer, config_element_type, ctx->u.perf_counter.type);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
 
-               ret = config_writer_write_element_unsigned_int(writer,
-                       config_element_config, ctx->u.perf_counter.config);
+               ret = config_writer_write_element_unsigned_int(
+                       writer, config_element_config, ctx->u.perf_counter.config);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
 
-               ret = config_writer_write_element_string(writer,
-                       config_element_name, ctx->u.perf_counter.name);
+               ret = config_writer_write_element_string(
+                       writer, config_element_name, ctx->u.perf_counter.name);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -1329,8 +1277,7 @@ int save_kernel_context(struct config_writer *writer,
                        goto end;
                }
        } else {
-               const char *context_type_string =
-                       get_kernel_context_type_string(ctx->ctx);
+               const char *context_type_string = get_kernel_context_type_string(ctx->ctx);
 
                if (!context_type_string) {
                        ERR("Unsupported kernel context type.");
@@ -1338,8 +1285,8 @@ int save_kernel_context(struct config_writer *writer,
                        goto end;
                }
 
-               ret = config_writer_write_element_string(writer,
-                       config_element_type, context_type_string);
+               ret = config_writer_write_element_string(
+                       writer, config_element_type, context_type_string);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -1359,9 +1306,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_contexts(struct config_writer *writer,
-               struct ltt_kernel_channel *kchan)
+static int save_kernel_contexts(struct config_writer *writer, struct ltt_kernel_channel *kchan)
 {
        int ret;
        struct ltt_kernel_context *ctx;
@@ -1377,7 +1322,7 @@ int save_kernel_contexts(struct config_writer *writer,
                goto end;
        }
 
-       cds_list_for_each_entry(ctx, &kchan->ctx_list, list) {
+       cds_list_for_each_entry (ctx, &kchan->ctx_list, list) {
                ret = save_kernel_context(writer, &ctx->ctx);
                if (ret != LTTNG_OK) {
                        goto end;
@@ -1397,9 +1342,8 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_context_perf_thread_counter(struct config_writer *writer,
-               struct ltt_ust_context *ctx)
+static int save_ust_context_perf_thread_counter(struct config_writer *writer,
+                                               struct ltt_ust_context *ctx)
 {
        int ret;
 
@@ -1413,22 +1357,22 @@ int save_ust_context_perf_thread_counter(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-                       config_element_type, ctx->ctx.u.perf_counter.type);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_type, ctx->ctx.u.perf_counter.type);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-                       config_element_config, ctx->ctx.u.perf_counter.config);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_config, ctx->ctx.u.perf_counter.config);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer, config_element_name,
-                       ctx->ctx.u.perf_counter.name);
+       ret = config_writer_write_element_string(
+               writer, config_element_name, ctx->ctx.u.perf_counter.name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1447,9 +1391,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_context_app_ctx(struct config_writer *writer,
-               struct ltt_ust_context *ctx)
+static int save_ust_context_app_ctx(struct config_writer *writer, struct ltt_ust_context *ctx)
 {
        int ret;
 
@@ -1463,17 +1405,15 @@ int save_ust_context_app_ctx(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-                       config_element_context_app_provider_name,
-                       ctx->ctx.u.app_ctx.provider_name);
+       ret = config_writer_write_element_string(
+               writer, config_element_context_app_provider_name, ctx->ctx.u.app_ctx.provider_name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-                       config_element_context_app_ctx_name,
-                       ctx->ctx.u.app_ctx.ctx_name);
+       ret = config_writer_write_element_string(
+               writer, config_element_context_app_ctx_name, ctx->ctx.u.app_ctx.ctx_name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1492,9 +1432,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_context_generic(struct config_writer *writer,
-               struct ltt_ust_context *ctx)
+static int save_ust_context_generic(struct config_writer *writer, struct ltt_ust_context *ctx)
 {
        int ret;
        const char *context_type_string;
@@ -1503,16 +1441,14 @@ int save_ust_context_generic(struct config_writer *writer,
        LTTNG_ASSERT(ctx);
 
        /* Save context as event_context_type_type */
-       context_type_string = get_ust_context_type_string(
-                       ctx->ctx.ctx);
+       context_type_string = get_ust_context_type_string(ctx->ctx.ctx);
        if (!context_type_string) {
                ERR("Unsupported UST context type.");
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-                       config_element_type, context_type_string);
+       ret = config_writer_write_element_string(writer, config_element_type, context_type_string);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1524,9 +1460,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_context(struct config_writer *writer,
-       struct cds_list_head *ctx_list)
+static int save_ust_context(struct config_writer *writer, struct cds_list_head *ctx_list)
 {
        int ret;
        struct ltt_ust_context *ctx;
@@ -1540,9 +1474,8 @@ int save_ust_context(struct config_writer *writer,
                goto end;
        }
 
-       cds_list_for_each_entry(ctx, ctx_list, list) {
-               ret = config_writer_open_element(writer,
-                       config_element_context);
+       cds_list_for_each_entry (ctx, ctx_list, list) {
+               ret = config_writer_open_element(writer, config_element_context);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -1584,9 +1517,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_channel(struct config_writer *writer,
-       struct ltt_kernel_channel *kchan)
+static int save_kernel_channel(struct config_writer *writer, struct ltt_kernel_channel *kchan)
 {
        int ret;
 
@@ -1599,15 +1530,14 @@ int save_kernel_channel(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer, config_element_name,
-               kchan->channel->name);
+       ret = config_writer_write_element_string(writer, config_element_name, kchan->channel->name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_bool(writer, config_element_enabled,
-               kchan->channel->enabled);
+       ret = config_writer_write_element_bool(
+               writer, config_element_enabled, kchan->channel->enabled);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1641,10 +1571,9 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_channel(struct config_writer *writer,
-       struct ltt_ust_channel *ust_chan,
-       struct ltt_ust_session *session)
+static int save_ust_channel(struct config_writer *writer,
+                           struct ltt_ust_channel *ust_chan,
+                           struct ltt_ust_session *session)
 {
        int ret;
 
@@ -1658,15 +1587,13 @@ int save_ust_channel(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer, config_element_name,
-               ust_chan->name);
+       ret = config_writer_write_element_string(writer, config_element_name, ust_chan->name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_bool(writer, config_element_enabled,
-               ust_chan->enabled);
+       ret = config_writer_write_element_bool(writer, config_element_enabled, ust_chan->enabled);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1677,23 +1604,22 @@ int save_ust_channel(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_tracefile_size, ust_chan->tracefile_size);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_tracefile_size, ust_chan->tracefile_size);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_tracefile_count, ust_chan->tracefile_count);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_tracefile_count, ust_chan->tracefile_count);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-               config_element_live_timer_interval,
-               session->live_timer_interval);
+       ret = config_writer_write_element_unsigned_int(
+               writer, config_element_live_timer_interval, session->live_timer_interval);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1705,7 +1631,7 @@ int save_ust_channel(struct config_writer *writer,
                        goto end;
                }
        } else {
-               struct agent *agent = NULL;
+               struct agent *agent = nullptr;
 
                agent = trace_ust_find_agent(session, ust_chan->domain);
                if (!agent) {
@@ -1744,9 +1670,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_session(struct config_writer *writer,
-       struct ltt_session *session)
+static int save_kernel_session(struct config_writer *writer, struct ltt_session *session)
 {
        int ret;
        struct ltt_kernel_channel *kchan;
@@ -1754,29 +1678,27 @@ int save_kernel_session(struct config_writer *writer,
        LTTNG_ASSERT(writer);
        LTTNG_ASSERT(session);
 
-       ret = config_writer_write_element_string(writer, config_element_type,
-               config_domain_type_kernel);
+       ret = config_writer_write_element_string(
+               writer, config_element_type, config_domain_type_kernel);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-               config_element_buffer_type, config_buffer_type_global);
+       ret = config_writer_write_element_string(
+               writer, config_element_buffer_type, config_buffer_type_global);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       ret = config_writer_open_element(writer,
-               config_element_channels);
+       ret = config_writer_open_element(writer, config_element_channels);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       cds_list_for_each_entry(kchan, &session->kernel_session->channel_list.head,
-                       list) {
+       cds_list_for_each_entry (kchan, &session->kernel_session->channel_list.head, list) {
                ret = save_kernel_channel(writer, kchan);
                if (ret != LTTNG_OK) {
                        goto end;
@@ -1795,8 +1717,7 @@ end:
        return ret;
 }
 
-static
-const char *get_config_domain_str(enum lttng_domain_type domain)
+static const char *get_config_domain_str(enum lttng_domain_type domain)
 {
        const char *str_dom;
 
@@ -1825,15 +1746,15 @@ const char *get_config_domain_str(enum lttng_domain_type domain)
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
 static int save_process_attr_tracker(struct config_writer *writer,
-               struct ltt_session *sess,
-               int domain,
-               enum lttng_process_attr process_attr)
+                                    struct ltt_session *sess,
+                                    int domain,
+                                    enum lttng_process_attr process_attr)
 {
        int ret = LTTNG_OK;
        const char *element_id_tracker, *element_target_id, *element_id;
        const struct process_attr_tracker *tracker;
        enum lttng_tracking_policy tracking_policy;
-       struct lttng_process_attr_values *values = NULL;
+       struct lttng_process_attr_values *values = nullptr;
 
        switch (process_attr) {
        case LTTNG_PROCESS_ATTR_PROCESS_ID:
@@ -1874,15 +1795,13 @@ static int save_process_attr_tracker(struct config_writer *writer,
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
        {
-               tracker = kernel_get_process_attr_tracker(
-                               sess->kernel_session, process_attr);
+               tracker = kernel_get_process_attr_tracker(sess->kernel_session, process_attr);
                LTTNG_ASSERT(tracker);
                break;
        }
        case LTTNG_DOMAIN_UST:
        {
-               tracker = trace_ust_get_process_attr_tracker(
-                               sess->ust_session, process_attr);
+               tracker = trace_ust_get_process_attr_tracker(sess->ust_session, process_attr);
                LTTNG_ASSERT(tracker);
                break;
        }
@@ -1907,8 +1826,7 @@ static int save_process_attr_tracker(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_open_element(
-                       writer, config_element_process_attr_values);
+       ret = config_writer_open_element(writer, config_element_process_attr_values);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -1917,8 +1835,7 @@ static int save_process_attr_tracker(struct config_writer *writer,
        if (tracking_policy == LTTNG_TRACKING_POLICY_INCLUDE_SET) {
                unsigned int i, count;
                enum process_attr_tracker_status status =
-                               process_attr_tracker_get_inclusion_set(
-                                               tracker, &values);
+                       process_attr_tracker_get_inclusion_set(tracker, &values);
 
                if (status != PROCESS_ATTR_TRACKER_STATUS_OK) {
                        ret = LTTNG_ERR_NOMEM;
@@ -1929,14 +1846,12 @@ static int save_process_attr_tracker(struct config_writer *writer,
 
                for (i = 0; i < count; i++) {
                        unsigned int integral_value = UINT_MAX;
-                       const char *name = NULL;
+                       const char *name = nullptr;
                        const struct process_attr_value *value =
-                                       lttng_process_attr_tracker_values_get_at_index(
-                                                       values, i);
+                               lttng_process_attr_tracker_values_get_at_index(values, i);
 
                        LTTNG_ASSERT(value);
-                       ret = config_writer_open_element(
-                                       writer, element_target_id);
+                       ret = config_writer_open_element(writer, element_target_id);
                        if (ret) {
                                ret = LTTNG_ERR_SAVE_IO_FAIL;
                                goto end;
@@ -1944,16 +1859,13 @@ static int save_process_attr_tracker(struct config_writer *writer,
 
                        switch (value->type) {
                        case LTTNG_PROCESS_ATTR_VALUE_TYPE_PID:
-                               integral_value =
-                                               (unsigned int) value->value.pid;
+                               integral_value = (unsigned int) value->value.pid;
                                break;
                        case LTTNG_PROCESS_ATTR_VALUE_TYPE_UID:
-                               integral_value =
-                                               (unsigned int) value->value.uid;
+                               integral_value = (unsigned int) value->value.uid;
                                break;
                        case LTTNG_PROCESS_ATTR_VALUE_TYPE_GID:
-                               integral_value =
-                                               (unsigned int) value->value.gid;
+                               integral_value = (unsigned int) value->value.gid;
                                break;
                        case LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME:
                                name = value->value.user_name;
@@ -1968,12 +1880,11 @@ static int save_process_attr_tracker(struct config_writer *writer,
                        }
 
                        if (name) {
-                               ret = config_writer_write_element_string(writer,
-                                               config_element_name, name);
+                               ret = config_writer_write_element_string(
+                                       writer, config_element_name, name);
                        } else {
                                ret = config_writer_write_element_unsigned_int(
-                                               writer, element_id,
-                                               integral_value);
+                                       writer, element_id, integral_value);
                        }
 
                        if (ret) {
@@ -2011,58 +1922,55 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static int save_process_attr_trackers(struct config_writer *writer,
-               struct ltt_session *sess,
-               int domain)
+static int
+save_process_attr_trackers(struct config_writer *writer, struct ltt_session *sess, int domain)
 {
        int ret;
 
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_PROCESS_ID);
+               ret = save_process_attr_tracker(
+                       writer, sess, domain, LTTNG_PROCESS_ATTR_PROCESS_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+               ret = save_process_attr_tracker(
+                       writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_USER_ID);
+               ret = save_process_attr_tracker(writer, sess, domain, LTTNG_PROCESS_ATTR_USER_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+               ret = save_process_attr_tracker(
+                       writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_GROUP_ID);
+               ret = save_process_attr_tracker(writer, sess, domain, LTTNG_PROCESS_ATTR_GROUP_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+               ret = save_process_attr_tracker(
+                       writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
                break;
        case LTTNG_DOMAIN_UST:
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+               ret = save_process_attr_tracker(
+                       writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+               ret = save_process_attr_tracker(
+                       writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
-               ret = save_process_attr_tracker(writer, sess, domain,
-                               LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+               ret = save_process_attr_tracker(
+                       writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
                if (ret != LTTNG_OK) {
                        goto end;
                }
@@ -2077,9 +1985,9 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_domain(struct config_writer *writer,
-       struct ltt_session *session, enum lttng_domain_type domain)
+static int save_ust_domain(struct config_writer *writer,
+                          struct ltt_session *session,
+                          enum lttng_domain_type domain)
 {
        int ret;
        struct ltt_ust_channel *ust_chan;
@@ -2091,8 +1999,7 @@ int save_ust_domain(struct config_writer *writer,
        LTTNG_ASSERT(writer);
        LTTNG_ASSERT(session);
 
-       ret = config_writer_open_element(writer,
-                       config_element_domain);
+       ret = config_writer_open_element(writer, config_element_domain);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -2104,23 +2011,21 @@ int save_ust_domain(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-                       config_element_type, config_domain_name);
+       ret = config_writer_write_element_string(writer, config_element_type, config_domain_name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       buffer_type_string = get_buffer_type_string(
-                       session->ust_session->buffer_type);
+       buffer_type_string = get_buffer_type_string(session->ust_session->buffer_type);
        if (!buffer_type_string) {
                ERR("Unsupported buffer type.");
                ret = LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer,
-                       config_element_buffer_type, buffer_type_string);
+       ret = config_writer_write_element_string(
+               writer, config_element_buffer_type, buffer_type_string);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -2132,19 +2037,20 @@ int save_ust_domain(struct config_writer *writer,
                goto end;
        }
 
-       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);
-               if (domain == ust_chan->domain) {
-                       ret = save_ust_channel(writer, ust_chan, session->ust_session);
-                       if (ret != LTTNG_OK) {
-                               rcu_read_unlock();
-                               goto end;
+       {
+               lttng::urcu::read_lock_guard read_lock;
+
+               cds_lfht_for_each_entry (
+                       session->ust_session->domain_global.channels->ht, &iter.iter, node, node) {
+                       ust_chan = lttng::utils::container_of(node, &ltt_ust_channel::node);
+                       if (domain == ust_chan->domain) {
+                               ret = save_ust_channel(writer, ust_chan, session->ust_session);
+                               if (ret != LTTNG_OK) {
+                                       goto end;
+                               }
                        }
                }
        }
-       rcu_read_unlock();
 
        /* /channels */
        ret = config_writer_close_element(writer);
@@ -2154,15 +2060,13 @@ int save_ust_domain(struct config_writer *writer,
        }
 
        if (domain == LTTNG_DOMAIN_UST) {
-               ret = config_writer_open_element(
-                               writer, config_element_process_attr_trackers);
+               ret = config_writer_open_element(writer, config_element_process_attr_trackers);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
 
-               ret = save_process_attr_trackers(
-                               writer, session, LTTNG_DOMAIN_UST);
+               ret = save_process_attr_trackers(writer, session, LTTNG_DOMAIN_UST);
                if (ret != LTTNG_OK) {
                        goto end;
                }
@@ -2188,8 +2092,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_domains(struct config_writer *writer, struct ltt_session *session)
+static int save_domains(struct config_writer *writer, struct ltt_session *session)
 {
        int ret = LTTNG_OK;
 
@@ -2207,8 +2110,7 @@ int save_domains(struct config_writer *writer, struct ltt_session *session)
        }
 
        if (session->kernel_session) {
-               ret = config_writer_open_element(writer,
-                       config_element_domain);
+               ret = config_writer_open_element(writer, config_element_domain);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -2219,15 +2121,13 @@ int save_domains(struct config_writer *writer, struct ltt_session *session)
                        goto end;
                }
 
-               ret = config_writer_open_element(
-                               writer, config_element_process_attr_trackers);
+               ret = config_writer_open_element(writer, config_element_process_attr_trackers);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
 
-               ret = save_process_attr_trackers(
-                               writer, session, LTTNG_DOMAIN_KERNEL);
+               ret = save_process_attr_trackers(writer, session, LTTNG_DOMAIN_KERNEL);
                if (ret != LTTNG_OK) {
                        goto end;
                }
@@ -2281,9 +2181,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_consumer_output(struct config_writer *writer,
-       struct consumer_output *output)
+static int save_consumer_output(struct config_writer *writer, struct consumer_output *output)
 {
        int ret;
 
@@ -2296,8 +2194,7 @@ int save_consumer_output(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_bool(writer, config_element_enabled,
-                       output->enabled);
+       ret = config_writer_write_element_bool(writer, config_element_enabled, output->enabled);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
@@ -2311,8 +2208,8 @@ int save_consumer_output(struct config_writer *writer,
 
        switch (output->type) {
        case CONSUMER_DST_LOCAL:
-               ret = config_writer_write_element_string(writer,
-                       config_element_path, output->dst.session_root_path);
+               ret = config_writer_write_element_string(
+                       writer, config_element_path, output->dst.session_root_path);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -2322,7 +2219,7 @@ int save_consumer_output(struct config_writer *writer,
        {
                char *uri;
 
-               uri = (char *) zmalloc(PATH_MAX);
+               uri = calloc<char>(PATH_MAX);
                if (!uri) {
                        ret = LTTNG_ERR_NOMEM;
                        goto end;
@@ -2334,16 +2231,15 @@ int save_consumer_output(struct config_writer *writer,
                        goto end_net_output;
                }
 
-               if (output->dst.net.control_isset &&
-                       output->dst.net.data_isset) {
+               if (output->dst.net.control_isset && output->dst.net.data_isset) {
                        ret = uri_to_str_url(&output->dst.net.control, uri, PATH_MAX);
                        if (ret < 0) {
                                ret = LTTNG_ERR_INVALID;
                                goto end_net_output;
                        }
 
-                       ret = config_writer_write_element_string(writer,
-                                       config_element_control_uri, uri);
+                       ret = config_writer_write_element_string(
+                               writer, config_element_control_uri, uri);
                        if (ret) {
                                ret = LTTNG_ERR_SAVE_IO_FAIL;
                                goto end_net_output;
@@ -2355,22 +2251,21 @@ int save_consumer_output(struct config_writer *writer,
                                goto end_net_output;
                        }
 
-                       ret = config_writer_write_element_string(writer,
-                                       config_element_data_uri, uri);
+                       ret = config_writer_write_element_string(
+                               writer, config_element_data_uri, uri);
                        if (ret) {
                                ret = LTTNG_ERR_SAVE_IO_FAIL;
                                goto end_net_output;
                        }
                        ret = LTTNG_OK;
-end_net_output:
+               end_net_output:
                        free(uri);
                        if (ret != LTTNG_OK) {
                                goto end;
                        }
                } else {
-                       ret = !output->dst.net.control_isset ?
-                               LTTNG_ERR_URL_CTRL_MISS :
-                               LTTNG_ERR_URL_DATA_MISS;
+                       ret = !output->dst.net.control_isset ? LTTNG_ERR_URL_CTRL_MISS :
+                                                              LTTNG_ERR_URL_DATA_MISS;
                        free(uri);
                        goto end;
                }
@@ -2408,9 +2303,7 @@ end:
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_snapshot_outputs(struct config_writer *writer,
-       struct snapshot *snapshot)
+static int save_snapshot_outputs(struct config_writer *writer, struct snapshot *snapshot)
 {
        int ret;
        struct lttng_ht_iter iter;
@@ -2425,43 +2318,43 @@ int save_snapshot_outputs(struct config_writer *writer,
                goto end;
        }
 
-       rcu_read_lock();
-       cds_lfht_for_each_entry(snapshot->output_ht->ht, &iter.iter, output,
-                       node.node) {
-               ret = config_writer_open_element(writer,
-                       config_element_output);
-               if (ret) {
-                       ret = LTTNG_ERR_SAVE_IO_FAIL;
-                       goto end_unlock;
-               }
+       {
+               lttng::urcu::read_lock_guard read_lock;
 
-               ret = config_writer_write_element_string(writer,
-                       config_element_name, output->name);
-               if (ret) {
-                       ret = LTTNG_ERR_SAVE_IO_FAIL;
-                       goto end_unlock;
-               }
+               cds_lfht_for_each_entry (snapshot->output_ht->ht, &iter.iter, output, node.node) {
+                       ret = config_writer_open_element(writer, config_element_output);
+                       if (ret) {
+                               ret = LTTNG_ERR_SAVE_IO_FAIL;
+                               goto end_unlock;
+                       }
 
-               ret = config_writer_write_element_unsigned_int(writer,
-                       config_element_max_size, output->max_size);
-               if (ret) {
-                       ret = LTTNG_ERR_SAVE_IO_FAIL;
-                       goto end_unlock;
-               }
+                       ret = config_writer_write_element_string(
+                               writer, config_element_name, output->name);
+                       if (ret) {
+                               ret = LTTNG_ERR_SAVE_IO_FAIL;
+                               goto end_unlock;
+                       }
 
-               ret = save_consumer_output(writer, output->consumer);
-               if (ret != LTTNG_OK) {
-                       goto end_unlock;
-               }
+                       ret = config_writer_write_element_unsigned_int(
+                               writer, config_element_max_size, output->max_size);
+                       if (ret) {
+                               ret = LTTNG_ERR_SAVE_IO_FAIL;
+                               goto end_unlock;
+                       }
 
-               /* /output */
-               ret = config_writer_close_element(writer);
-               if (ret) {
-                       ret = LTTNG_ERR_SAVE_IO_FAIL;
-                       goto end_unlock;
+                       ret = save_consumer_output(writer, output->consumer);
+                       if (ret != LTTNG_OK) {
+                               goto end_unlock;
+                       }
+
+                       /* /output */
+                       ret = config_writer_close_element(writer);
+                       if (ret) {
+                               ret = LTTNG_ERR_SAVE_IO_FAIL;
+                               goto end_unlock;
+                       }
                }
        }
-       rcu_read_unlock();
 
        /* /snapshot_outputs */
        ret = config_writer_close_element(writer);
@@ -2474,14 +2367,11 @@ int save_snapshot_outputs(struct config_writer *writer,
 end:
        return ret;
 end_unlock:
-       rcu_read_unlock();
        return ret;
 }
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_session_output(struct config_writer *writer,
-       struct ltt_session *session)
+static int save_session_output(struct config_writer *writer, struct ltt_session *session)
 {
        int ret;
 
@@ -2489,7 +2379,7 @@ int save_session_output(struct config_writer *writer,
        LTTNG_ASSERT(session);
 
        if ((session->snapshot_mode && session->snapshot.nb_output == 0) ||
-               (!session->snapshot_mode && !session->consumer)) {
+           (!session->snapshot_mode && !session->consumer)) {
                /* Session is in no output mode */
                ret = LTTNG_OK;
                goto end;
@@ -2526,9 +2416,9 @@ end:
        return ret;
 }
 
-static
-int save_session_rotation_schedule(struct config_writer *writer,
-               enum lttng_rotation_schedule_type type, uint64_t value)
+static int save_session_rotation_schedule(struct config_writer *writer,
+                                         enum lttng_rotation_schedule_type type,
+                                         uint64_t value)
 {
        int ret = 0;
        const char *element_name;
@@ -2537,11 +2427,11 @@ int save_session_rotation_schedule(struct config_writer *writer,
        switch (type) {
        case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
                element_name = config_element_rotation_schedule_periodic;
-               value_name = config_element_rotation_schedule_periodic_time_us;
+               value_name = config_element_rotation_schedule_periodic_time_us;
                break;
        case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
                element_name = config_element_rotation_schedule_size_threshold;
-               value_name = config_element_rotation_schedule_size_threshold_bytes;
+               value_name = config_element_rotation_schedule_size_threshold_bytes;
                break;
        default:
                ret = -1;
@@ -2553,8 +2443,7 @@ int save_session_rotation_schedule(struct config_writer *writer,
                goto end;
        }
 
-       ret = config_writer_write_element_unsigned_int(writer,
-                       value_name, value);
+       ret = config_writer_write_element_unsigned_int(writer, value_name, value);
        if (ret) {
                goto end;
        }
@@ -2568,29 +2457,26 @@ end:
        return ret;
 }
 
-static
-int save_session_rotation_schedules(struct config_writer *writer,
-       struct ltt_session *session)
+static int save_session_rotation_schedules(struct config_writer *writer,
+                                          struct ltt_session *session)
 {
        int ret;
 
-       ret = config_writer_open_element(writer,
-                       config_element_rotation_schedules);
+       ret = config_writer_open_element(writer, config_element_rotation_schedules);
        if (ret) {
                goto end;
        }
        if (session->rotate_timer_period) {
                ret = save_session_rotation_schedule(writer,
-                               LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC,
-                               session->rotate_timer_period);
+                                                    LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC,
+                                                    session->rotate_timer_period);
                if (ret) {
                        goto close_schedules;
                }
        }
        if (session->rotate_size) {
-               ret = save_session_rotation_schedule(writer,
-                               LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD,
-                               session->rotate_size);
+               ret = save_session_rotation_schedule(
+                       writer, LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD, session->rotate_size);
                if (ret) {
                        goto close_schedules;
                }
@@ -2611,14 +2497,14 @@ end:
  *
  * Return LTTNG_OK on success else a LTTNG_ERR* code.
  */
-static
-int save_session(struct ltt_session *session,
-       struct lttng_save_session_attr *attr, lttng_sock_cred *creds)
+static int save_session(struct ltt_session *session,
+                       struct lttng_save_session_attr *attr,
+                       lttng_sock_cred *creds)
 {
        int ret, fd = -1;
        char config_file_path[LTTNG_PATH_MAX];
        size_t len;
-       struct config_writer *writer = NULL;
+       struct config_writer *writer = nullptr;
        size_t session_name_len;
        const char *provided_path;
        int file_open_flags = O_CREAT | O_WRONLY | O_TRUNC;
@@ -2630,8 +2516,7 @@ int save_session(struct ltt_session *session,
        session_name_len = strlen(session->name);
        memset(config_file_path, 0, sizeof(config_file_path));
 
-       if (!session_access_ok(session,
-               LTTNG_SOCK_GET_UID_CRED(creds)) || session->destroyed) {
+       if (!session_access_ok(session, LTTNG_SOCK_GET_UID_CRED(creds)) || session->destroyed) {
                ret = LTTNG_ERR_EPERM;
                goto end;
        }
@@ -2647,15 +2532,16 @@ int save_session(struct ltt_session *session,
                strncpy(config_file_path, provided_path, sizeof(config_file_path));
        } else {
                ssize_t ret_len;
-               char *home_dir = utils_get_user_home_dir(
-                       LTTNG_SOCK_GET_UID_CRED(creds));
+               char *home_dir = utils_get_user_home_dir(LTTNG_SOCK_GET_UID_CRED(creds));
                if (!home_dir) {
                        ret = LTTNG_ERR_SET_URL;
                        goto end;
                }
 
-               ret_len = snprintf(config_file_path, sizeof(config_file_path),
-                               DEFAULT_SESSION_HOME_CONFIGPATH, home_dir);
+               ret_len = snprintf(config_file_path,
+                                  sizeof(config_file_path),
+                                  DEFAULT_SESSION_HOME_CONFIGPATH,
+                                  home_dir);
                free(home_dir);
                if (ret_len < 0) {
                        PERROR("snprintf save session");
@@ -2669,15 +2555,16 @@ int save_session(struct ltt_session *session,
         * Check the path fits in the config file path dst including the '/'
         * followed by trailing .lttng extension and the NULL terminated string.
         */
-       if ((len + session_name_len + 2 +
-                       sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION))
-                       > sizeof(config_file_path)) {
+       if ((len + session_name_len + 2 + sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION)) >
+           sizeof(config_file_path)) {
                ret = LTTNG_ERR_SET_URL;
                goto end;
        }
 
-       ret = run_as_mkdir_recursive(config_file_path, S_IRWXU | S_IRWXG,
-                       LTTNG_SOCK_GET_UID_CRED(creds), LTTNG_SOCK_GET_GID_CRED(creds));
+       ret = run_as_mkdir_recursive(config_file_path,
+                                    S_IRWXU | S_IRWXG,
+                                    LTTNG_SOCK_GET_UID_CRED(creds),
+                                    LTTNG_SOCK_GET_GID_CRED(creds));
        if (ret) {
                ret = LTTNG_ERR_SET_URL;
                goto end;
@@ -2698,9 +2585,11 @@ int save_session(struct ltt_session *session,
                file_open_flags |= O_EXCL;
        }
 
-       fd = run_as_open(config_file_path, file_open_flags,
-               S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-               LTTNG_SOCK_GET_UID_CRED(creds), LTTNG_SOCK_GET_GID_CRED(creds));
+       fd = run_as_open(config_file_path,
+                        file_open_flags,
+                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+                        LTTNG_SOCK_GET_UID_CRED(creds),
+                        LTTNG_SOCK_GET_GID_CRED(creds));
        if (fd < 0) {
                PERROR("Could not create configuration file");
                switch (errno) {
@@ -2735,17 +2624,15 @@ int save_session(struct ltt_session *session,
                goto end;
        }
 
-       ret = config_writer_write_element_string(writer, config_element_name,
-                       session->name);
+       ret = config_writer_write_element_string(writer, config_element_name, session->name);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
        if (session->shm_path[0] != '\0') {
-               ret = config_writer_write_element_string(writer,
-                               config_element_shared_memory_path,
-                               session->shm_path);
+               ret = config_writer_write_element_string(
+                       writer, config_element_shared_memory_path, session->shm_path);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
@@ -2757,15 +2644,14 @@ int save_session(struct ltt_session *session,
                goto end;
        }
 
-       ret = config_writer_write_element_bool(writer, config_element_started,
-                       session->active);
+       ret = config_writer_write_element_bool(writer, config_element_started, session->active);
        if (ret) {
                ret = LTTNG_ERR_SAVE_IO_FAIL;
                goto end;
        }
 
-       if (session->snapshot_mode || session->live_timer ||
-                       session->rotate_timer_period || session->rotate_size) {
+       if (session->snapshot_mode || session->live_timer || session->rotate_timer_period ||
+           session->rotate_size) {
                ret = config_writer_open_element(writer, config_element_attributes);
                if (ret) {
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
@@ -2773,23 +2659,22 @@ int save_session(struct ltt_session *session,
                }
 
                if (session->snapshot_mode) {
-                       ret = config_writer_write_element_bool(writer,
-                                       config_element_snapshot_mode, 1);
+                       ret = config_writer_write_element_bool(
+                               writer, config_element_snapshot_mode, 1);
                        if (ret) {
                                ret = LTTNG_ERR_SAVE_IO_FAIL;
                                goto end;
                        }
                } else if (session->live_timer) {
-                       ret = config_writer_write_element_unsigned_int(writer,
-                                       config_element_live_timer_interval, session->live_timer);
+                       ret = config_writer_write_element_unsigned_int(
+                               writer, config_element_live_timer_interval, session->live_timer);
                        if (ret) {
                                ret = LTTNG_ERR_SAVE_IO_FAIL;
                                goto end;
                        }
                }
                if (session->rotate_timer_period || session->rotate_size) {
-                       ret = save_session_rotation_schedules(writer,
-                                       session);
+                       ret = save_session_rotation_schedules(writer, session);
                        if (ret) {
                                ret = LTTNG_ERR_SAVE_IO_FAIL;
                                goto end;
@@ -2848,8 +2733,7 @@ end:
        return ret;
 }
 
-int cmd_save_sessions(struct lttng_save_session_attr *attr,
-       lttng_sock_cred *creds)
+int cmd_save_sessions(struct lttng_save_session_attr *attr, lttng_sock_cred *creds)
 {
        int ret;
        const char *session_name;
@@ -2875,7 +2759,7 @@ int cmd_save_sessions(struct lttng_save_session_attr *attr,
        } else {
                struct ltt_session_list *list = session_get_list();
 
-               cds_list_for_each_entry(session, &list->head, list) {
+               cds_list_for_each_entry (session, &list->head, list) {
                        if (!session_get(session)) {
                                continue;
                        }
This page took 0.053789 seconds and 4 git commands to generate.