summaryrefslogtreecommitdiff
path: root/src/dbus1-generator
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-22 12:44:17 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-22 12:44:17 +0200
commit0975b63fb31263e535a2d26ed41e66e23f468bc5 (patch)
treef16a919cbc592167af4120d592fd1b09557e0142 /src/dbus1-generator
parent337ce7442a0602116c6253ebf202bd34f675f627 (diff)
dbus1-generator: properly free the FILE*
Also, rework the code to make use of fflush_and_check(). Issue discovered by Simon Danner.
Diffstat (limited to 'src/dbus1-generator')
-rw-r--r--src/dbus1-generator/dbus1-generator.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index e1ffc5515f..3c4522b589 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -40,6 +40,7 @@ static int create_dbus_files(
_cleanup_free_ char *b = NULL, *s = NULL, *lnk = NULL;
_cleanup_fclose_ FILE *f = NULL;
+ int r;
assert(path);
assert(name);
@@ -100,12 +101,15 @@ static int create_dbus_files(
}
}
- fflush(f);
- if (ferror(f)) {
- log_error("Failed to write %s: %m", a);
- return -errno;
+ r = fflush_and_check(f);
+ if (r < 0) {
+ log_error("Failed to write %s: %s", a, strerror(-r));
+ return r;
}
+ fclose(f);
+ f = NULL;
+
service = s;
}
@@ -134,10 +138,10 @@ static int create_dbus_files(
name,
service);
- fflush(f);
- if (ferror(f)) {
- log_error("Failed to write %s: %m", b);
- return -errno;
+ r = fflush_and_check(f);
+ if (r < 0) {
+ log_error("Failed to write %s: %s", b, strerror(-r));
+ return r;
}
lnk = strjoin(arg_dest_late, "/" SPECIAL_BUSNAMES_TARGET ".wants/", name, ".busname", NULL);