#include "../command.hpp"
-static char *opt_channels;
static int opt_kernel;
static char *opt_session_name;
static int opt_userspace;
/*
* Disabling channel using the lttng API.
*/
-static int disable_channels(char *session_name)
+static int disable_channels(char *session_name, char *channel_list)
{
int ret = CMD_SUCCESS, warn = 0, success;
}
/* Strip channel list */
- channel_name = strtok(opt_channels, ",");
+ channel_name = strtok(channel_list, ",");
while (channel_name != NULL) {
DBG("Disabling channel %s", channel_name);
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;
pc = poptGetContext(NULL, argc, argv, long_options, 0);
goto end;
}
- opt_channels = (char*) poptGetArg(pc);
- if (opt_channels == NULL) {
- ERR("Missing channel name(s).\n");
+ arg_channel_list = poptGetArg(pc);
+ if (arg_channel_list == NULL) {
+ ERR("Missing channel name(s).");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ channel_list = strdup(arg_channel_list);
+ if (channel_list == NULL) {
+ PERROR("Failed to copy channel name");
ret = CMD_ERROR;
goto end;
}
}
}
- command_ret = disable_channels(session_name);
+ command_ret = disable_channels(session_name, channel_list);
if (command_ret) {
success = 0;
}
free(session_name);
}
+ free(channel_list);
+
/* Overwrite ret if an error occurred in disable_channels */
ret = command_ret ? command_ret : ret;