projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add UST test binaries to gitignore
[lttng-tools.git]
/
lttng
/
conf.c
diff --git
a/lttng/conf.c
b/lttng/conf.c
index 526988468aa93ac6a576f92f3a1c27416e1c5822..7337d92cade22a4b143ad57932390cd5ad779cea 100644
(file)
--- a/
lttng/conf.c
+++ b/
lttng/conf.c
@@
-63,7
+63,6
@@
static FILE *open_config(char *path, const char *mode)
fp = fopen(file_path, mode);
if (fp == NULL) {
fp = fopen(file_path, mode);
if (fp == NULL) {
- perror("config file");
goto error;
}
goto error;
}
@@
-102,21
+101,26
@@
error:
*
* Append data to the config file in file_path
*/
*
* 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;
{
FILE *fp;
+ size_t len;
+ int ret = 0;
fp = open_config(file_path, "a");
if (fp == NULL) {
fp = open_config(file_path, "a");
if (fp == NULL) {
- goto error;
+ ret = -1;
+ goto end;
}
/* Write session name into config file */
}
/* Write session name into config file */
- fwrite(data, size, 1, fp);
+ len = fwrite(data, size, 1, fp);
+ if (len < 1) {
+ ret = -1;
+ }
fclose(fp);
fclose(fp);
-
-error:
- return;
+end:
+ return ret;
}
/*
}
/*
@@
-166,6
+170,7
@@
char *config_read_session_name(char *path)
fp = open_config(path, "r");
if (fp == NULL) {
ERR("Can't find valid lttng config %s/.lttngrc", path);
fp = open_config(path, "r");
if (fp == NULL) {
ERR("Can't find valid lttng config %s/.lttngrc", path);
+ MSG("Did you create a session? (lttng create <my_sesion>)");
goto error;
}
goto error;
}
@@
-209,10
+214,7
@@
int config_add_session_name(char *path, char *name)
if (ret < 0) {
goto error;
}
if (ret < 0) {
goto error;
}
-
- write_config(path, ret, session_name);
- ret = 0;
-
+ ret = write_config(path, ret, session_name);
error:
return ret;
}
error:
return ret;
}
This page took
0.022923 seconds
and
4
git commands to generate.