X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fconf.cpp;h=44630b681135843eab58022294c89479dc003d19;hb=28ab034a2c3582d07d3423d2d746731f87d3969f;hp=e347c4b3afdd2361df09c877e464bc8038fd112a;hpb=48a4000561343808724f7cb5fa8c131877489ccd;p=lttng-tools.git diff --git a/src/bin/lttng/conf.cpp b/src/bin/lttng/conf.cpp index e347c4b3a..44630b681 100644 --- a/src/bin/lttng/conf.cpp +++ b/src/bin/lttng/conf.cpp @@ -1,11 +1,17 @@ /* - * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 EfficiOS Inc. * * SPDX-License-Identifier: GPL-2.0-only * */ #define _LGPL_SOURCE +#include "conf.hpp" + +#include +#include +#include + #include #include #include @@ -14,12 +20,6 @@ #include #include -#include -#include -#include - -#include "conf.h" - /* * Returns the path with '/CONFIG_FILENAME' added to it; * path will be NULL if an error occurs. @@ -167,18 +167,17 @@ int config_exists(const char *path) return S_ISREG(info.st_mode) || S_ISDIR(info.st_mode); } -static -int _config_read_session_name(const char *path, char **name) +static int _config_read_session_name(const char *path, char **name) { int ret = 0; FILE *fp; char var[NAME_MAX], *session_name; #if (NAME_MAX == 255) -#define NAME_MAX_SCANF_IS_A_BROKEN_API "254" +#define NAME_MAX_SCANF_IS_A_BROKEN_API "254" #endif - session_name = (char *) zmalloc(NAME_MAX); + session_name = calloc(NAME_MAX); if (session_name == NULL) { ret = -ENOMEM; ERR("Out of memory"); @@ -192,9 +191,11 @@ int _config_read_session_name(const char *path, char **name) } while (!feof(fp)) { - if ((ret = fscanf(fp, "%" NAME_MAX_SCANF_IS_A_BROKEN_API - "[^'=']=%" NAME_MAX_SCANF_IS_A_BROKEN_API "s\n", - var, session_name)) != 2) { + if ((ret = fscanf(fp, + "%" NAME_MAX_SCANF_IS_A_BROKEN_API + "[^'=']=%" NAME_MAX_SCANF_IS_A_BROKEN_API "s\n", + var, + session_name)) != 2) { if (ret == -1) { ERR("Missing session=NAME in config file."); goto error_close;