Add type-checked versions of allocation and deallocations functions
[lttng-tools.git] / src / common / config / session-config.cpp
index 2d2f303f5aef7d964d39eff93db69dbe4268b0c1..9e5f0ff20cbf298b4753c2e0bf2975e7b8d5ea25 100644 (file)
 #include <sys/stat.h>
 #include <stdbool.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/utils.h>
-#include <common/dynamic-buffer.h>
-#include <common/compat/getenv.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/compat/getenv.hpp>
 #include <lttng/lttng-error.h>
 #include <libxml/parser.h>
 #include <libxml/valid.h>
@@ -34,8 +34,8 @@
 #include <lttng/rotation.h>
 #include <lttng/userspace-probe.h>
 
-#include "session-config.h"
-#include "config-internal.h"
+#include "session-config.hpp"
+#include "config-internal.hpp"
 
 #define CONFIG_USERSPACE_PROBE_LOOKUP_METHOD_NAME_MAX_LEN 7
 
@@ -287,7 +287,7 @@ struct config_writer *config_writer_create(int fd_output, int indent)
        struct config_writer *writer;
        xmlOutputBufferPtr buffer;
 
-       writer = (config_writer *) zmalloc(sizeof(struct config_writer));
+       writer = zmalloc<config_writer>();
        if (!writer) {
                PERROR("zmalloc config_writer_create");
                goto end;
@@ -529,7 +529,7 @@ end:
 }
 
 static ATTR_FORMAT_PRINTF(2, 3)
-void xml_error_handler(void *ctx, const char *format, ...)
+void xml_error_handler(void *ctx __attribute__((unused)), const char *format, ...)
 {
        char *errMsg;
        va_list args;
@@ -581,7 +581,7 @@ char *get_session_config_xsd_path(void)
        base_path_len = strlen(base_path);
        max_path_len = base_path_len +
                sizeof(DEFAULT_SESSION_CONFIG_XSD_FILENAME) + 1;
-       xsd_path = (char *) zmalloc(max_path_len);
+       xsd_path = zmalloc<char>(max_path_len);
        if (!xsd_path) {
                goto end;
        }
@@ -1203,7 +1203,7 @@ int create_snapshot_session(const char *session_name, xmlNodePtr output_node,
                        xmlNextElementSibling(snapshot_output_node)) {
                char *name = NULL;
                uint64_t max_size = UINT64_MAX;
-               struct consumer_output output = { 0 };
+               struct consumer_output output = {};
                struct lttng_snapshot_output *snapshot_output = NULL;
                const char *control_uri = NULL;
                const char *data_uri = NULL;
@@ -1329,7 +1329,7 @@ int create_session(const char *name,
        const struct config_load_session_override_attr *overrides)
 {
        int ret;
-       struct consumer_output output = { 0 };
+       struct consumer_output output = {};
        xmlNodePtr consumer_output_node;
        const char *control_uri = NULL;
        const char *data_uri = NULL;
@@ -1856,7 +1856,7 @@ int process_event_node(xmlNodePtr event_node, struct lttng_handle *handle,
                                continue;
                        }
 
-                       exclusions = (char **) zmalloc(exclusion_count * sizeof(char *));
+                       exclusions = calloc<char *>(exclusion_count);
                        if (!exclusions) {
                                exclusion_count = 0;
                                ret = -LTTNG_ERR_NOMEM;
@@ -3399,9 +3399,8 @@ int process_session_node(xmlNodePtr session_node, const char *session_name,
        /* Init domains to create the session handles */
        for (node = xmlFirstElementChild(domains_node); node;
                node = xmlNextElementSibling(node)) {
-               struct lttng_domain *domain;
+               lttng_domain *domain = zmalloc<lttng_domain>();
 
-               domain = (lttng_domain *) zmalloc(sizeof(*domain));
                if (!domain) {
                        ret = -LTTNG_ERR_NOMEM;
                        goto error;
@@ -3859,7 +3858,7 @@ int config_load_session(const char *path, const char *session_name,
        int ret;
        bool session_loaded = false;
        const char *path_ptr = NULL;
-       struct session_config_validation_ctx validation_ctx = { 0 };
+       struct session_config_validation_ctx validation_ctx = {};
 
        ret = init_session_config_validation_ctx(&validation_ctx);
        if (ret) {
This page took 0.025192 seconds and 4 git commands to generate.