X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttng%2Futils.c;h=1b2138cedbd1531afe12db32a4cb463f84670afc;hb=97b1a726be0f1779f5508543c58521d774312e73;hp=109532a4f60da1d94cf11ec5b907fc49ea68d2ca;hpb=5440dc4282b3186641a8886dc05f6cf5641b5191;p=lttng-tools.git diff --git a/lttng/utils.c b/lttng/utils.c index 109532a4f..1b2138ced 100644 --- a/lttng/utils.c +++ b/lttng/utils.c @@ -22,33 +22,6 @@ #include "conf.h" -/* - * get_config_file_path - * - * Return absolute path to the configuration file. - */ -char *get_config_file_path(void) -{ - char *alloc_path, *path = NULL; - - /* Get path to config directory */ - alloc_path = config_get_default_path(); - if (alloc_path == NULL) { - goto error; - } - - /* Get path to config file */ - path = config_generate_dir_path(alloc_path); - if (path == NULL) { - goto free_alloc_path; - } - -free_alloc_path: - free(alloc_path); -error: - return path; -} - /* * get_session_name * @@ -60,7 +33,7 @@ char *get_session_name(void) char *path, *session_name = NULL; /* Get path to config file */ - path = get_config_file_path(); + path = config_get_default_path(); if (path == NULL) { goto error; } @@ -68,11 +41,9 @@ char *get_session_name(void) /* Get session name from config */ session_name = config_read_session_name(path); if (session_name == NULL) { - goto free_path; + goto error; } -free_path: - free(path); error: return session_name; } @@ -87,18 +58,19 @@ int set_session_name(char *name) int ret; char *session_name; - if (name != NULL) { - session_name = name; - } else { + if (!name) { session_name = get_session_name(); if (session_name == NULL) { ret = -1; goto error; } + } else { + session_name = name; } lttng_set_session_name(session_name); - free(session_name); + if (!name) + free(session_name); ret = 0;