From c119cdb1e4cf3e0fd5080160a5c4286cd7391714 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 24 Sep 2012 17:40:36 -0400 Subject: [PATCH] Fix: Returned code when listing kernel channel Backported from master branch. See bug #260. Signed-off-by: David Goulet --- src/bin/lttng-sessiond/main.c | 8 ++++++++ src/bin/lttng/commands/list.c | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index d29de9d45..d735be833 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3226,6 +3226,9 @@ static ssize_t cmd_list_channels(int domain, struct ltt_session *session, nb_chan = session->kernel_session->channel_count; } DBG3("Number of kernel channels %zd", nb_chan); + if (nb_chan <= 0) { + ret = LTTCOMM_KERN_CHAN_NOT_FOUND; + } break; case LTTNG_DOMAIN_UST: if (session->ust_session != NULL) { @@ -3233,6 +3236,9 @@ static 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) { + ret = LTTCOMM_UST_CHAN_NOT_FOUND; + } break; default: *channels = NULL; @@ -3250,6 +3256,8 @@ static 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/commands/list.c b/src/bin/lttng/commands/list.c index 50d6114c3..71843fdab 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -25,6 +25,8 @@ #include "../command.h" +#include + static int opt_userspace; static int opt_kernel; static char *opt_channel; @@ -412,11 +414,21 @@ static int list_channels(const char *channel_name) count = lttng_list_channels(handle, &channels); if (count < 0) { - ret = count; + switch (-count) { + case LTTCOMM_KERN_CHAN_NOT_FOUND: + ret = CMD_SUCCESS; + WARN("No kernel channel"); + break; + case LTTCOMM_UST_CHAN_NOT_FOUND: + ret = CMD_SUCCESS; + WARN("No UST channel"); + break; + default: + /* We had a real error */ + ret = count; + ERR("%s", lttng_strerror(ret)); + } goto error_channels; - } else if (count == 0) { - ERR("Channel %s not found", channel_name); - goto error; } if (channel_name == NULL) { -- 2.34.1