Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.cpp
index c7fb313f90fb1eedfa0541b1014d8209473fd23e..bbc94828e6c828e7b7a9acbe90080654d714202a 100644 (file)
  */
 
 #define _LGPL_SOURCE
-#include <grp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <common/bytecode/bytecode.h>
-#include <common/align.h>
-#include <common/common.h>
-#include <common/compat/errno.h>
-#include <common/compat/string.h>
-#include <common/defaults.h>
-#include <common/dynamic-array.h>
-#include <common/dynamic-buffer.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/tracker.h>
-#include <common/unix.h>
-#include <common/uri.h>
-#include <common/utils.h>
-#include <lttng/channel-internal.h>
+#include "lttng-ctl-helper.hpp"
+
+#include <common/align.hpp>
+#include <common/bytecode/bytecode.hpp>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/string.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/filter/filter-ast.hpp>
+#include <common/filter/filter-parser.hpp>
+#include <common/filter/memstream.hpp>
+#include <common/make-unique-wrapper.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/tracker.hpp>
+#include <common/unix.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/channel-internal.hpp>
 #include <lttng/destruction-handle.h>
 #include <lttng/endpoint.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-internal.h>
-#include <lttng/health-internal.h>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-internal.hpp>
+#include <lttng/health-internal.hpp>
 #include <lttng/lttng-error.h>
 #include <lttng/lttng.h>
-#include <lttng/session-descriptor-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/session-descriptor-internal.hpp>
+#include <lttng/session-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
 
-#include "lttng-ctl-helper.h"
-#include <common/filter/filter-ast.h>
-#include <common/filter/filter-parser.hpp>
-#include <common/filter/memstream.h>
+#include <grp.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
-#define COPY_DOMAIN_PACKED(dst, src)                           \
-do {                                                           \
-       struct lttng_domain _tmp_domain;                        \
-                                                               \
-       lttng_ctl_copy_lttng_domain(&_tmp_domain, &src);        \
-       dst = _tmp_domain;                                      \
-} while (0)
+#define COPY_DOMAIN_PACKED(dst, src)                               \
+       do {                                                       \
+               struct lttng_domain _tmp_domain;                   \
+                                                                   \
+               lttng_ctl_copy_lttng_domain(&_tmp_domain, &(src)); \
+               (dst) = _tmp_domain;                               \
+       } while (0)
 
 /* Socket to session daemon for communication */
 static int sessiond_socket = -1;
@@ -83,8 +85,7 @@ LTTNG_EXPORT int lttng_opt_mi;
  *
  * If domain is unknown, default domain will be the kernel.
  */
