From: Jérémie Galarneau Date: Fri, 7 Nov 2014 23:07:07 +0000 (-0500) Subject: Fix: Don't report an error when listing a session with no channels X-Git-Tag: v2.4.3~40 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=22aca9f6954179e10aeed2e1a5719a2f13600eae;p=lttng-tools.git Fix: Don't report an error when listing a session with no channels The LTTng sessiond daemon reports an error when the list_channel command is invoked on a session which only has a metadata channel. The error lies in assuming that a session which has an enabled domains also has (user-visible) channels. The metadata channel should be listed in a future fix. Fixes #855 Signed-off-by: Jérémie Galarneau Conflicts: src/bin/lttng/commands/list.c --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 8f8278eec..022d5cee1 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2388,12 +2388,12 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session, session->ust_session->domain_global.channels); } DBG3("Number of UST global channels %zd", nb_chan); - if (nb_chan <= 0) { + if (nb_chan < 0) { ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; + goto error; } break; default: - *channels = NULL; ret = LTTNG_ERR_UND; goto error; } @@ -2406,10 +2406,6 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session, } list_lttng_channels(domain, session, *channels); - } else { - *channels = NULL; - /* Ret value was set in the domain switch case */ - goto error; } return nb_chan; diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index a95f269d0..e8e451152 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3315,7 +3315,7 @@ skip_domain: case LTTNG_LIST_CHANNELS: { int nb_chan; - struct lttng_channel *channels; + struct lttng_channel *channels = NULL; nb_chan = cmd_list_channels(cmd_ctx->lsm->domain.type, cmd_ctx->session, &channels); diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 0b1eff265..dd39c4fc5 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -688,7 +688,7 @@ static int list_channels(const char *channel_name) goto error_channels; } - if (channel_name == NULL) { + if (count) { MSG("Channels:\n-------------"); }