switch (opt) {
case OPT_HELP:
usage(stdout);
- ret = CMD_SUCCESS;
goto end;
case OPT_TYPE:
/*
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
free(type);
}
+ poptFreeContext(pc);
return ret;
}
*/
int cmd_calibrate(int argc, const char **argv)
{
- int opt, ret;
+ int opt, ret = CMD_SUCCESS;
static poptContext pc;
pc = poptGetContext(NULL, argc, argv, long_options, 0);
switch (opt) {
case OPT_HELP:
usage(stdout);
- ret = CMD_SUCCESS;
goto end;
case OPT_TRACEPOINT:
ret = CMD_UNDEFINED;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
ret = calibrate_lttng();
end:
+ poptFreeContext(pc);
return ret;
}
ret = create_session();
end:
+ poptFreeContext(pc);
return ret;
}
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
+ usage(stdout);
goto end;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
ret = destroy_session();
end:
+ poptFreeContext(pc);
return ret;
}
*/
int cmd_disable_channels(int argc, const char **argv)
{
- int opt, ret;
+ int opt, ret = CMD_SUCCESS;
static poptContext pc;
char *session_name = NULL;
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
- ret = CMD_SUCCESS;
+ usage(stdout);
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
if (opt_channels == NULL) {
ERR("Missing channel name(s).\n");
usage(stderr);
- ret = CMD_SUCCESS;
+ ret = CMD_ERROR;
goto end;
}
if (!opt_session_name) {
session_name = get_session_name();
if (session_name == NULL) {
- ret = -1;
+ ret = CMD_ERROR;
goto end;
}
} else {
ret = disable_channels(session_name);
end:
+ poptFreeContext(pc);
return ret;
}
*/
int cmd_disable_events(int argc, const char **argv)
{
- int opt, ret;
+ int opt, ret = CMD_SUCCESS;
static poptContext pc;
char *session_name = NULL;
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
- ret = CMD_SUCCESS;
+ usage(stdout);
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
if (opt_event_list == NULL && opt_disable_all == 0) {
ERR("Missing event name(s).\n");
usage(stderr);
- ret = CMD_SUCCESS;
+ ret = CMD_ERROR;
goto end;
}
if (!opt_session_name) {
session_name = get_session_name();
if (session_name == NULL) {
- ret = -1;
+ ret = CMD_ERROR;
goto end;
}
} else {
ret = disable_events(session_name);
end:
+ poptFreeContext(pc);
return ret;
}
*/
int cmd_enable_channels(int argc, const char **argv)
{
- int opt, ret;
+ int opt, ret = CMD_SUCCESS;
static poptContext pc;
char *session_name = NULL;
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
- ret = CMD_SUCCESS;
+ usage(stdout);
goto end;
case OPT_DISCARD:
chan.attr.overwrite = 0;
DBG("Channel set to overwrite");
break;
case OPT_SUBBUF_SIZE:
+ /* TODO Replace atol with strtol and check for errors */
chan.attr.subbuf_size = atol(poptGetOptArg(pc));
DBG("Channel subbuf size set to %" PRIu64, chan.attr.subbuf_size);
break;
case OPT_NUM_SUBBUF:
+ /* TODO Replace atoi with strtol and check for errors */
chan.attr.num_subbuf = atoi(poptGetOptArg(pc));
DBG("Channel subbuf num set to %" PRIu64, chan.attr.num_subbuf);
break;
case OPT_SWITCH_TIMER:
+ /* TODO Replace atoi with strtol and check for errors */
chan.attr.switch_timer_interval = atoi(poptGetOptArg(pc));
DBG("Channel switch timer interval set to %d", chan.attr.switch_timer_interval);
break;
case OPT_READ_TIMER:
+ /* TODO Replace atoi with strtol and check for errors */
chan.attr.read_timer_interval = atoi(poptGetOptArg(pc));
DBG("Channel read timer interval set to %d", chan.attr.read_timer_interval);
break;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
if (opt_channels == NULL) {
ERR("Missing channel name.\n");
usage(stderr);
- ret = CMD_SUCCESS;
+ ret = CMD_ERROR;
goto end;
}
if (!opt_session_name) {
session_name = get_session_name();
if (session_name == NULL) {
- ret = -1;
+ ret = CMD_ERROR;
goto end;
}
} else {
ret = enable_channel(session_name);
end:
+ poptFreeContext(pc);
return ret;
}
*/
int cmd_enable_events(int argc, const char **argv)
{
- int opt, ret;
+ int opt, ret = CMD_SUCCESS;
static poptContext pc;
char *session_name = NULL;
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
- ret = CMD_SUCCESS;
+ usage(stdout);
goto end;
case OPT_TRACEPOINT:
opt_event_type = LTTNG_EVENT_TRACEPOINT;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
if (opt_event_list == NULL && opt_enable_all == 0) {
ERR("Missing event name(s).\n");
usage(stderr);
- ret = CMD_SUCCESS;
+ ret = CMD_ERROR;
goto end;
}
if (!opt_session_name) {
session_name = get_session_name();
if (session_name == NULL) {
- ret = -1;
+ ret = CMD_ERROR;
goto end;
}
} else {
free(session_name);
}
+ poptFreeContext(pc);
return ret;
}
if (argc < 1) {
usage(stderr);
+ ret = CMD_ERROR;
goto end;
}
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
+ usage(stdout);
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
handle = lttng_create_handle(session_name, &domain);
if (handle == NULL) {
+ ret = CMD_FATAL;
goto end;
}
if (!opt_kernel && !opt_userspace) {
ret = list_sessions(NULL);
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
if (opt_kernel) {
ret = list_kernel_events();
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
if (opt_userspace) {
ret = list_ust_events();
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
/* List session attributes */
ret = list_sessions(session_name);
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
/* Domain listing */
if (opt_domain) {
ret = list_domains(session_name);
+ if (ret < 0) {
+ ret = CMD_ERROR;
+ }
goto end;
}
/* Channel listing */
ret = list_channels(opt_channel);
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
} else {
/* We want all domain(s) */
nb_domain = lttng_list_domains(session_name, &domains);
if (nb_domain < 0) {
- ret = nb_domain;
+ ret = CMD_ERROR;
goto end;
}
handle = lttng_create_handle(session_name, &domains[i]);
if (handle == NULL) {
+ ret = CMD_FATAL;
goto end;
}
ret = list_channels(opt_channel);
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
}
lttng_destroy_handle(handle);
+ poptFreeContext(pc);
return ret;
}
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
- ret = CMD_SUCCESS;
+ usage(stdout);
goto end;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
if (opt_session_name == NULL) {
ERR("Missing session name");
usage(stderr);
+ ret = CMD_ERROR;
goto end;
}
ret = set_session();
end:
+ poptFreeContext(pc);
return ret;
}
*/
int cmd_start(int argc, const char **argv)
{
- int opt, ret;
+ int opt, ret = CMD_SUCCESS;
static poptContext pc;
pc = poptGetContext(NULL, argc, argv, long_options, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
- ret = CMD_SUCCESS;
+ usage(stdout);
goto end;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
ret = start_tracing();
end:
+ poptFreeContext(pc);
return ret;
}
*/
int cmd_stop(int argc, const char **argv)
{
- int opt, ret;
+ int opt, ret = CMD_SUCCESS;
static poptContext pc;
pc = poptGetContext(NULL, argc, argv, long_options, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
- ret = CMD_SUCCESS;
+ usage(stdout);
goto end;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
ret = stop_tracing();
end:
+ poptFreeContext(pc);
return ret;
}
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(stderr);
- ret = CMD_SUCCESS;
+ usage(stdout);
goto end;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
MSG("\nlttng is free software and under the GPL license.");
end:
+ poptFreeContext(pc);
return ret;
}