-void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
-               struct lttng_domain *src)
+void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst, struct lttng_domain *src)
 {
        if (src && dst) {
                switch (src->type) {
@@ -117,11 +118,12 @@ static int send_session_msg(struct lttcomm_session_msg *lsm)
                goto end;
        }
 
-       DBG("LSM cmd type: '%s' (%d)", lttcomm_sessiond_command_str((lttcomm_sessiond_command) lsm->cmd_type),
-                       lsm->cmd_type);
+       DBG("LSM cmd type: '%s' (%d)",
+           lttcomm_sessiond_command_str((lttcomm_sessiond_command) lsm->cmd_type),
+           lsm->cmd_type);
 
-       ret = lttcomm_send_creds_unix_sock(sessiond_socket, lsm,
-                       sizeof(struct lttcomm_session_msg));
+       ret = lttcomm_send_creds_unix_sock(
+               sessiond_socket, lsm, sizeof(struct lttcomm_session_msg));
        if (ret < 0) {
                ret = -LTTNG_ERR_FATAL;
        }
@@ -227,15 +229,13 @@ static int recv_payload_sessiond(struct lttng_payload *payload, size_t len)
        int ret;
        const size_t original_payload_size = payload->buffer.size;
 
-       ret = lttng_dynamic_buffer_set_size(
-                       &payload->buffer, payload->buffer.size + len);
+       ret = lttng_dynamic_buffer_set_size(&payload->buffer, payload->buffer.size + len);
        if (ret) {
                ret = -LTTNG_ERR_NOMEM;
                goto end;
        }
 
-       ret = recv_data_sessiond(
-                       payload->buffer.data + original_payload_size, len);
+       ret = recv_data_sessiond(payload->buffer.data + original_payload_size, len);
 end:
        return ret;
 }
@@ -245,7 +245,7 @@ end:
  *
  * If yes return 1, else return -1.
  */
-int lttng_check_tracing_group(void)
+int lttng_check_tracing_group()
 {
        gid_t *grp_list, tracing_gid;
        int grp_list_size, grp_id, i;
@@ -259,14 +259,14 @@ int lttng_check_tracing_group(void)
        }
 
        /* Get number of supplementary group IDs */
-       grp_list_size = getgroups(0, NULL);
+       grp_list_size = getgroups(0, nullptr);
        if (grp_list_size < 0) {
                PERROR("getgroups");
                goto end;
        }
 
        /* Alloc group list of the right size */
-       grp_list = (gid_t *) zmalloc(grp_list_size * sizeof(gid_t));
+       grp_list = calloc<gid_t>(grp_list_size);
        if (!grp_list) {
                PERROR("malloc");
                goto end;
@@ -291,8 +291,7 @@ end:
        return ret;
 }
 
-static enum lttng_error_code check_enough_available_memory(
-               uint64_t num_bytes_requested_per_cpu)
+static enum lttng_error_code check_enough_available_memory(uint64_t num_bytes_requested_per_cpu)
 {
        int ret;
        enum lttng_error_code ret_code;
@@ -316,8 +315,7 @@ static enum lttng_error_code check_enough_available_memory(
                goto end;
        }
 
-       num_bytes_requested_total =
-                       num_bytes_requested_per_cpu * (uint64_t) num_cpu;
+       num_bytes_requested_total = num_bytes_requested_per_cpu * (uint64_t) num_cpu;
 
        /*
         * Try to get the `MemAvail` field of `/proc/meminfo`. This is the most
@@ -393,9 +391,9 @@ error:
  * Returns 0 on success, negative value on failure (the sessiond socket path
  * is somehow too long or ENOMEM).
  */
-static int set_session_daemon_path(void)
+static int set_session_daemon_path()
 {
-       int in_tgroup = 0;      /* In tracing group. */
+       int in_tgroup = 0; /* In tracing group. */
        uid_t uid;
 
        uid = getuid();
@@ -407,8 +405,8 @@ static int set_session_daemon_path(void)
 
        if ((uid == 0) || in_tgroup == 1) {
                const int ret = lttng_strncpy(sessiond_sock_path,
-                               DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
-                               sizeof(sessiond_sock_path));
+                                             DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
+                                             sizeof(sessiond_sock_path));
 
                if (ret) {
                        goto error;
@@ -434,8 +432,10 @@ static int set_session_daemon_path(void)
                 * With GNU C >= 2.1, snprintf returns the required size
                 * (excluding closing null)
                 */
-               ret = snprintf(sessiond_sock_path, sizeof(sessiond_sock_path),
-                               DEFAULT_HOME_CLIENT_UNIX_SOCK, utils_get_home_dir());
+               ret = snprintf(sessiond_sock_path,
+                              sizeof(sessiond_sock_path),
+                              DEFAULT_HOME_CLIENT_UNIX_SOCK,
+                              utils_get_home_dir());
                if ((ret < 0) || (ret >= sizeof(sessiond_sock_path))) {
                        goto error;
                }
@@ -452,7 +452,7 @@ error:
  *
  * On success, return the socket's file descriptor. On error, return -1.
  */
-int connect_sessiond(void)
+int connect_sessiond()
 {
        int ret;
 
@@ -473,7 +473,7 @@ error:
        return -1;
 }
 
-static void reset_global_sessiond_connection_state(void)
+static void reset_global_sessiond_connection_state()
 {
        sessiond_socket = -1;
        connected = 0;
@@ -484,7 +484,7 @@ static void reset_global_sessiond_connection_state(void)
  *
  *  On success, return 0. On error, return -1.
  */
-static int disconnect_sessiond(void)
+static int disconnect_sessiond()
 {
        int ret = 0;
 
@@ -496,11 +496,10 @@ static int disconnect_sessiond(void)
        return ret;
 }
 
-static int recv_sessiond_optional_data(size_t len, void **user_buf,
-       size_t *user_len)
+static int recv_sessiond_optional_data(size_t len, void **user_buf, size_t *user_len)
 {
        int ret = 0;
-       void *buf = NULL;
+       char *buf = nullptr;
 
        if (len) {
                if (!user_len) {
@@ -508,7 +507,7 @@ static int recv_sessiond_optional_data(size_t len, void **user_buf,
                        goto end;
                }
 
-               buf = zmalloc(len);
+               buf = zmalloc<char>(len);
                if (!buf) {
                        ret = -ENOMEM;
                        goto end;
@@ -526,7 +525,7 @@ static int recv_sessiond_optional_data(size_t len, void **user_buf,
 
                /* Move ownership of command header buffer to user. */
                *user_buf = buf;
-               buf = NULL;
+               buf = nullptr;
                *user_len = len;
        } else {
                /* No command header. */
@@ -535,7 +534,7 @@ static int recv_sessiond_optional_data(size_t len, void **user_buf,
                }
 
                if (user_buf) {
-                       *user_buf = NULL;
+                       *user_buf = nullptr;
                }
        }
 
@@ -552,9 +551,13 @@ end:
  * Return size of data (only payload, not header) or a negative error code.
  */
 int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
-               const int *fds, size_t nb_fd, const void *vardata,
-               size_t vardata_len, void **user_payload_buf,
-               void **user_cmd_header_buf, size_t *user_cmd_header_len)
+                                     const int *fds,
+                                     size_t nb_fd,
+                                     const void *vardata,
+                                     size_t vardata_len,
+                                     void **user_payload_buf,
+                                     void **user_cmd_header_buf,
+                                     size_t *user_cmd_header_len)
 {
        int ret;
        size_t payload_len;
@@ -602,15 +605,14 @@ int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
        }
 
        /* Get command header from data transmission */
-       ret = recv_sessiond_optional_data(llm.cmd_header_size,
-               user_cmd_header_buf, user_cmd_header_len);
+       ret = recv_sessiond_optional_data(
+               llm.cmd_header_size, user_cmd_header_buf, user_cmd_header_len);
        if (ret < 0) {
                goto end;
        }
 
        /* Get payload from data transmission */
-       ret = recv_sessiond_optional_data(llm.data_size, user_payload_buf,
-               &payload_len);
+       ret = recv_sessiond_optional_data(llm.data_size, user_payload_buf, &payload_len);
        if (ret < 0) {
                goto end;
        }
@@ -622,8 +624,7 @@ end:
        return ret;
 }
 
-int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
-       struct lttng_payload *reply)
+int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message, struct lttng_payload *reply)
 {
        int ret;
        struct lttcomm_lttng_msg llm;
@@ -642,16 +643,15 @@ int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
        }
 
        /* Send command to session daemon */
-       ret = lttcomm_send_creds_unix_sock(sessiond_socket, message->buffer.data,
-                       message->buffer.size);
+       ret = lttcomm_send_creds_unix_sock(
+               sessiond_socket, message->buffer.data, message->buffer.size);
        if (ret < 0) {
                ret = -LTTNG_ERR_FATAL;
                goto end;
        }
 
        if (fd_count > 0) {
-               ret = lttcomm_send_payload_view_fds_unix_sock(sessiond_socket,
-                               message);
+               ret = lttcomm_send_payload_view_fds_unix_sock(sessiond_socket, message);
                if (ret < 0) {
                        ret = -LTTNG_ERR_FATAL;
                        goto end;
@@ -694,18 +694,17 @@ int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
        }
 
        if (llm.fd_count > 0) {
-               ret = lttcomm_recv_payload_fds_unix_sock(
-                               sessiond_socket, llm.fd_count, reply);
+               ret = lttcomm_recv_payload_fds_unix_sock(sessiond_socket, llm.fd_count, reply);
                if (ret < 0) {
                        goto end;
                }
        }
 
        /* Don't return the llm header to the caller. */
-       memmove(reply->buffer.data, reply->buffer.data + sizeof(llm),
-                       reply->buffer.size - sizeof(llm));
-       ret = lttng_dynamic_buffer_set_size(
-                       &reply->buffer, reply->buffer.size - sizeof(llm));
+       memmove(reply->buffer.data,
+               reply->buffer.data + sizeof(llm),
+               reply->buffer.size - sizeof(llm));
+       ret = lttng_dynamic_buffer_set_size(&reply->buffer, reply->buffer.size - sizeof(llm));
        if (ret) {
                /* Can't happen as size is reduced. */
                abort();
@@ -723,21 +722,19 @@ end:
  *
  * The returned pointer will be NULL in case of malloc() error.
  */
-struct lttng_handle *lttng_create_handle(const char *session_name,
-               struct lttng_domain *domain)
+struct lttng_handle *lttng_create_handle(const char *session_name, struct lttng_domain *domain)
 {
        int ret;
-       struct lttng_handle *handle = NULL;
+       struct lttng_handle *handle = nullptr;
 
-       handle = (lttng_handle *) zmalloc(sizeof(struct lttng_handle));
-       if (handle == NULL) {
+       handle = zmalloc<lttng_handle>();
+       if (handle == nullptr) {
                PERROR("malloc handle");
                goto end;
        }
 
        /* Copy session name */
-       ret = lttng_strncpy(handle->session_name, session_name ? : "",
-                           sizeof(handle->session_name));
+       ret = lttng_strncpy(handle->session_name, session_name ?: "", sizeof(handle->session_name));
        if (ret) {
                goto error;
        }
@@ -751,7 +748,7 @@ end:
        return handle;
 error:
        free(handle);
-       return NULL;
+       return nullptr;
 }
 
 /*
@@ -767,21 +764,19 @@ void lttng_destroy_handle(struct lttng_handle *handle)
  *
  * Returns size of returned session payload data or a negative error code.
  */
-int lttng_register_consumer(struct lttng_handle *handle,
-               const char *socket_path)
+int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path)
 {
        int ret;
        struct lttcomm_session_msg lsm;
 
-       if (handle == NULL || socket_path == NULL) {
+       if (handle == nullptr || socket_path == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_REGISTER_CONSUMER;
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                       sizeof(lsm.session.name));
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_REGISTER_CONSUMER;
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -789,14 +784,13 @@ int lttng_register_consumer(struct lttng_handle *handle,
 
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
 
-       ret = lttng_strncpy(lsm.u.reg.path, socket_path,
-                           sizeof(lsm.u.reg.path));
+       ret = lttng_strncpy(lsm.u.reg.path, socket_path, sizeof(lsm.u.reg.path));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+       ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
 end:
        return ret;
 }
@@ -811,22 +805,21 @@ int lttng_start_tracing(const char *session_name)
        int ret;
        struct lttcomm_session_msg lsm;
 
-       if (session_name == NULL) {
+       if (session_name == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_START_TRACE;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_START_TRACE;
 
-       ret = lttng_strncpy(lsm.session.name, session_name,
-                           sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+       ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
 end:
        return ret;
 }
@@ -839,22 +832,21 @@ static int _lttng_stop_tracing(const char *session_name, int wait)
        int ret, data_ret;
        struct lttcomm_session_msg lsm;
 
-       if (session_name == NULL) {
+       if (session_name == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_STOP_TRACE;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_STOP_TRACE;
 
-       ret = lttng_strncpy(lsm.session.name, session_name,
-                           sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
-       ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+       ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
        if (ret < 0 && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) {
                goto error;
        }
@@ -911,17 +903,24 @@ int lttng_stop_tracing_no_wait(const char *session_name)
  * Returns the size of the returned payload data or a negative error code.
  */
 int lttng_add_context(struct lttng_handle *handle,
-               struct lttng_event_context *ctx, const char *event_name,
-               const char *channel_name)
+                     struct lttng_event_context *ctx,
+                     const char *event_name __attribute__((unused)),
+                     const char *channel_name)
 {
        int ret;
-       struct lttcomm_session_msg lsm = { .cmd_type = LTTNG_ADD_CONTEXT };
+       struct lttcomm_session_msg lsm = {
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_ADD_CONTEXT,
+               .session = {},
+               .domain = {},
+               .u = {},
+               .fd_count = 0,
+       };
        struct lttng_payload payload;
 
        lttng_payload_init(&payload);
 
        /* Safety check. Both are mandatory. */
-       if (handle == NULL || ctx == NULL) {
+       if (handle == nullptr || ctx == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
@@ -933,16 +932,15 @@ int lttng_add_context(struct lttng_handle *handle,
        }
 
        /* If no channel name, send empty string. */
-       ret = lttng_strncpy(lsm.u.context.channel_name, channel_name ?: "",
-                       sizeof(lsm.u.context.channel_name));
+       ret = lttng_strncpy(
+               lsm.u.context.channel_name, channel_name ?: "", sizeof(lsm.u.context.channel_name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -962,8 +960,7 @@ int lttng_add_context(struct lttng_handle *handle,
        {
                struct lttng_payload reply;
                struct lttng_payload_view payload_view =
-                               lttng_payload_view_from_payload(&payload, 0,
-                               -1);
+                       lttng_payload_view_from_payload(&payload, 0, -1);
 
                lttng_payload_init(&reply);
                ret = lttng_ctl_ask_sessiond_payload(&payload_view, &reply);
@@ -987,10 +984,10 @@ end:
  * Returns size of returned session payload data or a negative error code.
  */
 int lttng_enable_event(struct lttng_handle *handle,
-               struct lttng_event *ev, const char *channel_name)
+                      struct lttng_event *ev,
+                      const char *channel_name)
 {
-       return lttng_enable_event_with_exclusions(handle, ev, channel_name,
-                       NULL, 0, NULL);
+       return lttng_enable_event_with_exclusions(handle, ev, channel_name, nullptr, 0, nullptr);
 }
 
 /*
@@ -1000,11 +997,12 @@ int lttng_enable_event(struct lttng_handle *handle,
  * Return size of returned session payload data if OK.
  */
 int lttng_enable_event_with_filter(struct lttng_handle *handle,
-               struct lttng_event *event, const char *channel_name,
-               const char *filter_expression)
+                                  struct lttng_event *event,
+                                  const char *channel_name,
+                                  const char *filter_expression)
 {
-       return lttng_enable_event_with_exclusions(handle, event, channel_name,
-                       filter_expression, 0, NULL);
+       return lttng_enable_event_with_exclusions(
+               handle, event, channel_name, filter_expression, 0, nullptr);
 }
 
 /*
@@ -1016,15 +1014,15 @@ int lttng_enable_event_with_filter(struct lttng_handle *handle,
 static char *set_agent_filter(const char *filter, struct lttng_event *ev)
 {
        int err;
-       char *agent_filter = NULL;
+       char *agent_filter = nullptr;
 
        LTTNG_ASSERT(ev);
 
        /* Don't add filter for the '*' event. */
        if (strcmp(ev->name, "*") != 0) {
                if (filter) {
-                       err = asprintf(&agent_filter, "(%s) && (logger_name == \"%s\")", filter,
-                                       ev->name);
+                       err = asprintf(
+                               &agent_filter, "(%s) && (logger_name == \"%s\")", filter, ev->name);
                } else {
                        err = asprintf(&agent_filter, "logger_name == \"%s\"", ev->name);
                }
@@ -1047,16 +1045,17 @@ static char *set_agent_filter(const char *filter, struct lttng_event *ev)
                if (filter || agent_filter) {
                        char *new_filter;
 
-                       err = asprintf(&new_filter, "(%s) && (int_loglevel %s %d)",
-                                       agent_filter ? agent_filter : filter, op,
-                                       ev->loglevel);
+                       err = asprintf(&new_filter,
+                                      "(%s) && (int_loglevel %s %d)",
+                                      agent_filter ? agent_filter : filter,
+                                      op,
+                                      ev->loglevel);
                        if (agent_filter) {
                                free(agent_filter);
                        }
                        agent_filter = new_filter;
                } else {
-                       err = asprintf(&agent_filter, "int_loglevel %s %d", op,
-                                       ev->loglevel);
+                       err = asprintf(&agent_filter, "int_loglevel %s %d", op, ev->loglevel);
                }
                if (err < 0) {
                        PERROR("asprintf");
@@ -1067,7 +1066,7 @@ static char *set_agent_filter(const char *filter, struct lttng_event *ev)
        return agent_filter;
 error:
        free(agent_filter);
-       return NULL;
+       return nullptr;
 }
 
 /*
@@ -1079,15 +1078,23 @@ error:
  * Returns size of returned session payload data or a negative error code.
  */
 int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
-               struct lttng_event *ev, const char *channel_name,
-               const char *original_filter_expression,
-               int exclusion_count, char **exclusion_list)
+                                      struct lttng_event *ev,
+                                      const char *channel_name,
+                                      const char *original_filter_expression,
+                                      int exclusion_count,
+                                      char **exclusion_list)
 {
-       struct lttcomm_session_msg lsm = { .cmd_type = LTTNG_ENABLE_EVENT };
+       struct lttcomm_session_msg lsm = {
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_ENABLE_EVENT,
+               .session = {},
+               .domain = {},
+               .u = {},
+               .fd_count = 0,
+       };
        struct lttng_payload payload;
        int ret = 0;
        unsigned int free_filter_expression = 0;
-       struct filter_parser_ctx *ctx = NULL;
+       struct filter_parser_ctx *ctx = nullptr;
        size_t bytecode_len = 0;
 
        /*
@@ -1103,7 +1110,7 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
         */
        char *filter_expression = (char *) original_filter_expression;
 
-       if (handle == NULL || ev == NULL) {
+       if (handle == nullptr || ev == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
@@ -1125,12 +1132,12 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
        }
 
        /* Parse filter expression. */
-       if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL
-                       || handle->domain.type == LTTNG_DOMAIN_LOG4J
-                       || handle->domain.type == LTTNG_DOMAIN_PYTHON) {
+       if (filter_expression != nullptr || handle->domain.type == LTTNG_DOMAIN_JUL ||
+           handle->domain.type == LTTNG_DOMAIN_LOG4J ||
+           handle->domain.type == LTTNG_DOMAIN_PYTHON) {
                if (handle->domain.type == LTTNG_DOMAIN_JUL ||
-                               handle->domain.type == LTTNG_DOMAIN_LOG4J ||
-                               handle->domain.type == LTTNG_DOMAIN_PYTHON) {
+                   handle->domain.type == LTTNG_DOMAIN_LOG4J ||
+                   handle->domain.type == LTTNG_DOMAIN_PYTHON) {
                        char *agent_filter;
 
                        /* Setup agent filter if needed. */
@@ -1154,8 +1161,7 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
                        }
                }
 
-               if (strnlen(filter_expression, LTTNG_FILTER_MAX_LEN) ==
-                               LTTNG_FILTER_MAX_LEN) {
+               if (strnlen(filter_expression, LTTNG_FILTER_MAX_LEN) == LTTNG_FILTER_MAX_LEN) {
                        ret = -LTTNG_ERR_FILTER_INVAL;
                        goto error;
                }
@@ -1165,8 +1171,7 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
                        goto error;
                }
 
-               bytecode_len = bytecode_get_len(&ctx->bytecode->b) +
-                               sizeof(ctx->bytecode->b);
+               bytecode_len = bytecode_get_len(&ctx->bytecode->b) + sizeof(ctx->bytecode->b);
                if (bytecode_len > LTTNG_FILTER_MAX_LEN) {
                        ret = -LTTNG_ERR_FILTER_INVAL;
                        goto error;
@@ -1174,18 +1179,21 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
        }
 
 serialize:
-       ret = lttng_event_serialize(ev, exclusion_count, exclusion_list,
-                       filter_expression, bytecode_len,
-                       (ctx && bytecode_len) ? &ctx->bytecode->b : NULL,
-                       &payload);
+       ret = lttng_event_serialize(ev,
+                                   exclusion_count,
+                                   exclusion_list,
+                                   filter_expression,
+                                   bytecode_len,
+                                   (ctx && bytecode_len) ? &ctx->bytecode->b : nullptr,
+                                   &payload);
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
        /* If no channel name, send empty string. */
-       ret = lttng_strncpy(lsm.u.enable.channel_name, channel_name ?: "",
-                       sizeof(lsm.u.enable.channel_name));
+       ret = lttng_strncpy(
+               lsm.u.enable.channel_name, channel_name ?: "", sizeof(lsm.u.enable.channel_name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
@@ -1195,8 +1203,7 @@ serialize:
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
 
        /* Session name */
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
@@ -1206,8 +1213,7 @@ serialize:
        lsm.u.enable.length = (uint32_t) payload.buffer.size;
 
        {
-               struct lttng_payload_view view = lttng_payload_view_from_payload(
-                       &payload, 0, -1);
+               struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
                int fd_count = lttng_payload_view_get_fd_handle_count(&view);
                int fd_to_send;
 
@@ -1217,8 +1223,7 @@ serialize:
 
                LTTNG_ASSERT(fd_count == 0 || fd_count == 1);
                if (fd_count == 1) {
-                       struct fd_handle *h =
-                                       lttng_payload_view_pop_fd_handle(&view);
+                       struct fd_handle *h = lttng_payload_view_pop_fd_handle(&view);
 
                        if (!h) {
                                goto error;
@@ -1231,9 +1236,14 @@ serialize:
                lsm.fd_count = fd_count;
 
                ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
-                               fd_count ? &fd_to_send : NULL, fd_count,
-                               view.buffer.size ? view.buffer.data : NULL,
-                               view.buffer.size, NULL, NULL, 0);
+                                                       fd_count ? &fd_to_send : nullptr,
+                                                       fd_count,
+                                                       view.buffer.size ? view.buffer.data :
+                                                                          nullptr,
+                                                       view.buffer.size,
+                                                       nullptr,
+                                                       nullptr,
+                                                       nullptr);
        }
 
 error:
@@ -1259,14 +1269,21 @@ error:
 }
 
 int lttng_disable_event_ext(struct lttng_handle *handle,
-               struct lttng_event *ev, const char *channel_name,
-               const char *original_filter_expression)
+                           struct lttng_event *ev,
+                           const char *channel_name,
+                           const char *original_filter_expression)
 {
-       struct lttcomm_session_msg lsm = { .cmd_type = LTTNG_DISABLE_EVENT };
+       struct lttcomm_session_msg lsm = {
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_DISABLE_EVENT,
+               .session = {},
+               .domain = {},
+               .u = {},
+               .fd_count = 0,
+       };
        struct lttng_payload payload;
        int ret = 0;
        unsigned int free_filter_expression = 0;
-       struct filter_parser_ctx *ctx = NULL;
+       struct filter_parser_ctx *ctx = nullptr;
        size_t bytecode_len = 0;
 
        /*
@@ -1282,7 +1299,7 @@ int lttng_disable_event_ext(struct lttng_handle *handle,
         */
        char *filter_expression = (char *) original_filter_expression;
 
-       if (handle == NULL || ev == NULL) {
+       if (handle == nullptr || ev == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
@@ -1298,12 +1315,12 @@ int lttng_disable_event_ext(struct lttng_handle *handle,
        }
 
        /* Parse filter expression. */
-       if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL
-                       || handle->domain.type == LTTNG_DOMAIN_LOG4J
-                       || handle->domain.type == LTTNG_DOMAIN_PYTHON) {
+       if (filter_expression != nullptr || handle->domain.type == LTTNG_DOMAIN_JUL ||
+           handle->domain.type == LTTNG_DOMAIN_LOG4J ||
+           handle->domain.type == LTTNG_DOMAIN_PYTHON) {
                if (handle->domain.type == LTTNG_DOMAIN_JUL ||
-                               handle->domain.type == LTTNG_DOMAIN_LOG4J ||
-                               handle->domain.type == LTTNG_DOMAIN_PYTHON) {
+                   handle->domain.type == LTTNG_DOMAIN_LOG4J ||
+                   handle->domain.type == LTTNG_DOMAIN_PYTHON) {
                        char *agent_filter;
 
                        /* Setup agent filter if needed. */
@@ -1327,8 +1344,7 @@ int lttng_disable_event_ext(struct lttng_handle *handle,
                        }
                }
 
-               if (strnlen(filter_expression, LTTNG_FILTER_MAX_LEN) ==
-                               LTTNG_FILTER_MAX_LEN) {
+               if (strnlen(filter_expression, LTTNG_FILTER_MAX_LEN) == LTTNG_FILTER_MAX_LEN) {
                        ret = -LTTNG_ERR_FILTER_INVAL;
                        goto error;
                }
@@ -1338,8 +1354,7 @@ int lttng_disable_event_ext(struct lttng_handle *handle,
                        goto error;
                }
 
-               bytecode_len = bytecode_get_len(&ctx->bytecode->b) +
-                               sizeof(ctx->bytecode->b);
+               bytecode_len = bytecode_get_len(&ctx->bytecode->b) + sizeof(ctx->bytecode->b);
                if (bytecode_len > LTTNG_FILTER_MAX_LEN) {
                        ret = -LTTNG_ERR_FILTER_INVAL;
                        goto error;
@@ -1347,18 +1362,21 @@ int lttng_disable_event_ext(struct lttng_handle *handle,
        }
 
 serialize:
-       ret = lttng_event_serialize(ev, 0, NULL,
-                       filter_expression, bytecode_len,
-                       (ctx && bytecode_len) ? &ctx->bytecode->b : NULL,
-                       &payload);
+       ret = lttng_event_serialize(ev,
+                                   0,
+                                   nullptr,
+                                   filter_expression,
+                                   bytecode_len,
+                                   (ctx && bytecode_len) ? &ctx->bytecode->b : nullptr,
+                                   &payload);
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
        /* If no channel name, send empty string. */
-       ret = lttng_strncpy(lsm.u.disable.channel_name, channel_name ?: "",
-                       sizeof(lsm.u.disable.channel_name));
+       ret = lttng_strncpy(
+               lsm.u.disable.channel_name, channel_name ?: "", sizeof(lsm.u.disable.channel_name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
@@ -1368,8 +1386,7 @@ serialize:
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
 
        /* Session name */
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
@@ -1379,8 +1396,7 @@ serialize:
        lsm.u.disable.length = (uint32_t) payload.buffer.size;
 
        {
-               struct lttng_payload_view view = lttng_payload_view_from_payload(
-                       &payload, 0, -1);
+               struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
                int fd_count = lttng_payload_view_get_fd_handle_count(&view);
                int fd_to_send;
 
@@ -1390,8 +1406,7 @@ serialize:
 
                LTTNG_ASSERT(fd_count == 0 || fd_count == 1);
                if (fd_count == 1) {
-                       struct fd_handle *h =
-                                       lttng_payload_view_pop_fd_handle(&view);
+                       struct fd_handle *h = lttng_payload_view_pop_fd_handle(&view);
 
                        if (!h) {
                                goto error;
@@ -1402,9 +1417,14 @@ serialize:
                }
 
                ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
-                               fd_count ? &fd_to_send : NULL, fd_count,
-                               view.buffer.size ? view.buffer.data : NULL,
-                               view.buffer.size, NULL, NULL, 0);
+                                                       fd_count ? &fd_to_send : nullptr,
+                                                       fd_count,
+                                                       view.buffer.size ? view.buffer.data :
+                                                                          nullptr,
+                                                       view.buffer.size,
+                                                       nullptr,
+                                                       nullptr,
+                                                       nullptr);
        }
 
 error:
@@ -1435,8 +1455,7 @@ error:
  * If no channel name is specified, the default 'channel0' is used.
  * Returns size of returned session payload data or a negative error code.
  */
-int lttng_disable_event(struct lttng_handle *handle, const char *name,
-               const char *channel_name)
+int lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name)
 {
        int ret;
        struct lttng_event ev;
@@ -1450,14 +1469,14 @@ int lttng_disable_event(struct lttng_handle *handle, const char *name,
                goto end;
        }
 
-       ret = lttng_disable_event_ext(handle, &ev, channel_name, NULL);
+       ret = lttng_disable_event_ext(handle, &ev, channel_name, nullptr);
 end:
        return ret;
 }
 
 struct lttng_channel *lttng_channel_create(struct lttng_domain *domain)
 {
-       struct lttng_channel *channel = NULL;
+       struct lttng_channel *channel = nullptr;
 
        if (!domain) {
                goto end;
@@ -1509,20 +1528,19 @@ void lttng_channel_destroy(struct lttng_channel *channel)
  * Enable channel per domain
  * Returns size of returned session payload data or a negative error code.
  */
-int lttng_enable_channel(struct lttng_handle *handle,
-               struct lttng_channel *in_chan)
+int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *in_chan)
 {
        enum lttng_error_code ret_code;
        int ret;
        struct lttng_dynamic_buffer buffer;
        struct lttcomm_session_msg lsm;
        uint64_t total_buffer_size_needed_per_cpu = 0;
-       struct lttng_channel *channel = NULL;
+       struct lttng_channel *channel = nullptr;
 
        lttng_dynamic_buffer_init(&buffer);
 
        /* NULL arguments are forbidden. No default values. */
-       if (handle == NULL || in_chan == NULL) {
+       if (handle == nullptr || in_chan == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
@@ -1531,17 +1549,14 @@ int lttng_enable_channel(struct lttng_handle *handle,
         * Verify that the amount of memory required to create the requested
         * buffer is available on the system at the moment.
         */
-       if (in_chan->attr.num_subbuf >
-                       UINT64_MAX / in_chan->attr.subbuf_size) {
+       if (in_chan->attr.num_subbuf > UINT64_MAX / in_chan->attr.subbuf_size) {
                /* Overflow */
                ret = -LTTNG_ERR_OVERFLOW;
                goto end;
        }
 
-       total_buffer_size_needed_per_cpu =
-                       in_chan->attr.num_subbuf * in_chan->attr.subbuf_size;
-       ret_code = check_enough_available_memory(
-                       total_buffer_size_needed_per_cpu);
+       total_buffer_size_needed_per_cpu = in_chan->attr.num_subbuf * in_chan->attr.subbuf_size;
+       ret_code = check_enough_available_memory(total_buffer_size_needed_per_cpu);
        if (ret_code != LTTNG_OK) {
                ret = -ret_code;
                goto end;
@@ -1556,27 +1571,24 @@ int lttng_enable_channel(struct lttng_handle *handle,
 
        /* Populate the channel extended attribute if necessary. */
        if (!channel->attr.extended.ptr) {
-               struct lttng_channel_extended *extended =
-                               (struct lttng_channel_extended *) zmalloc(
-                                               sizeof(*extended));
+               struct lttng_channel_extended *extended = zmalloc<lttng_channel_extended>();
 
                if (!extended) {
                        ret = -LTTNG_ERR_NOMEM;
                        goto end;
                }
-               lttng_channel_set_default_extended_attr(
-                               &handle->domain, extended);
+
+               lttng_channel_set_default_extended_attr(&handle->domain, extended);
                channel->attr.extended.ptr = extended;
        }
 
        /* Prepare the payload */
        memset(&lsm, 0, sizeof(lsm));
 
-       lsm.cmd_type = LTTNG_ENABLE_CHANNEL;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_ENABLE_CHANNEL;
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
 
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                                   sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -1590,8 +1602,7 @@ int lttng_enable_channel(struct lttng_handle *handle,
 
        lsm.u.channel.length = buffer.size;
 
-       ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
-                       &lsm, buffer.data, buffer.size, NULL);
+       ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, buffer.data, buffer.size, nullptr);
 end:
        lttng_channel_destroy(channel);
        lttng_dynamic_buffer_reset(&buffer);
@@ -1608,16 +1619,15 @@ int lttng_disable_channel(struct lttng_handle *handle, const char *name)
        struct lttcomm_session_msg lsm;
 
        /* Safety check. Both are mandatory. */
-       if (handle == NULL || name == NULL) {
+       if (handle == nullptr || name == nullptr) {
                return -LTTNG_ERR_INVALID;
        }
 
        memset(&lsm, 0, sizeof(lsm));
 
-       lsm.cmd_type = LTTNG_DISABLE_CHANNEL;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_DISABLE_CHANNEL;
 
-       ret = lttng_strncpy(lsm.u.disable.channel_name, name,
-                       sizeof(lsm.u.disable.channel_name));
+       ret = lttng_strncpy(lsm.u.disable.channel_name, name, sizeof(lsm.u.disable.channel_name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -1625,14 +1635,13 @@ int lttng_disable_channel(struct lttng_handle *handle, const char *name)
 
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
 
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                           sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+       ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
 end:
        return ret;
 }
@@ -1643,55 +1652,63 @@ end:
  * Returns the number of lttng_event entries in events;
  * on error, returns a negative value.
  */
-int lttng_list_tracepoints(struct lttng_handle *handle,
-               struct lttng_event **events)
+int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events)
 {
-        enum lttng_error_code ret_code;
-        int ret, total_payload_received;
-        char *reception_buffer = NULL;
-        struct lttcomm_session_msg lsm = { .cmd_type = LTTNG_LIST_TRACEPOINTS };
-        struct lttcomm_list_command_header *cmd_header = NULL;
-        size_t cmd_header_len;
-        unsigned int nb_events = 0;
+       enum lttng_error_code ret_code;
+       int ret, total_payload_received;
+       char *reception_buffer = nullptr;
+       struct lttcomm_session_msg lsm = {
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_TRACEPOINTS,
+               .session = {},
+               .domain = {},
+               .u = {},
+               .fd_count = 0,
+       };
+       struct lttcomm_list_command_header *cmd_header = nullptr;
+       size_t cmd_header_len;
+       unsigned int nb_events = 0;
 
-        if (handle == NULL) {
-                ret = -LTTNG_ERR_INVALID;
-                goto end;
-        }
+       if (handle == nullptr) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
 
-        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
+       COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
 
-        ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm, NULL, 0, NULL, 0,
-                        (void **) &reception_buffer, (void **) &cmd_header,
-                        &cmd_header_len);
-        if (ret < 0) {
-                goto end;
-        }
+       ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
+                                               nullptr,
+                                               0,
+                                               nullptr,
+                                               0,
+                                               (void **) &reception_buffer,
+                                               (void **) &cmd_header,
+                                               &cmd_header_len);
+       if (ret < 0) {
+               goto end;
+       }
 
-        total_payload_received = ret;
+       total_payload_received = ret;
 
-        if (!cmd_header) {
-                ret = -LTTNG_ERR_UNK;
-                goto end;
-        }
+       if (!cmd_header) {
+               ret = -LTTNG_ERR_UNK;
+               goto end;
+       }
 
-        if (cmd_header->count > INT_MAX) {
-                ret = -LTTNG_ERR_OVERFLOW;
-                goto end;
-        }
+       if (cmd_header->count > INT_MAX) {
+               ret = -LTTNG_ERR_OVERFLOW;
+               goto end;
+       }
 
-        nb_events = (unsigned int) cmd_header->count;
+       nb_events = (unsigned int) cmd_header->count;
 
        {
                struct lttng_buffer_view events_view =
-                               lttng_buffer_view_init(reception_buffer, 0,
-                                               total_payload_received);
+                       lttng_buffer_view_init(reception_buffer, 0, total_payload_received);
                struct lttng_payload_view events_payload_view =
-                               lttng_payload_view_from_buffer_view(
-                                               &events_view, 0, -1);
+                       lttng_payload_view_from_buffer_view(&events_view, 0, -1);
 
                ret_code = lttng_events_create_and_flatten_from_payload(
-                               &events_payload_view, nb_events, events);
+                       &events_payload_view, nb_events, events);
                if (ret_code != LTTNG_OK) {
                        ret = -ret_code;
                        goto end;
@@ -1701,9 +1718,9 @@ int lttng_list_tracepoints(struct lttng_handle *handle,
        ret = (int) nb_events;
 
 end:
-        free(cmd_header);
-        free(reception_buffer);
-        return ret;
+       free(cmd_header);
+       free(reception_buffer);
+       return ret;
 }
 
 /*
@@ -1712,32 +1729,29 @@ end:
  * Returns the number of lttng_event_field entries in events;
  * on error, returns a negative value.
  */
-int lttng_list_tracepoint_fields(struct lttng_handle *handle,
-               struct lttng_event_field **fields)
+int lttng_list_tracepoint_fields(struct lttng_handle *handle, struct lttng_event_field **fields)
 {
        enum lttng_error_code ret_code;
        int ret;
        struct lttcomm_session_msg lsm;
-       const struct lttcomm_list_command_header *cmd_header = NULL;
+       const struct lttcomm_list_command_header *cmd_header = nullptr;
        unsigned int nb_event_fields = 0;
        struct lttng_payload reply;
 
-       if (handle == NULL) {
+       lttng_payload_init(&reply);
+
+       if (handle == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       lttng_payload_init(&reply);
-
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_LIST_TRACEPOINT_FIELDS;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_TRACEPOINT_FIELDS;
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
 
        {
                lttng_payload_view message_view =
-                               lttng_payload_view_init_from_buffer(
-                                       (const char *) &lsm, 0,
-                                       sizeof(lsm));
+                       lttng_payload_view_init_from_buffer((const char *) &lsm, 0, sizeof(lsm));
 
                ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
                if (ret < 0) {
@@ -1746,17 +1760,15 @@ int lttng_list_tracepoint_fields(struct lttng_handle *handle,
        }
 
        {
-               const lttng_buffer_view cmd_header_view =
-                               lttng_buffer_view_from_dynamic_buffer(
-                                       &reply.buffer, 0, sizeof(*cmd_header));
+               const lttng_buffer_view cmd_header_view = lttng_buffer_view_from_dynamic_buffer(
+                       &reply.buffer, 0, sizeof(*cmd_header));
 
                if (!lttng_buffer_view_is_valid(&cmd_header_view)) {
                        ret = -LTTNG_ERR_INVALID_PROTOCOL;
                        goto end;
                }
 
-               cmd_header = (struct lttcomm_list_command_header *)
-                               cmd_header_view.data;
+               cmd_header = (struct lttcomm_list_command_header *) cmd_header_view.data;
        }
 
        if (cmd_header->count > INT_MAX) {
@@ -1768,11 +1780,10 @@ int lttng_list_tracepoint_fields(struct lttng_handle *handle,
 
        {
                lttng_payload_view reply_view =
-                               lttng_payload_view_from_payload(&reply,
-                               sizeof(*cmd_header), -1);
+                       lttng_payload_view_from_payload(&reply, sizeof(*cmd_header), -1);
 
                ret_code = lttng_event_fields_create_and_flatten_from_payload(
-                               &reply_view, nb_event_fields, fields);
+                       &reply_view, nb_event_fields, fields);
                if (ret_code != LTTNG_OK) {
                        ret = -ret_code;
                        goto end;
@@ -1782,6 +1793,7 @@ int lttng_list_tracepoint_fields(struct lttng_handle *handle,
        ret = nb_event_fields;
 
 end:
+       lttng_payload_reset(&reply);
        return ret;
 }
 
@@ -1794,65 +1806,68 @@ end:
  */
 int lttng_list_syscalls(struct lttng_event **events)
 {
-        enum lttng_error_code ret_code;
-        int ret, total_payload_received;
-        char *reception_buffer = NULL;
-        struct lttcomm_session_msg lsm = {};
-        struct lttcomm_list_command_header *cmd_header = NULL;
-        size_t cmd_header_len;
-        uint32_t nb_events = 0;
-
-        if (!events) {
-                ret = -LTTNG_ERR_INVALID;
-                goto end;
-        }
-
-        lsm.cmd_type = LTTNG_LIST_SYSCALLS;
-        /* Force kernel domain for system calls. */
-        lsm.domain.type = LTTNG_DOMAIN_KERNEL;
-
-        ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm, NULL, 0, NULL, 0,
-                        (void **) &reception_buffer, (void **) &cmd_header,
-                        &cmd_header_len);
-        if (ret < 0) {
-                goto end;
-        }
-        total_payload_received = ret;
-
-        if (!cmd_header) {
-                ret = -LTTNG_ERR_UNK;
-                goto end;
-        }
-
-        if (cmd_header->count > INT_MAX) {
-                ret = -LTTNG_ERR_OVERFLOW;
-                goto end;
-        }
-
-        nb_events = (unsigned int) cmd_header->count;
-
-        {
-                const struct lttng_buffer_view events_view =
-                                lttng_buffer_view_init(reception_buffer, 0,
-                                                total_payload_received);
+       enum lttng_error_code ret_code;
+       int ret, total_payload_received;
+       char *reception_buffer = nullptr;
+       struct lttcomm_session_msg lsm = {};
+       struct lttcomm_list_command_header *cmd_header = nullptr;
+       size_t cmd_header_len;
+       uint32_t nb_events = 0;
+
+       if (!events) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_SYSCALLS;
+       /* Force kernel domain for system calls. */
+       lsm.domain.type = LTTNG_DOMAIN_KERNEL;
+
+       ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
+                                               nullptr,
+                                               0,
+                                               nullptr,
+                                               0,
+                                               (void **) &reception_buffer,
+                                               (void **) &cmd_header,
+                                               &cmd_header_len);
+       if (ret < 0) {
+               goto end;
+       }
+       total_payload_received = ret;
+
+       if (!cmd_header) {
+               ret = -LTTNG_ERR_UNK;
+               goto end;
+       }
+
+       if (cmd_header->count > INT_MAX) {
+               ret = -LTTNG_ERR_OVERFLOW;
+               goto end;
+       }
+
+       nb_events = (unsigned int) cmd_header->count;
+
+       {
+               const struct lttng_buffer_view events_view =
+                       lttng_buffer_view_init(reception_buffer, 0, total_payload_received);
                struct lttng_payload_view events_payload_view =
-                               lttng_payload_view_from_buffer_view(
-                                               &events_view, 0, -1);
+                       lttng_payload_view_from_buffer_view(&events_view, 0, -1);
 
-                ret_code = lttng_events_create_and_flatten_from_payload(
-                                &events_payload_view, nb_events, events);
-                if (ret_code != LTTNG_OK) {
-                        ret = -ret_code;
-                        goto end;
-                }
-        }
+               ret_code = lttng_events_create_and_flatten_from_payload(
+                       &events_payload_view, nb_events, events);
+               if (ret_code != LTTNG_OK) {
+                       ret = -ret_code;
+                       goto end;
+               }
+       }
 
-        ret = (int) nb_events;
+       ret = (int) nb_events;
 
 end:
-        free(reception_buffer);
-        free(cmd_header);
-        return ret;
+       free(reception_buffer);
+       free(cmd_header);
+       return ret;
 }
 
 /*
@@ -1868,21 +1883,24 @@ const char *lttng_strerror(int code)
        return error_get_str(code);
 }
 
-enum lttng_error_code lttng_create_session_ext(
-               struct lttng_session_descriptor *session_descriptor)
+enum lttng_error_code lttng_create_session_ext(struct lttng_session_descriptor *session_descriptor)
 {
        enum lttng_error_code ret_code;
        struct lttcomm_session_msg lsm = {
-               .cmd_type = LTTNG_CREATE_SESSION_EXT,
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_CREATE_SESSION_EXT,
+               .session = {},
+               .domain = {},
+               .u = {},
+               .fd_count = 0,
        };
-       void *reply = NULL;
+       void *reply = nullptr;
        struct lttng_buffer_view reply_view;
        int reply_ret;
        bool sessiond_must_generate_ouput;
        struct lttng_dynamic_buffer payload;
        int ret;
        size_t descriptor_size;
-       struct lttng_session_descriptor *descriptor_reply = NULL;
+       struct lttng_session_descriptor *descriptor_reply = nullptr;
 
        lttng_dynamic_buffer_init(&payload);
        if (!session_descriptor) {
@@ -1891,8 +1909,7 @@ enum lttng_error_code lttng_create_session_ext(
        }
 
        sessiond_must_generate_ouput =
-                       !lttng_session_descriptor_is_output_destination_initialized(
-                               session_descriptor);
+               !lttng_session_descriptor_is_output_destination_initialized(session_descriptor);
        if (sessiond_must_generate_ouput) {
                const char *home_dir = utils_get_home_dir();
                size_t home_dir_len = home_dir ? strlen(home_dir) + 1 : 0;
@@ -1903,8 +1920,7 @@ enum lttng_error_code lttng_create_session_ext(
                }
 
                lsm.u.create_session.home_dir_size = (uint16_t) home_dir_len;
-               ret = lttng_dynamic_buffer_append(&payload, home_dir,
-                               home_dir_len);
+               ret = lttng_dynamic_buffer_append(&payload, home_dir, home_dir_len);
                if (ret) {
                        ret_code = LTTNG_ERR_NOMEM;
                        goto end;
@@ -1912,8 +1928,7 @@ enum lttng_error_code lttng_create_session_ext(
        }
 
        descriptor_size = payload.size;
-       ret = lttng_session_descriptor_serialize(session_descriptor,
-                       &payload);
+       ret = lttng_session_descriptor_serialize(session_descriptor, &payload);
        if (ret) {
                ret_code = LTTNG_ERR_INVALID;
                goto end;
@@ -1922,8 +1937,8 @@ enum lttng_error_code lttng_create_session_ext(
        lsm.u.create_session.session_descriptor_size = descriptor_size;
 
        /* Command returns a session descriptor on success. */
-       reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, payload.data,
-                       payload.size, &reply);
+       reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
+               &lsm, payload.data, payload.size, &reply);
        if (reply_ret < 0) {
                ret_code = (lttng_error_code) -reply_ret;
                goto end;
@@ -1934,8 +1949,7 @@ enum lttng_error_code lttng_create_session_ext(
        }
 
        reply_view = lttng_buffer_view_init((const char *) reply, 0, reply_ret);
-       ret = lttng_session_descriptor_create_from_buffer(&reply_view,
-                       &descriptor_reply);
+       ret = lttng_session_descriptor_create_from_buffer(&reply_view, &descriptor_reply);
        if (ret < 0) {
                ret_code = LTTNG_ERR_FATAL;
                goto end;
@@ -1958,8 +1972,8 @@ int lttng_create_session(const char *name, const char *url)
 {
        int ret;
        ssize_t size;
-       struct lttng_uri *uris = NULL;
-       struct lttng_session_descriptor *descriptor = NULL;
+       struct lttng_uri *uris = nullptr;
+       struct lttng_session_descriptor *descriptor = nullptr;
        enum lttng_error_code ret_code;
 
        if (!name) {
@@ -1967,7 +1981,7 @@ int lttng_create_session(const char *name, const char *url)
                goto end;
        }
 
-       size = uri_parse_str_urls(url, NULL, &uris);
+       size = uri_parse_str_urls(url, nullptr, &uris);
        if (size < 0) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -1981,12 +1995,10 @@ int lttng_create_session(const char *name, const char *url)
                        ret = -LTTNG_ERR_INVALID;
                        goto end;
                }
-               descriptor = lttng_session_descriptor_local_create(name,
-                               uris[0].dst.path);
+               descriptor = lttng_session_descriptor_local_create(name, uris[0].dst.path);
                break;
        case 2:
-               descriptor = lttng_session_descriptor_network_create(name, url,
-                               NULL);
+               descriptor = lttng_session_descriptor_network_create(name, url, nullptr);
                break;
        default:
                ret = -LTTNG_ERR_INVALID;
@@ -2014,15 +2026,15 @@ int lttng_create_session_snapshot(const char *name, const char *snapshot_url)
        int ret;
        enum lttng_error_code ret_code;
        ssize_t size;
-       struct lttng_uri *uris = NULL;
-       struct lttng_session_descriptor *descriptor = NULL;
+       struct lttng_uri *uris = nullptr;
+       struct lttng_session_descriptor *descriptor = nullptr;
 
        if (!name) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       size = uri_parse_str_urls(snapshot_url, NULL, &uris);
+       size = uri_parse_str_urls(snapshot_url, nullptr, &uris);
        if (size < 0) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -2030,10 +2042,8 @@ int lttng_create_session_snapshot(const char *name, const char *snapshot_url)
        /*
         * If the user does not specify a custom subdir, use the session name.
         */
-       if (size > 0 && uris[0].dtype != LTTNG_DST_PATH &&
-                       strlen(uris[0].subdir) == 0) {
-               ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s",
-                               name);
+       if (size > 0 && uris[0].dtype != LTTNG_DST_PATH && strlen(uris[0].subdir) == 0) {
+               ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s", name);
                if (ret < 0) {
                        PERROR("Failed to set session name as network destination sub-directory");
                        ret = -LTTNG_ERR_FATAL;
@@ -2054,15 +2064,11 @@ int lttng_create_session_snapshot(const char *name, const char *snapshot_url)
                        ret = -LTTNG_ERR_INVALID;
                        goto end;
                }
-               descriptor = lttng_session_descriptor_snapshot_local_create(
-                               name,
-                               uris[0].dst.path);
+               descriptor = lttng_session_descriptor_snapshot_local_create(name, uris[0].dst.path);
                break;
        case 2:
                descriptor = lttng_session_descriptor_snapshot_network_create(
-                               name,
-                               snapshot_url,
-                               NULL);
+                       name, snapshot_url, nullptr);
                break;
        default:
                ret = -LTTNG_ERR_INVALID;
@@ -2085,12 +2091,11 @@ end:
  *
  * Return 0 on success else a negative LTTng error code.
  */
-int lttng_create_session_live(const char *name, const char *url,
-               unsigned int timer_interval)
+int lttng_create_session_live(const char *name, const char *url, unsigned int timer_interval)
 {
        int ret;
        enum lttng_error_code ret_code;
-       struct lttng_session_descriptor *descriptor = NULL;
+       struct lttng_session_descriptor *descriptor = nullptr;
 
        if (!name) {
                ret = -LTTNG_ERR_INVALID;
@@ -2099,10 +2104,9 @@ int lttng_create_session_live(const char *name, const char *url,
 
        if (url) {
                descriptor = lttng_session_descriptor_live_network_create(
-                               name, url, NULL, timer_interval);
+                       name, url, nullptr, timer_interval);
        } else {
-               descriptor = lttng_session_descriptor_live_create(
-                               name, timer_interval);
+               descriptor = lttng_session_descriptor_live_create(name, timer_interval);
        }
        if (!descriptor) {
                ret = -LTTNG_ERR_INVALID;
@@ -2125,7 +2129,7 @@ int lttng_destroy_session(const char *session_name)
        int ret;
        enum lttng_error_code ret_code;
        enum lttng_destruction_handle_status status;
-       struct lttng_destruction_handle *handle = NULL;
+       struct lttng_destruction_handle *handle = nullptr;
 
        /*
         * Stop the tracing and wait for the data to be
@@ -2168,7 +2172,7 @@ int lttng_destroy_session_no_wait(const char *session_name)
 {
        enum lttng_error_code ret_code;
 
-       ret_code = lttng_destroy_session_ext(session_name, NULL);
+       ret_code = lttng_destroy_session_ext(session_name, nullptr);
        return ret_code == LTTNG_OK ? 0 : -ret_code;
 }
 
@@ -2182,21 +2186,21 @@ int lttng_list_sessions(struct lttng_session **out_sessions)
 {
        int ret;
        struct lttcomm_session_msg lsm;
-       const size_t session_size = sizeof(struct lttng_session) +
-                       sizeof(struct lttng_session_extended);
+       const size_t session_size =
+               sizeof(struct lttng_session) + sizeof(struct lttng_session_extended);
        size_t session_count, i;
        struct lttng_session_extended *sessions_extended_begin;
-       struct lttng_session *sessions = NULL;
+       struct lttng_session *sessions = nullptr;
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_LIST_SESSIONS;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_SESSIONS;
        /*
         * Initialize out_sessions to NULL so it is initialized when
         * lttng_list_sessions returns 0, thus allowing *out_sessions to
         * be subsequently freed.
         */
-       *out_sessions = NULL;
-       ret = lttng_ctl_ask_sessiond(&lsm, (void**) &sessions);
+       *out_sessions = nullptr;
+       ret = lttng_ctl_ask_sessiond(&lsm, (void **) &sessions);
        if (ret <= 0) {
                goto end;
        }
@@ -2211,14 +2215,12 @@ int lttng_list_sessions(struct lttng_session **out_sessions)
                goto end;
        }
        session_count = (size_t) ret / session_size;
-       sessions_extended_begin = (struct lttng_session_extended *)
-                       (&sessions[session_count]);
+       sessions_extended_begin = (struct lttng_session_extended *) (&sessions[session_count]);
 
        /* Set extended session info pointers. */
        for (i = 0; i < session_count; i++) {
                struct lttng_session *session = &sessions[i];
-               struct lttng_session_extended *extended =
-                               &(sessions_extended_begin[i]);
+               struct lttng_session_extended *extended = &(sessions_extended_begin[i]);
 
                session->extended.ptr = extended;
        }
@@ -2229,8 +2231,8 @@ end:
        return ret;
 }
 
-enum lttng_error_code lttng_session_get_creation_time(
-               const struct lttng_session *session, uint64_t *creation_time)
+enum lttng_error_code lttng_session_get_creation_time(const struct lttng_session *session,
+                                                     uint64_t *creation_time)
 {
        enum lttng_error_code ret = LTTNG_OK;
        struct lttng_session_extended *extended;
@@ -2251,34 +2253,32 @@ end:
        return ret;
 }
 
-int lttng_set_session_shm_path(const char *session_name,
-               const char *shm_path)
+int lttng_set_session_shm_path(const char *session_name, const char *shm_path)
 {
        int ret;
        struct lttcomm_session_msg lsm;
 
-       if (session_name == NULL) {
+       if (session_name == nullptr) {
                return -LTTNG_ERR_INVALID;
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_SET_SESSION_SHM_PATH;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SET_SESSION_SHM_PATH;
 
-       ret = lttng_strncpy(lsm.session.name, session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = lttng_strncpy(lsm.u.set_shm_path.shm_path, shm_path ?: "",
-                       sizeof(lsm.u.set_shm_path.shm_path));
+       ret = lttng_strncpy(
+               lsm.u.set_shm_path.shm_path, shm_path ?: "", sizeof(lsm.u.set_shm_path.shm_path));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+       ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
 end:
        return ret;
 }
@@ -2289,28 +2289,26 @@ end:
  * Returns the number of lttng_domain entries in domains;
  * on error, returns a negative value.
  */
-int lttng_list_domains(const char *session_name,
-               struct lttng_domain **domains)
+int lttng_list_domains(const char *session_name, struct lttng_domain **domains)
 {
        int ret;
        struct lttcomm_session_msg lsm;
 
-       if (session_name == NULL) {
+       if (session_name == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_LIST_DOMAINS;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_DOMAINS;
 
-       ret = lttng_strncpy(lsm.session.name, session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
-       ret = lttng_ctl_ask_sessiond(&lsm, (void**) domains);
+       ret = lttng_ctl_ask_sessiond(&lsm, (void **) domains);
        if (ret < 0) {
                goto error;
        }
@@ -2326,27 +2324,25 @@ error:
  * Returns the number of lttng_channel entries in channels;
  * on error, returns a negative value.
  */
-int lttng_list_channels(struct lttng_handle *handle,
-               struct lttng_channel **channels)
+int lttng_list_channels(struct lttng_handle *handle, struct lttng_channel **channels)
 {
        int ret, total_payload_received;
        struct lttcomm_session_msg lsm;
-       char *reception_buffer = NULL;
+       char *reception_buffer = nullptr;
        size_t cmd_header_len = 0;
-       struct lttcomm_list_command_header *cmd_header = NULL;
+       struct lttcomm_list_command_header *cmd_header = nullptr;
        struct lttng_dynamic_buffer tmp_buffer;
 
        lttng_dynamic_buffer_init(&tmp_buffer);
 
-       if (handle == NULL) {
+       if (handle == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_LIST_CHANNELS;
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                       sizeof(lsm.session.name));
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_CHANNELS;
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -2354,9 +2350,14 @@ int lttng_list_channels(struct lttng_handle *handle,
 
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
 
-       ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm, NULL, 0, NULL, 0,
-                       (void **) &reception_buffer, (void **) &cmd_header,
-                       &cmd_header_len);
+       ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
+                                               nullptr,
+                                               0,
+                                               nullptr,
+                                               0,
+                                               (void **) &reception_buffer,
+                                               (void **) &cmd_header,
+                                               &cmd_header_len);
        if (ret < 0) {
                goto end;
        }
@@ -2381,11 +2382,10 @@ int lttng_list_channels(struct lttng_handle *handle,
        {
                enum lttng_error_code ret_code;
                const struct lttng_buffer_view events_view =
-                               lttng_buffer_view_init(reception_buffer, 0,
-                                               total_payload_received);
+                       lttng_buffer_view_init(reception_buffer, 0, total_payload_received);
 
                ret_code = lttng_channels_create_and_flatten_from_buffer(
-                               &events_view, cmd_header->count, channels);
+                       &events_view, cmd_header->count, channels);
                if (ret_code != LTTNG_OK) {
                        ret = -ret_code;
                        goto end;
@@ -2406,35 +2406,33 @@ end:
  * on error, returns a negative value.
  */
 int lttng_list_events(struct lttng_handle *handle,
-               const char *channel_name, struct lttng_event **events)
+                     const char *channel_name,
+                     struct lttng_event **events)
 {
        int ret;
        struct lttcomm_session_msg lsm = {};
        struct lttng_payload reply;
        struct lttng_payload_view lsm_view =
-                       lttng_payload_view_init_from_buffer(
-                               (const char *) &lsm, 0, sizeof(lsm));
+               lttng_payload_view_init_from_buffer((const char *) &lsm, 0, sizeof(lsm));
        unsigned int nb_events = 0;
 
+       lttng_payload_init(&reply);
+
        /* Safety check. An handle and channel name are mandatory. */
-       if (handle == NULL || channel_name == NULL) {
+       if (handle == nullptr || channel_name == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       lttng_payload_init(&reply);
-
        /* Initialize command parameters. */
-       lsm.cmd_type = LTTNG_LIST_EVENTS;
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                       sizeof(lsm.session.name));
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_EVENTS;
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = lttng_strncpy(lsm.u.list.channel_name, channel_name,
-                       sizeof(lsm.u.list.channel_name));
+       ret = lttng_strncpy(lsm.u.list.channel_name, channel_name, sizeof(lsm.u.list.channel_name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -2449,11 +2447,9 @@ int lttng_list_events(struct lttng_handle *handle,
        }
 
        {
-               const struct lttcomm_list_command_header *cmd_reply_header =
-                               NULL;
+               const struct lttcomm_list_command_header *cmd_reply_header = nullptr;
                const lttng_payload_view cmd_reply_header_view =
-                               lttng_payload_view_from_payload(&reply, 0,
-                                               sizeof(*cmd_reply_header));
+                       lttng_payload_view_from_payload(&reply, 0, sizeof(*cmd_reply_header));
 
                if (!lttng_payload_view_is_valid(&cmd_reply_header_view)) {
                        ret = -LTTNG_ERR_INVALID_PROTOCOL;
@@ -2461,8 +2457,7 @@ int lttng_list_events(struct lttng_handle *handle,
                }
 
                cmd_reply_header = (const struct lttcomm_list_command_header *)
-                                                  cmd_reply_header_view.buffer
-                                                                  .data;
+                                          cmd_reply_header_view.buffer.data;
                if (cmd_reply_header->count > INT_MAX) {
                        ret = -LTTNG_ERR_OVERFLOW;
                        goto end;
@@ -2474,11 +2469,10 @@ int lttng_list_events(struct lttng_handle *handle,
        {
                enum lttng_error_code ret_code;
                lttng_payload_view cmd_reply_payload = lttng_payload_view_from_payload(
-                               &reply,
-                               sizeof(struct lttcomm_list_command_header), -1);
+                       &reply, sizeof(struct lttcomm_list_command_header), -1);
 
                ret_code = lttng_events_create_and_flatten_from_payload(
-                               &cmd_reply_payload, nb_events, events);
+                       &cmd_reply_payload, nb_events, events);
                if (ret_code != LTTNG_OK) {
                        ret = -((int) ret_code);
                        goto end;
@@ -2501,7 +2495,7 @@ int lttng_set_tracing_group(const char *name)
        int ret = 0;
        char *new_group;
 
-       if (name == NULL) {
+       if (name == nullptr) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
@@ -2514,14 +2508,14 @@ int lttng_set_tracing_group(const char *name)
 
        free(tracing_group);
        tracing_group = new_group;
-       new_group = NULL;
+       new_group = nullptr;
 
 end:
        return ret;
 }
 
-int lttng_calibrate(struct lttng_handle *handle,
-               struct lttng_calibrate *calibrate)
+int lttng_calibrate(struct lttng_handle *handle __attribute__((unused)),
+                   struct lttng_calibrate *calibrate __attribute__((unused)))
 {
        /*
         * This command was removed in LTTng 2.9.
@@ -2533,13 +2527,12 @@ int lttng_calibrate(struct lttng_handle *handle,
  * Set default channel attributes.
  * If either or both of the arguments are null, attr content is zeroe'd.
  */
-void lttng_channel_set_default_attr(struct lttng_domain *domain,
-               struct lttng_channel_attr *attr)
+void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr)
 {
        struct lttng_channel_extended *extended;
 
        /* Safety check */
-       if (attr == NULL || domain == NULL) {
+       if (attr == nullptr || domain == nullptr) {
                return;
        }
 
@@ -2554,8 +2547,7 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,
 
        switch (domain->type) {
        case LTTNG_DOMAIN_KERNEL:
-               attr->switch_timer_interval =
-                               DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
+               attr->switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
                attr->read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
                attr->subbuf_size = default_get_kernel_channel_subbuf_size();
                attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
@@ -2567,20 +2559,16 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,
                        attr->subbuf_size = default_get_ust_uid_channel_subbuf_size();
                        attr->num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM;
                        attr->output = DEFAULT_UST_UID_CHANNEL_OUTPUT;
-                       attr->switch_timer_interval =
-                                       DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
-                       attr->read_timer_interval =
-                                       DEFAULT_UST_UID_CHANNEL_READ_TIMER;
+                       attr->switch_timer_interval = DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
+                       attr->read_timer_interval = DEFAULT_UST_UID_CHANNEL_READ_TIMER;
                        break;
                case LTTNG_BUFFER_PER_PID:
                default:
                        attr->subbuf_size = default_get_ust_pid_channel_subbuf_size();
                        attr->num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM;
                        attr->output = DEFAULT_UST_PID_CHANNEL_OUTPUT;
-                       attr->switch_timer_interval =
-                                       DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
-                       attr->read_timer_interval =
-                                       DEFAULT_UST_PID_CHANNEL_READ_TIMER;
+                       attr->switch_timer_interval = DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
+                       attr->read_timer_interval = DEFAULT_UST_PID_CHANNEL_READ_TIMER;
                        break;
                }
        default:
@@ -2597,7 +2585,7 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,
 }
 
 int lttng_channel_get_discarded_event_count(struct lttng_channel *channel,
-               uint64_t *discarded_events)
+                                           uint64_t *discarded_events)
 {
        int ret = 0;
        struct lttng_channel_extended *chan_ext;
@@ -2622,8 +2610,7 @@ end:
        return ret;
 }
 
-int lttng_channel_get_lost_packet_count(struct lttng_channel *channel,
-               uint64_t *lost_packets)
+int lttng_channel_get_lost_packet_count(struct lttng_channel *channel, uint64_t *lost_packets)
 {
        int ret = 0;
        struct lttng_channel_extended *chan_ext;
@@ -2649,7 +2636,7 @@ end:
 }
 
 int lttng_channel_get_monitor_timer_interval(struct lttng_channel *chan,
-               uint64_t *monitor_timer_interval)
+                                            uint64_t *monitor_timer_interval)
 {
        int ret = 0;
 
@@ -2663,14 +2650,14 @@ int lttng_channel_get_monitor_timer_interval(struct lttng_channel *chan,
                goto end;
        }
 
-       *monitor_timer_interval = ((struct lttng_channel_extended *)
-                       chan->attr.extended.ptr)->monitor_timer_interval;
+       *monitor_timer_interval =
+               ((struct lttng_channel_extended *) chan->attr.extended.ptr)->monitor_timer_interval;
 end:
        return ret;
 }
 
 int lttng_channel_set_monitor_timer_interval(struct lttng_channel *chan,
-               uint64_t monitor_timer_interval)
+                                            uint64_t monitor_timer_interval)
 {
        int ret = 0;
 
@@ -2679,15 +2666,13 @@ int lttng_channel_set_monitor_timer_interval(struct lttng_channel *chan,
                goto end;
        }
 
-       ((struct lttng_channel_extended *)
-                       chan->attr.extended.ptr)->monitor_timer_interval =
-                       monitor_timer_interval;
+       ((struct lttng_channel_extended *) chan->attr.extended.ptr)->monitor_timer_interval =
+               monitor_timer_interval;
 end:
        return ret;
 }
 
-int lttng_channel_get_blocking_timeout(struct lttng_channel *chan,
-               int64_t *blocking_timeout)
+int lttng_channel_get_blocking_timeout(struct lttng_channel *chan, int64_t *blocking_timeout)
 {
        int ret = 0;
 
@@ -2701,14 +2686,13 @@ int lttng_channel_get_blocking_timeout(struct lttng_channel *chan,
                goto end;
        }
 
-       *blocking_timeout = ((struct lttng_channel_extended *)
-                       chan->attr.extended.ptr)->blocking_timeout;
+       *blocking_timeout =
+               ((struct lttng_channel_extended *) chan->attr.extended.ptr)->blocking_timeout;
 end:
        return ret;
 }
 
-int lttng_channel_set_blocking_timeout(struct lttng_channel *chan,
-               int64_t blocking_timeout)
+int lttng_channel_set_blocking_timeout(struct lttng_channel *chan, int64_t blocking_timeout)
 {
        int ret = 0;
        int64_t msec_timeout;
@@ -2734,9 +2718,8 @@ int lttng_channel_set_blocking_timeout(struct lttng_channel *chan,
                goto end;
        }
 
-       ((struct lttng_channel_extended *)
-                       chan->attr.extended.ptr)->blocking_timeout =
-                       blocking_timeout;
+       ((struct lttng_channel_extended *) chan->attr.extended.ptr)->blocking_timeout =
+               blocking_timeout;
 end:
        return ret;
 }
@@ -2781,24 +2764,24 @@ int lttng_session_daemon_alive(void)
  * Return 0 on success, else a negative value.
  */
 int lttng_set_consumer_url(struct lttng_handle *handle,
-               const char *control_url, const char *data_url)
+                          const char *control_url,
+                          const char *data_url)
 {
        int ret;
        ssize_t size;
        struct lttcomm_session_msg lsm;
-       struct lttng_uri *uris = NULL;
+       struct lttng_uri *uris = nullptr;
 
-       if (handle == NULL || (control_url == NULL && data_url == NULL)) {
+       if (handle == nullptr || (control_url == nullptr && data_url == nullptr)) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
        }
 
        memset(&lsm, 0, sizeof(lsm));
 
-       lsm.cmd_type = LTTNG_SET_CONSUMER_URI;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SET_CONSUMER_URI;
 
-       ret = lttng_strncpy(lsm.session.name, handle->session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto error;
@@ -2814,8 +2797,8 @@ int lttng_set_consumer_url(struct lttng_handle *handle,
 
        lsm.u.uri.size = size;
 
-       ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, uris,
-                       sizeof(struct lttng_uri) * size, NULL);
+       ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
+               &lsm, uris, sizeof(struct lttng_uri) * size, nullptr);
 
        free(uris);
 error:
@@ -2825,9 +2808,8 @@ error:
 /*
  * [OBSOLETE]
  */
-extern "C"
-LTTNG_EXPORT int lttng_enable_consumer(struct lttng_handle *handle);
-int lttng_enable_consumer(struct lttng_handle *handle)
+extern "C" LTTNG_EXPORT int lttng_enable_consumer(struct lttng_handle *handle);
+int lttng_enable_consumer(struct lttng_handle *handle __attribute__((unused)))
 {
        return -ENOSYS;
 }
@@ -2835,9 +2817,8 @@ int lttng_enable_consumer(struct lttng_handle *handle)
 /*
  * [OBSOLETE]
  */
-extern "C"
-LTTNG_EXPORT int lttng_disable_consumer(struct lttng_handle *handle);
-int lttng_disable_consumer(struct lttng_handle *handle)
+extern "C" LTTNG_EXPORT int lttng_disable_consumer(struct lttng_handle *handle);
+int lttng_disable_consumer(struct lttng_handle *handle __attribute__((unused)))
 {
        return -ENOSYS;
 }
@@ -2845,11 +2826,11 @@ int lttng_disable_consumer(struct lttng_handle *handle)
 /*
  * [OBSOLETE]
  */
-extern "C"
-LTTNG_EXPORT int _lttng_create_session_ext(const char *name, const char *url,
-               const char *datetime);
-int _lttng_create_session_ext(const char *name, const char *url,
-               const char *datetime)
+extern "C" LTTNG_EXPORT int
+_lttng_create_session_ext(const char *name, const char *url, const char *datetime);
+int _lttng_create_session_ext(const char *name __attribute__((unused)),
+                             const char *url __attribute__((unused)),
+                             const char *datetime __attribute__((unused)))
 {
        return -ENOSYS;
 }
@@ -2863,17 +2844,16 @@ int lttng_data_pending(const char *session_name)
 {
        int ret;
        struct lttcomm_session_msg lsm;
-       uint8_t *pending = NULL;
+       uint8_t *pending = nullptr;
 
-       if (session_name == NULL) {
+       if (session_name == nullptr) {
                return -LTTNG_ERR_INVALID;
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_DATA_PENDING;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_DATA_PENDING;
 
-       ret = lttng_strncpy(lsm.session.name, session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -2898,6 +2878,34 @@ end:
        return ret;
 }
 
+/*
+ * Get the status of the kernel tracer
+ *
+ * Sets the value of the argument
+ */
+enum lttng_error_code lttng_get_kernel_tracer_status(enum lttng_kernel_tracer_status *out_status)
+{
+       if (out_status == nullptr) {
+               return LTTNG_ERR_INVALID;
+       }
+
+       struct lttcomm_session_msg lsm = {};
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_KERNEL_TRACER_STATUS;
+
+       uint32_t *raw_tracer_status = nullptr;
+       const auto ask_ret = lttng_ctl_ask_sessiond(&lsm, (void **) &raw_tracer_status);
+
+       const auto tracer_status =
+               lttng::make_unique_wrapper<uint32_t, lttng::memory::free>(raw_tracer_status);
+
+       if (ask_ret != 4) {
+               return LTTNG_ERR_INVALID;
+       }
+
+       *out_status = (enum lttng_kernel_tracer_status) * tracer_status;
+       return LTTNG_OK;
+}
+
 /*
  * Regenerate the metadata for a session.
  * Return 0 on success, a negative error code on error.
@@ -2913,16 +2921,15 @@ int lttng_regenerate_metadata(const char *session_name)
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_REGENERATE_METADATA;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_REGENERATE_METADATA;
 
-       ret = lttng_strncpy(lsm.session.name, session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+       ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
        if (ret < 0) {
                goto end;
        }
@@ -2955,16 +2962,15 @@ int lttng_regenerate_statedump(const char *session_name)
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_REGENERATE_STATEDUMP;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_REGENERATE_STATEDUMP;
 
-       ret = lttng_strncpy(lsm.session.name, session_name,
-                       sizeof(lsm.session.name));
+       ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
        if (ret) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
 
-       ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+       ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
        if (ret < 0) {
                goto end;
        }
@@ -2974,25 +2980,28 @@ end:
        return ret;
 }
 
-static
-int _lttng_register_trigger(struct lttng_trigger *trigger, const char *name,
-               bool generate_name)
+static int
+_lttng_register_trigger(struct lttng_trigger *trigger, const char *name, bool generate_name)
 {
        int ret;
        struct lttcomm_session_msg lsm = {
-               .cmd_type = LTTNG_REGISTER_TRIGGER,
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_REGISTER_TRIGGER,
+               .session = {},
+               .domain = {},
+               .u = {},
+               .fd_count = 0,
        };
        lsm.u.trigger.is_trigger_anonymous = !name && !generate_name;
        struct lttcomm_session_msg *message_lsm;
        struct lttng_payload message;
        struct lttng_payload reply;
-       struct lttng_trigger *reply_trigger = NULL;
+       struct lttng_trigger *reply_trigger = nullptr;
        enum lttng_domain_type domain_type;
        const struct lttng_credentials user_creds = {
                .uid = LTTNG_OPTIONAL_INIT_VALUE(geteuid()),
                .gid = LTTNG_OPTIONAL_INIT_UNSET,
        };
-       const char *unused_trigger_name = NULL;
+       const char *unused_trigger_name = nullptr;
        enum lttng_trigger_status trigger_status;
 
        lttng_payload_init(&message);
@@ -3033,7 +3042,7 @@ int _lttng_register_trigger(struct lttng_trigger *trigger, const char *name,
                 * "safety" checks.
                 */
                const struct lttng_credentials *trigger_creds =
-                               lttng_trigger_get_credentials(trigger);
+                       lttng_trigger_get_credentials(trigger);
 
                if (!lttng_credentials_is_equal_uid(trigger_creds, &user_creds)) {
                        if (lttng_credentials_get_uid(&user_creds) != 0) {
@@ -3048,8 +3057,7 @@ int _lttng_register_trigger(struct lttng_trigger *trigger, const char *name,
                goto end_unset_name;
        }
 
-       domain_type = lttng_trigger_get_underlying_domain_type_restriction(
-                       trigger);
+       domain_type = lttng_trigger_get_underlying_domain_type_restriction(trigger);
 
        lsm.domain.type = domain_type;
 
@@ -3075,11 +3083,9 @@ int _lttng_register_trigger(struct lttng_trigger *trigger, const char *name,
 
        {
                struct lttng_payload_view message_view =
-                               lttng_payload_view_from_payload(
-                                               &message, 0, -1);
+                       lttng_payload_view_from_payload(&message, 0, -1);
 
-               message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(
-                               &message_view);
+               message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(&message_view);
                ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
                if (ret < 0) {
                        goto end_unset_name;
@@ -3088,11 +3094,9 @@ int _lttng_register_trigger(struct lttng_trigger *trigger, const char *name,
 
        {
                struct lttng_payload_view reply_view =
-                               lttng_payload_view_from_payload(
-                                               &reply, 0, reply.buffer.size);
+                       lttng_payload_view_from_payload(&reply, 0, reply.buffer.size);
 
-               ret = lttng_trigger_create_from_payload(
-                               &reply_view, &reply_trigger);
+               ret = lttng_trigger_create_from_payload(&reply_view, &reply_trigger);
                if (ret < 0) {
                        ret = -LTTNG_ERR_INVALID_PROTOCOL;
                        goto end_unset_name;
@@ -3111,7 +3115,7 @@ int _lttng_register_trigger(struct lttng_trigger *trigger, const char *name,
        goto end;
 
 end_unset_name:
-       trigger_status = lttng_trigger_set_name(trigger, NULL);
+       trigger_status = lttng_trigger_set_name(trigger, nullptr);
        if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
                ret = -LTTNG_ERR_UNK;
        }
@@ -3125,34 +3129,36 @@ end:
 int lttng_register_trigger(struct lttng_trigger *trigger)
 {
        /* Register an anonymous trigger. */
-       return _lttng_register_trigger(trigger, NULL, false);
+       return _lttng_register_trigger(trigger, nullptr, false);
 }
 
-enum lttng_error_code lttng_register_trigger_with_name(
-               struct lttng_trigger *trigger, const char *name)
+enum lttng_error_code lttng_register_trigger_with_name(struct lttng_trigger *trigger,
+                                                      const char *name)
 {
        const int ret = _lttng_register_trigger(trigger, name, false);
 
-       return ret == 0 ? LTTNG_OK : (enum lttng_error_code) -ret;
+       return ret == 0 ? LTTNG_OK : (enum lttng_error_code) - ret;
 }
 
-enum lttng_error_code lttng_register_trigger_with_automatic_name(
-               struct lttng_trigger *trigger)
+enum lttng_error_code lttng_register_trigger_with_automatic_name(struct lttng_trigger *trigger)
 {
-       const int ret =  _lttng_register_trigger(trigger, nullptr, true);
+       const int ret = _lttng_register_trigger(trigger, nullptr, true);
 
-       return ret == 0 ? LTTNG_OK : (enum lttng_error_code) -ret;
+       return ret == 0 ? LTTNG_OK : (enum lttng_error_code) - ret;
 }
 
-enum lttng_error_code lttng_error_query_execute(
-               const struct lttng_error_query *query,
-               const struct lttng_endpoint *endpoint,
-               struct lttng_error_query_results **results)
+enum lttng_error_code lttng_error_query_execute(const struct lttng_error_query *query,
+                                               const struct lttng_endpoint *endpoint,
+                                               struct lttng_error_query_results **results)
 {
        int ret;
        enum lttng_error_code ret_code;
        struct lttcomm_session_msg lsm = {
-               .cmd_type = LTTNG_EXECUTE_ERROR_QUERY,
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_EXECUTE_ERROR_QUERY,
+               .session = {},
+               .domain = {},
+               .u = {},
+               .fd_count = 0,
        };
        struct lttng_payload message;
        struct lttng_payload reply;
@@ -3184,19 +3190,16 @@ enum lttng_error_code lttng_error_query_execute(
        }
 
        message_lsm = (struct lttcomm_session_msg *) message.buffer.data;
-       message_lsm->u.error_query.length =
-                       (uint32_t) message.buffer.size - sizeof(lsm);
+       message_lsm->u.error_query.length = (uint32_t) message.buffer.size - sizeof(lsm);
 
        {
                struct lttng_payload_view message_view =
-                               lttng_payload_view_from_payload(
-                                               &message, 0, -1);
+                       lttng_payload_view_from_payload(&message, 0, -1);
 
-               message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(
-                               &message_view);
+               message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(&message_view);
                ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
                if (ret < 0) {
-                       ret_code =(lttng_error_code) -ret;
+                       ret_code = (lttng_error_code) -ret;
                        goto end;
                }
        }
@@ -3204,11 +3207,10 @@ enum lttng_error_code lttng_error_query_execute(
        {
                ssize_t reply_create_ret;
                struct lttng_payload_view reply_view =
-                               lttng_payload_view_from_payload(
-                                               &reply, 0, reply.buffer.size);
+                       lttng_payload_view_from_payload(&reply, 0, reply.buffer.size);
 
-               reply_create_ret = lttng_error_query_results_create_from_payload(
-                               &reply_view, results);
+               reply_create_ret =
+                       lttng_error_query_results_create_from_payload(&reply_view, results);
                if (reply_create_ret < 0) {
                        ret_code = LTTNG_ERR_INVALID_PROTOCOL;
                        goto end;
@@ -3229,7 +3231,7 @@ int lttng_unregister_trigger(const struct lttng_trigger *trigger)
        struct lttcomm_session_msg *message_lsm;
        struct lttng_payload message;
        struct lttng_payload reply;
-       struct lttng_trigger *copy = NULL;
+       struct lttng_trigger *copy = nullptr;
        const struct lttng_credentials user_creds = {
                .uid = LTTNG_OPTIONAL_INIT_VALUE(geteuid()),
                .gid = LTTNG_OPTIONAL_INIT_UNSET,
@@ -3263,8 +3265,7 @@ int lttng_unregister_trigger(const struct lttng_trigger *trigger)
                 * credentials passed on the socket. These check are all
                 * "safety" checks.
                 */
-               const struct lttng_credentials *trigger_creds =
-                               lttng_trigger_get_credentials(copy);
+               const struct lttng_credentials *trigger_creds = lttng_trigger_get_credentials(copy);
                if (!lttng_credentials_is_equal_uid(trigger_creds, &user_creds)) {
                        if (lttng_credentials_get_uid(&user_creds) != 0) {
                                ret = -LTTNG_ERR_EPERM;
@@ -3279,7 +3280,7 @@ int lttng_unregister_trigger(const struct lttng_trigger *trigger)
        }
 
        memset(&lsm, 0, sizeof(lsm));
-       lsm.cmd_type = LTTNG_UNREGISTER_TRIGGER;
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_UNREGISTER_TRIGGER;
 
        ret = lttng_dynamic_buffer_append(&message.buffer, &lsm, sizeof(lsm));
        if (ret) {
@@ -3296,22 +3297,20 @@ int lttng_unregister_trigger(const struct lttng_trigger *trigger)
        /*
         * This is needed to populate the trigger object size for the command
         * header and number of fds sent.
-       */
+        */
        message_lsm = (struct lttcomm_session_msg *) message.buffer.data;
 
        message_lsm->u.trigger.length = (uint32_t) message.buffer.size - sizeof(lsm);
 
        {
                struct lttng_payload_view message_view =
-                               lttng_payload_view_from_payload(
-                                               &message, 0, -1);
+                       lttng_payload_view_from_payload(&message, 0, -1);
 
                /*
                 * Update the message header with the number of fd that will be
                 * sent.
                 */
-               message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(
-                               &message_view);
+               message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(&message_view);
 
                ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
                if (ret < 0) {
@@ -3337,28 +3336,31 @@ enum lttng_error_code lttng_list_triggers(struct lttng_triggers **triggers)
 {
        int ret;
        enum lttng_error_code ret_code = LTTNG_OK;
-       struct lttcomm_session_msg lsm = { .cmd_type = LTTNG_LIST_TRIGGERS };
-       struct lttng_triggers *local_triggers = NULL;
+       struct lttcomm_session_msg lsm = {
+               .cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_TRIGGERS,
+               .session = {},
+               .domain = {},
+               .u = {},
+               .fd_count = 0,
+       };
+       struct lttng_triggers *local_triggers = nullptr;
        struct lttng_payload reply;
        struct lttng_payload_view lsm_view =
-                       lttng_payload_view_init_from_buffer(
-                               (const char *) &lsm, 0, sizeof(lsm));
+               lttng_payload_view_init_from_buffer((const char *) &lsm, 0, sizeof(lsm));
 
        lttng_payload_init(&reply);
 
        ret = lttng_ctl_ask_sessiond_payload(&lsm_view, &reply);
        if (ret < 0) {
-               ret_code = (enum lttng_error_code) -ret;
+               ret_code = (enum lttng_error_code) - ret;
                goto end;
        }
 
        {
                struct lttng_payload_view reply_view =
-                               lttng_payload_view_from_payload(
-                                               &reply, 0, reply.buffer.size);
+                       lttng_payload_view_from_payload(&reply, 0, reply.buffer.size);
 
-               ret = lttng_triggers_create_from_payload(
-                               &reply_view, &local_triggers);
+               ret = lttng_triggers_create_from_payload(&reply_view, &local_triggers);
                if (ret < 0) {
                        ret_code = LTTNG_ERR_FATAL;
                        goto end;
@@ -3366,7 +3368,7 @@ enum lttng_error_code lttng_list_triggers(struct lttng_triggers **triggers)
        }
 
        *triggers = local_triggers;
-       local_triggers = NULL;
+       local_triggers = nullptr;
 end:
        lttng_payload_reset(&reply);
        lttng_triggers_destroy(local_triggers);
@@ -3376,7 +3378,7 @@ end:
 /*
  * lib constructor.
  */
-static void __attribute__((constructor)) init(void)
+static void __attribute__((constructor)) init()
 {
        /* Set default session group */
        lttng_set_tracing_group(DEFAULT_TRACING_GROUP);
@@ -3385,7 +3387,7 @@ static void __attribute__((constructor)) init(void)
 /*
  * lib destructor.
  */
-static void __attribute__((destructor)) lttng_ctl_exit(void)
+static void __attribute__((destructor)) lttng_ctl_exit()
 {
        free(tracing_group);
 }
This page took 0.076262 seconds and 4 git commands to generate.