/*
* Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
- * SPDX-License-Identifier: GPL-2.0-only
+ * SPDX-License-Identifier: LGPL-2.1-only
*
*/
#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>
#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
+namespace {
struct session_config_validation_ctx {
xmlSchemaParserCtxtPtr parser_ctx;
xmlSchemaPtr schema;
xmlSchemaValidCtxtPtr schema_validation_ctx;
};
+} /* namespace */
const char * const config_element_all = "all";
LTTNG_EXPORT const char *config_xml_encoding = "UTF-8";
ENABLE = 1,
};
+namespace {
struct consumer_output {
int enabled;
char *path;
char *control_uri;
char *data_uri;
};
+} /* namespace */
/*
* Returns a xmlChar string which must be released using xmlFree().
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;
return ret >= 0 ? 0 : ret;
}
-static
-void xml_error_handler(void *ctx, const char *format, ...)
+static ATTR_FORMAT_PRINTF(2, 3)
+void xml_error_handler(void *ctx __attribute__((unused)), const char *format, ...)
{
char *errMsg;
va_list args;
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;
}
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;
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;
continue;
}
- exclusions = (char **) zmalloc(exclusion_count * sizeof(char *));
+ exclusions = calloc<char *>(exclusion_count);
if (!exclusions) {
exclusion_count = 0;
ret = -LTTNG_ERR_NOMEM;
/* 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;
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) {