[systemd-devel] [PATCH] dbus1-generator: Always close file in create_dbus_files

Simon Danner danner.simon at gmail.com
Thu Aug 21 23:19:20 PDT 2014


In the !service case, the first file doesn't get closed automatically,
since the second one uses the same FILE*. Close it explicitly.
Found by cppcheck

Signed-off-by: Simon Danner <danner.simon at gmail.com>
---
 src/dbus1-generator/dbus1-generator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index e1ffc55..e401471 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -100,8 +100,7 @@ static int create_dbus_files(
                         }
                 }
 
-                fflush(f);
-                if (ferror(f)) {
+                if (fclose(f)) {
                         log_error("Failed to write %s: %m", a);
                         return -errno;
                 }
-- 
2.1.0





More information about the systemd-devel mailing list