goto error;
}
- if (opt_loglevel[0] != '\0') {
+ if (opt_loglevel) {
MSG("Kernel loglevels are not supported.");
ret = CMD_UNDEFINED;
goto error;
}
ev.loglevel_type = opt_loglevel_type;
- strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN);
- ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+ if (opt_loglevel) {
+ strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN);
+ ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+ } else {
+ ev.loglevel[0] = '\0';
+ }
} else {
ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
goto error;
*/
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;
}