Fix: lttng-destroy: string formating error when default session is unset
[lttng-tools.git] / src / bin / lttng / utils.cpp
index 403ee018579f755819877ce5d25109b7f94f24a4..45fe256a579d092b4a1d92ddd81e26459b315a1e 100644 (file)
@@ -8,6 +8,7 @@
 #define _LGPL_SOURCE
 #include "command.hpp"
 #include "conf.hpp"
+#include "exception.hpp"
 #include "utils.hpp"
 
 #include <common/defaults.hpp>
@@ -715,15 +716,14 @@ lttng::cli::session_list lttng::cli::list_sessions(const struct session_spec& sp
                                lttng::make_unique_wrapper<char, lttng::memory::free>(
                                        get_session_name());
 
-                       if (configured_name) {
-                               const struct lttng::cli::session_spec new_spec(
-                                       lttng::cli::session_spec::type::NAME,
-                                       configured_name.get());
-
-                               return list_sessions(new_spec);
+                       if (!configured_name) {
+                               LTTNG_THROW_CLI_NO_DEFAULT_SESSION();
                        }
 
-                       return lttng::cli::session_list();
+                       const struct lttng::cli::session_spec new_spec(
+                               lttng::cli::session_spec::type::NAME, configured_name.get());
+
+                       return list_sessions(new_spec);
                }
 
                return get_sessions(
This page took 0.022465 seconds and 4 git commands to generate.