Fix: Don't report an error when listing a session with no channels
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index d882b074d54cd4f0348365ab4adb218ce263c48b..17091de09ec66d9bd5b6028bbf04b90c7a99d5ff 100644 (file)
@@ -2388,6 +2388,10 @@ ssize_t cmd_list_domains(struct ltt_session *session,
                }
        }
 
+       if (!nb_dom) {
+               goto end;
+       }
+
        *domains = zmalloc(nb_dom * sizeof(struct lttng_domain));
        if (*domains == NULL) {
                ret = LTTNG_ERR_FATAL;
@@ -2413,7 +2417,7 @@ ssize_t cmd_list_domains(struct ltt_session *session,
                        }
                }
        }
-
+end:
        return nb_dom;
 
 error:
@@ -2447,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;
        }
@@ -2465,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;
This page took 0.032764 seconds and 5 git commands to generate.