Fix auto session path duplication
[lttng-tools.git] / lttng / commands / create.c
index b8bbdb7e7ba453434279a320b538fddb36dd9f9d..16e3b4d8628fdb3cd73c9e9dae6d7dd51bd496e9 100644 (file)
@@ -98,8 +98,14 @@ static int create_session()
                        goto error;
                }
 
-               ret = asprintf(&traces_path, "%s/" LTTNG_DEFAULT_TRACE_DIR_NAME
-                               "/%s-%s", alloc_path, session_name, datetime);
+               if (have_name) {
+                       ret = asprintf(&traces_path, "%s/" LTTNG_DEFAULT_TRACE_DIR_NAME
+                                       "/%s-%s", alloc_path, session_name, datetime);
+               } else {
+                       ret = asprintf(&traces_path, "%s/" LTTNG_DEFAULT_TRACE_DIR_NAME
+                                       "/%s", alloc_path, session_name);
+               }
+
                if (ret < 0) {
                        perror("asprintf trace dir name");
                        goto error;
@@ -125,8 +131,6 @@ static int create_session()
        MSG("Session %s created.", session_name);
        if (have_name) {
                MSG("Traces will be written in %s" , traces_path);
-       } else {
-               MSG("Traces will be written in %s/%s", traces_path, session_name);
        }
 
        ret = CMD_SUCCESS;
This page took 0.023069 seconds and 4 git commands to generate.