*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
+#include <lttng/domain-internal.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.hpp>
-#include <lttng/domain-internal.hpp>
-
-#include "../command.hpp"
-
static int opt_kernel;
static char *opt_session_name;
static int opt_userspace;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-disable-channel.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, nullptr, nullptr },
+ { "userspace", 'u', POPT_ARG_NONE, nullptr, OPT_USERSPACE, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
-static int mi_partial_channel_print(char *channel_name, unsigned int enabled,
- int success)
+static int mi_partial_channel_print(char *channel_name, unsigned int enabled, int success)
{
int ret;
}
/* Name */
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- channel_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, channel_name);
if (ret) {
goto end;
}
/* Enabled ? */
- ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled,
- enabled);
+ ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, enabled);
if (ret) {
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_success, success);
+ ret = mi_lttng_writer_write_element_bool(writer, mi_lttng_element_success, success);
if (ret) {
goto end;
}
*/
static int disable_channels(char *session_name, char *channel_list)
{
- int ret = CMD_SUCCESS, warn = 0, success;
-
- /* Normal case for disable channed is enabled = 0 */
- unsigned int enabled = 0;
+ int ret = CMD_SUCCESS;
+ /* Normal case for disable channed is enabled = false */
+ bool warn = false, success, enabled = false;
char *channel_name;
struct lttng_domain dom;
}
handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = -1;
goto error;
}
ret = CMD_ERROR;
goto error;
}
-
}
/* Strip channel list */
channel_name = strtok(channel_list, ",");
- while (channel_name != NULL) {
+ while (channel_name != nullptr) {
DBG("Disabling channel %s", channel_name);
ret = lttng_disable_channel(handle, channel_name);
if (ret < 0) {
- ERR("Channel %s: %s (session %s)", channel_name,
- lttng_strerror(ret), session_name);
- warn = 1;
+ ERR("Channel %s: %s (session %s)",
+ channel_name,
+ lttng_strerror(ret),
+ session_name);
+ warn = true;
/*
* Mi:
* The client should look at the stderr stream
* for more informations.
*/
- enabled = 1;
- success = 0;
+ enabled = true;
+ success = false;
} else {
MSG("%s channel %s disabled for session %s",
- lttng_domain_type_str(dom.type),
- channel_name, session_name);
- enabled = 0;
- success = 1;
+ lttng_domain_type_str(dom.type),
+ channel_name,
+ session_name);
+ enabled = false;
+ success = true;
}
/* Print the channel */
}
/* Next channel */
- channel_name = strtok(NULL, ",");
+ channel_name = strtok(nullptr, ",");
}
ret = CMD_SUCCESS;
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- char *session_name = NULL;
- char *channel_list = NULL;
- const char *arg_channel_list = NULL;
- const char *leftover = NULL;
+ char *session_name = nullptr;
+ char *channel_list = nullptr;
+ const char *arg_channel_list = nullptr;
+ const char *leftover = nullptr;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
}
}
- ret = print_missing_or_multiple_domains(
- opt_kernel + opt_userspace, false);
+ ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace, false);
if (ret) {
ret = CMD_ERROR;
goto end;
}
arg_channel_list = poptGetArg(pc);
- if (arg_channel_list == NULL) {
+ if (arg_channel_list == nullptr) {
ERR("Missing channel name(s).");
ret = CMD_ERROR;
goto end;
}
channel_list = strdup(arg_channel_list);
- if (channel_list == NULL) {
+ if (channel_list == nullptr) {
PERROR("Failed to copy channel name");
ret = CMD_ERROR;
goto end;
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto end;
}
/* Open command element */
ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_disable_channel);
+ mi_lttng_element_command_disable_channel);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_success, success);
+ ret = mi_lttng_writer_write_element_bool(writer, mi_lttng_element_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;