X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttng%2Futils.c;h=ee0e297b16c80414c8d9a9a954f82aff8637036c;hb=63371d1e4ff3148287a04e14b468c4234e3d0182;hp=f9edb173bb88271c39cdfea9a676003b743de1a2;hpb=beb8c75afd91bc32f2e7a9c124c9a21ecffd1486;p=lttng-tools.git diff --git a/lttng/utils.c b/lttng/utils.c index f9edb173b..ee0e297b1 100644 --- a/lttng/utils.c +++ b/lttng/utils.c @@ -1,10 +1,10 @@ /* * Copyright (c) 2011 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; only version 2 + * of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -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; } @@ -82,19 +53,24 @@ error: * * Get session name and set it for the lttng control lib. */ -int set_session_name(void) +int set_session_name(char *name) { int ret; char *session_name; - session_name = get_session_name(); - if (session_name == NULL) { - ret = -1; - goto error; + 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;