X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=4def4e7a2ee3aa050599a661aeb162d5c2d179cb;hp=4b8a07c48fc6aa29dc316711f8cf0774c6fbe334;hb=ae8564917fa3cb3497ec17951d8ac0ee28de9c81;hpb=0cda4f28041a221757fa2dfa8e91706e7a548090 diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 4b8a07c48..4def4e7a2 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -389,10 +389,10 @@ static int list_channels(const char *channel_name) count = lttng_list_channels(handle, &channels); if (count < 0) { ret = count; - goto error; + goto error_channels; } else if (count == 0) { - MSG("No channel found"); - goto end; + ERR("Channel %s not found", channel_name); + goto error; } if (channel_name == NULL) { @@ -421,14 +421,16 @@ static int list_channels(const char *channel_name) } if (!chan_found && channel_name != NULL) { - MSG("Channel %s not found", channel_name); + ERR("Channel %s not found", channel_name); + goto error; } -end: - free(channels); ret = CMD_SUCCESS; error: + free(channels); + +error_channels: return ret; } @@ -475,7 +477,7 @@ static int list_sessions(const char *session_name) free(sessions); if (!session_found && session_name != NULL) { - MSG("Session %s not found", session_name); + ERR("Session %s not found", session_name); } if (session_name == NULL) { @@ -541,6 +543,7 @@ int cmd_list(int argc, const char **argv) if (argc < 1) { usage(stderr); + ret = CMD_ERROR; goto end; } @@ -550,14 +553,13 @@ int cmd_list(int argc, const char **argv) 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); @@ -579,6 +581,7 @@ int cmd_list(int argc, const char **argv) handle = lttng_create_handle(session_name, &domain); if (handle == NULL) { + ret = CMD_FATAL; goto end; } @@ -586,18 +589,21 @@ int cmd_list(int argc, const char **argv) 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; } } @@ -605,12 +611,16 @@ int cmd_list(int argc, const char **argv) /* 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; } @@ -618,13 +628,14 @@ int cmd_list(int argc, const char **argv) /* 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; } @@ -646,11 +657,13 @@ int cmd_list(int argc, const char **argv) 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; } } @@ -663,5 +676,6 @@ end: } lttng_destroy_handle(handle); + poptFreeContext(pc); return ret; }