PERROR("snprintf session name");
goto error;
}
- session_name = strdup(DEFAULT_SESSION_NAME);
- if (session_name == NULL) {
- PERROR("strdup session name");
- goto error;
- }
+ session_name = session_name_date;
DBG("Auto session name set to %s", session_name_date);
} else {
+ if (strncmp(opt_session_name, DEFAULT_SESSION_NAME,
+ strlen(DEFAULT_SESSION_NAME)) == 0 &&
+ strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME)) {
+ ERR("%s is a reserved keyword for default session(s)",
+ DEFAULT_SESSION_NAME);
+ ret = CMD_ERROR;
+ goto error;
+ }
session_name = opt_session_name;
ret = snprintf(session_name_date, sizeof(session_name_date),
"%s-%s", session_name, datetime);
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
switch (-ret) {
- case LTTCOMM_EXIST_SESS:
+ case LTTNG_ERR_EXIST_SESS:
WARN("Session %s already exists", session_name);
break;
}
goto error;
}
- if (opt_session_name == NULL) {
- MSG("Session %s created.", session_name_date);
- } else {
- MSG("Session %s created.", session_name);
- }
+ MSG("Session %s created.", session_name);
MSG("Traces will be written in %s", print_str_url);
if (opt_ctrl_url || opt_data_url) {
}
}
- if (opt_session_name == NULL) {
- free(session_name);
- session_name = session_name_date;
- }
-
/* Init lttng session config */
ret = config_init(session_name);
if (ret < 0) {
ret = CMD_SUCCESS;
error:
- if (opt_session_name == NULL && session_name != session_name_date) {
- free(session_name);
- }
-
if (alloc_url) {
free(alloc_url);
}
if (traces_path) {
free(traces_path);
}
+ free(alloc_path);
if (ret < 0) {
ERR("%s", lttng_strerror(ret));