X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Futils.c;h=599f7ff819f3cf4855ca9f7b47ae27d6343c0493;hb=8aeeba8f5a90c8352ec9826f564cb47e164e0e9a;hp=ad13d3277eb4106c7320bfbe3563d53ba57c1d72;hpb=0f907de1f20c91a2bd1a08ee4d50332d1958754b;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/utils.c b/src/bin/lttng-relayd/utils.c index ad13d3277..599f7ff81 100644 --- a/src/bin/lttng-relayd/utils.c +++ b/src/bin/lttng-relayd/utils.c @@ -1,23 +1,12 @@ /* - * Copyright (C) 2013 - Julien Desfossez - * David Goulet + * Copyright (C) 2013 Julien Desfossez + * Copyright (C) 2013 David Goulet * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, version 2 only, as - * published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE -#include +#define _LGPL_SOURCE #include #include #include @@ -29,44 +18,29 @@ #include "lttng-relayd.h" #include "utils.h" -/* - * Returns the HOME directory path. Caller MUST NOT free(3) the return pointer. - */ -static char *get_default_path(void) -{ - return getenv("HOME"); -} - -static char *create_output_path_auto(char *path_name) +static char *create_output_path_auto(const char *path_name) { int ret; char *traces_path = NULL; - char *alloc_path = NULL; - char *default_path; + const char *default_path; - default_path = get_default_path(); + default_path = utils_get_home_dir(); if (default_path == NULL) { ERR("Home path not found.\n \ Please specify an output path using -o, --output PATH"); goto exit; } - alloc_path = strdup(default_path); - if (alloc_path == NULL) { - PERROR("Path allocation"); - goto exit; - } ret = asprintf(&traces_path, "%s/" DEFAULT_TRACE_DIR_NAME - "/%s", alloc_path, path_name); + "/%s", default_path, path_name); if (ret < 0) { PERROR("asprintf trace dir name"); goto exit; } exit: - free(alloc_path); return traces_path; } -static char *create_output_path_noauto(char *path_name) +static char *create_output_path_noauto(const char *path_name) { int ret; char *traces_path = NULL; @@ -92,9 +66,9 @@ exit: * * Return the allocated string containing the path name or else NULL. */ -char *create_output_path(char *path_name) +char *create_output_path(const char *path_name) { - assert(path_name); + LTTNG_ASSERT(path_name); if (opt_output_path == NULL) { return create_output_path_auto(path_name);