From ade7ce5245446944d27824943142773f7e4d0674 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 7 Nov 2014 17:58:15 -0500 Subject: [PATCH] Fix: Don't report an error when listing a session with no channels MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/bin/lttng-sessiond/cmd.c | 8 ++------ src/bin/lttng-sessiond/main.c | 2 +- src/bin/lttng/commands/list.c | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 98e090539..17091de09 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2451,12 +2451,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; } @@ -2469,10 +2469,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 c8484b93c..9542e650d 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3501,7 +3501,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 7c3211a59..12499ee40 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -1207,7 +1207,7 @@ static int list_channels(const char *channel_name) } } else { /* Pretty print */ - if (channel_name == NULL) { + if (count) { MSG("Channels:\n-------------"); } -- 2.34.1