#include "lttng/tracker.h"
#define _LGPL_SOURCE
-#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
int ret = 0;
struct config_entry entry = { section, name, value };
- assert(args);
+ LTTNG_ASSERT(args);
if (!section || !name || !value) {
ret = -EIO;
xmlCharEncodingHandlerPtr handler;
int out_len, ret, in_len;
- assert(in_str);
+ LTTNG_ASSERT(in_str);
handler = xmlFindCharEncodingHandler(config_xml_encoding);
if (!handler) {
value ? config_xml_true : config_xml_false);
}
+LTTNG_HIDDEN
+int config_writer_write_element_double(struct config_writer *writer,
+ const char *element_name,
+ double value)
+{
+ int ret;
+ xmlChar *encoded_element_name;
+
+ if (!writer || !writer->writer || !element_name || !element_name[0]) {
+ ret = -1;
+ goto end;
+ }
+
+ encoded_element_name = encode_string(element_name);
+ if (!encoded_element_name) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = xmlTextWriterWriteFormatElement(
+ writer->writer, encoded_element_name, "%f", value);
+ xmlFree(encoded_element_name);
+end:
+ return ret >= 0 ? 0 : ret;
+}
+
LTTNG_HIDDEN
int config_writer_write_element_string(struct config_writer *writer,
const char *element_name, const char *value)
}
static
-char *get_session_config_xsd_path()
+char *get_session_config_xsd_path(void)
{
char *xsd_path;
const char *base_path = lttng_secure_getenv(DEFAULT_SESSION_CONFIG_XSD_PATH_ENV);
goto end;
}
- if (!strcmp((const char *) str, config_xml_true)) {
+ if (!strcmp((const char *) str, config_xml_true) ||
+ !strcmp((const char *) str, "1")) {
*val = 1;
- } else if (!strcmp((const char *) str, config_xml_false)) {
+ } else if (!strcmp((const char *) str, config_xml_false) ||
+ !strcmp((const char *) str, "0")) {
*val = 0;
} else {
- WARN("Invalid boolean value encoutered (%s).",
+ WARN("Invalid boolean value encountered (%s).",
(const char *) str);
ret = -1;
}
int ret;
xmlNodePtr node;
- assert(output);
+ LTTNG_ASSERT(output);
for (node = xmlFirstElementChild(consumer_output_node); node;
node = xmlNextElementSibling(node)) {
struct lttng_handle *handle;
const char *uri = NULL;
- assert(name);
+ LTTNG_ASSERT(name);
handle = lttng_create_handle(name, NULL);
if (!handle) {
xmlNodePtr snapshot_output_list_node;
xmlNodePtr snapshot_output_node;
- assert(session_name);
+ LTTNG_ASSERT(session_name);
ret = lttng_create_session_snapshot(session_name, NULL);
if (ret) {
const char *data_uri = NULL;
const char *path = NULL;
- assert(name);
+ LTTNG_ASSERT(name);
if (output_node) {
consumer_output_node = xmlFirstElementChild(output_node);
{
int ret;
- assert(probe_attribute_node);
- assert(attr);
+ LTTNG_ASSERT(probe_attribute_node);
+ LTTNG_ASSERT(attr);
if (!strcmp((const char *) probe_attribute_node->name,
config_element_address)) {
unsigned long exclusion_count = 0;
char *filter_expression = NULL;
- assert(event_node);
- assert(handle);
- assert(channel_name);
+ LTTNG_ASSERT(event_node);
+ LTTNG_ASSERT(handle);
+ LTTNG_ASSERT(channel_name);
event = lttng_event_create();
if (!event) {
event->loglevel = LTTNG_LOGLEVEL_DEBUG;
break;
default:
- assert(0);
+ abort();
}
for (node = xmlFirstElementChild(event_node); node;
struct lttng_event event;
xmlNodePtr node;
- assert(events_node);
- assert(handle);
- assert(channel_name);
+ LTTNG_ASSERT(events_node);
+ LTTNG_ASSERT(handle);
+ LTTNG_ASSERT(channel_name);
for (node = xmlFirstElementChild(events_node); node;
node = xmlNextElementSibling(node)) {
{
int ret;
- assert(attr_node);
- assert(channel);
- assert(contexts_node);
- assert(events_node);
+ LTTNG_ASSERT(attr_node);
+ LTTNG_ASSERT(channel);
+ LTTNG_ASSERT(contexts_node);
+ LTTNG_ASSERT(events_node);
if (!strcmp((const char *) attr_node->name, config_element_name)) {
xmlChar *content;
struct lttng_event_context context;
xmlNodePtr context_child_node = xmlFirstElementChild(context_node);
- assert(handle);
- assert(channel_name);
+ LTTNG_ASSERT(handle);
+ LTTNG_ASSERT(channel_name);
if (!context_child_node) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID :
LTTNG_PROCESS_ATTR_PROCESS_ID;
- assert(handle);
+ LTTNG_ASSERT(handle);
tracker_handle_ret_code = lttng_session_get_tracker_handle(
handle->session_name, handle->domain.type,
struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
enum lttng_process_attr_tracker_handle_status status;
- assert(handle);
- assert(id_tracker_node);
+ LTTNG_ASSERT(handle);
+ LTTNG_ASSERT(id_tracker_node);
tracker_handle_ret_code = lttng_session_get_tracker_handle(
handle->session_name, handle->domain.type, process_attr,
xmlNodePtr vgid_tracker_node = NULL;
xmlNodePtr node;
- assert(session_name);
+ LTTNG_ASSERT(session_name);
ret = init_domain(domain_node, &domain);
if (ret) {
{
int ret;
- assert(path);
+ LTTNG_ASSERT(path);
/* Can we read the file. */
ret = access(path, R_OK);
xmlNodePtr sessions_node;
xmlNodePtr session_node;
- assert(path);
- assert(validation_ctx);
+ LTTNG_ASSERT(path);
+ LTTNG_ASSERT(validation_ctx);
ret = validate_file_read_creds(path);
if (ret != 1) {
struct lttng_dynamic_buffer file_path;
size_t path_len;
- assert(path);
- assert(validation_ctx);
+ LTTNG_ASSERT(path);
+ LTTNG_ASSERT(validation_ctx);
path_len = strlen(path);
lttng_dynamic_buffer_init(&file_path);
if (path_len >= LTTNG_PATH_MAX) {
int ret, uid = getuid();
struct stat buf;
- assert(path);
+ LTTNG_ASSERT(path);
if (uid == 0) {
goto valid;
/* Try home path */
home_path = utils_get_home_dir();
if (home_path) {
- char path[PATH_MAX];
+ char path_buf[PATH_MAX];
/*
* Try user session configuration path. Ignore error here so we can
* continue loading the system wide sessions.
*/
if (autoload) {
- ret = snprintf(path, sizeof(path),
- DEFAULT_SESSION_HOME_CONFIGPATH "/"
- DEFAULT_SESSION_CONFIG_AUTOLOAD, home_path);
+ ret = snprintf(path_buf, sizeof(path_buf),
+ DEFAULT_SESSION_HOME_CONFIGPATH
+ "/" DEFAULT_SESSION_CONFIG_AUTOLOAD,
+ home_path);
if (ret < 0) {
PERROR("snprintf session autoload home config path");
ret = -LTTNG_ERR_INVALID;
* avoid any user session daemon to try to load kernel sessions
* automatically and failing all the times.
*/
- ret = validate_path_creds(path);
+ ret = validate_path_creds(path_buf);
if (ret) {
- path_ptr = path;
+ path_ptr = path_buf;
}
} else {
- ret = snprintf(path, sizeof(path),
- DEFAULT_SESSION_HOME_CONFIGPATH, home_path);
+ ret = snprintf(path_buf, sizeof(path_buf),
+ DEFAULT_SESSION_HOME_CONFIGPATH,
+ home_path);
if (ret < 0) {
PERROR("snprintf session home config path");
ret = -LTTNG_ERR_INVALID;
goto end;
}
- path_ptr = path;
+ path_ptr = path_buf;
}
if (path_ptr) {
ret = load_session_from_path(path_ptr, session_name,