X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng%2Fconf.c;h=5479a3cd016e740100d14198e210d45769da013d;hp=e6cc7746c6124978b1561fa40fe413d044d39a5f;hb=778ca3dd8ad4b1f79ab64aec0abf1134f4bcd1a8;hpb=0d63dd195f9b665bc46a23ec918b20bee7a5d96b diff --git a/lttng/conf.c b/lttng/conf.c index e6cc7746c..5479a3cd0 100644 --- a/lttng/conf.c +++ b/lttng/conf.c @@ -3,8 +3,8 @@ * * 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. + * 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 @@ -102,21 +102,26 @@ error: * * Append data to the config file in file_path */ -static void write_config(char *file_path, size_t size, char *data) +static int write_config(char *file_path, size_t size, char *data) { FILE *fp; + size_t len; + int ret = 0; fp = open_config(file_path, "a"); if (fp == NULL) { - goto error; + ret = -1; + goto end; } /* Write session name into config file */ - fwrite(data, size, 1, fp); + len = fwrite(data, size, 1, fp); + if (len < 1) { + ret = -1; + } fclose(fp); - -error: - return; +end: + return ret; } /* @@ -209,10 +214,7 @@ int config_add_session_name(char *path, char *name) if (ret < 0) { goto error; } - - write_config(path, ret, session_name); - ret = 0; - + ret = write_config(path, ret, session_name); error: return ret; }