]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
exec-util: use fflush_and_check() where appropriate
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Oct 2018 18:14:51 +0000 (20:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Oct 2018 19:23:34 +0000 (21:23 +0200)
src/basic/exec-util.c

index aa26902a20cb50d7ce6d5edb2586df2b50835c7a..32c6418482278f4ea9d6d74cb45f7f6d4c243d52 100644 (file)
@@ -268,8 +268,8 @@ static int gather_environment_generate(int fd, void *arg) {
 }
 
 static int gather_environment_collect(int fd, void *arg) {
-        char ***env = arg;
         _cleanup_fclose_ FILE *f = NULL;
+        char ***env = arg;
         int r;
 
         /* Write out a series of env=cescape(VAR=value) assignments to fd. */
@@ -286,8 +286,9 @@ static int gather_environment_collect(int fd, void *arg) {
         if (r < 0)
                 return r;
 
-        if (ferror(f))
-                return errno > 0 ? -errno : -EIO;
+        r = fflush_and_check(f);
+        if (r < 0)
+                return r;
 
         return 0;
 }