Add type-checked versions of allocation and deallocations functions
[lttng-tools.git] / src / bin / lttng-sessiond / consumer.cpp
index 9919c678148978460438bc9e99cb287531e0a351..bdda3913597a7639150a67473517e92bf31f1180 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/uri.h>
-#include <common/relayd/relayd.h>
-#include <common/string-utils/format.h>
-
-#include "consumer.h"
-#include "health-sessiond.h"
-#include "ust-app.h"
-#include "utils.h"
-#include "lttng-sessiond.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/uri.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/string-utils/format.hpp>
+
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
+#include "lttng-sessiond.hpp"
 
 /*
  * Return allocated full pathname of the session using the consumer trace path
@@ -49,7 +49,7 @@ char *setup_channel_trace_path(struct consumer_output *consumer,
         * Allocate the string ourself to make sure we never exceed
         * LTTNG_PATH_MAX.
         */
-       pathname = (char *) zmalloc(LTTNG_PATH_MAX);
+       pathname = calloc<char>(LTTNG_PATH_MAX);
        if (!pathname) {
                goto error;
        }
@@ -429,7 +429,7 @@ struct consumer_socket *consumer_allocate_socket(int *fd)
 
        LTTNG_ASSERT(fd);
 
-       socket = (consumer_socket *) zmalloc(sizeof(struct consumer_socket));
+       socket = zmalloc<consumer_socket>();
        if (socket == NULL) {
                PERROR("zmalloc consumer socket");
                goto error;
@@ -520,7 +520,7 @@ struct consumer_output *consumer_create_output(enum consumer_dst_type type)
 {
        struct consumer_output *output = NULL;
 
-       output = (consumer_output *) zmalloc(sizeof(struct consumer_output));
+       output = zmalloc<consumer_output>();
        if (output == NULL) {
                PERROR("zmalloc consumer_output");
                goto error;
@@ -1731,6 +1731,7 @@ int consumer_open_channel_packets(struct consumer_socket *socket, uint64_t key)
        int ret;
        lttcomm_consumer_msg msg = {
                .cmd_type = LTTNG_CONSUMER_OPEN_CHANNEL_PACKETS,
+               .u = {},
        };
        msg.u.open_channel_packets.key = key;
 
@@ -1786,6 +1787,7 @@ int consumer_init(struct consumer_socket *socket,
        int ret;
        struct lttcomm_consumer_msg msg = {
                .cmd_type = LTTNG_CONSUMER_INIT,
+               .u = {},
        };
 
        LTTNG_ASSERT(socket);
@@ -1830,6 +1832,7 @@ int consumer_create_trace_chunk(struct consumer_socket *socket,
        enum lttng_trace_chunk_status tc_status;
        struct lttcomm_consumer_msg msg = {
                .cmd_type = LTTNG_CONSUMER_CREATE_TRACE_CHUNK,
+               .u = {},
        };
        msg.u.create_trace_chunk.session_id = session_id;
 
@@ -1984,6 +1987,7 @@ int consumer_close_trace_chunk(struct consumer_socket *socket,
        enum lttng_trace_chunk_status chunk_status;
        lttcomm_consumer_msg msg = {
                .cmd_type = LTTNG_CONSUMER_CLOSE_TRACE_CHUNK,
+               .u = {},
        };
        msg.u.close_trace_chunk.session_id = session_id;
 
@@ -2110,6 +2114,7 @@ int consumer_trace_chunk_exists(struct consumer_socket *socket,
        enum lttng_trace_chunk_status chunk_status;
        lttcomm_consumer_msg msg = {
                .cmd_type = LTTNG_CONSUMER_TRACE_CHUNK_EXISTS,
+               .u = {},
        };
        msg.u.trace_chunk_exists.session_id = session_id;
 
This page took 0.025788 seconds and 4 git commands to generate.