[systemd-commits] src/cryptsetup src/efi-boot-generator src/fstab-generator

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Sat May 16 15:11:44 PDT 2015


 src/cryptsetup/cryptsetup-generator.c       |    6 +++---
 src/efi-boot-generator/efi-boot-generator.c |   12 ++++++------
 src/fstab-generator/fstab-generator.c       |   12 ++++++------
 3 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 4652c56c59682f153c34d30b410534e4f0c6fd6a
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat May 16 18:11:12 2015 -0400

    Use fflush_and_check() in more places

diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 755ee5d..6fad8ad 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -176,9 +176,9 @@ static int create_disk(
                         "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
                         name);
 
-        fflush(f);
-        if (ferror(f))
-                return log_error_errno(errno, "Failed to write file %s: %m", p);
+        r = fflush_and_check(f);
+        if (r < 0)
+                return log_error_errno(r, "Failed to write file %s: %m", p);
 
         from = strjoina("../", n);
 
diff --git a/src/efi-boot-generator/efi-boot-generator.c b/src/efi-boot-generator/efi-boot-generator.c
index 128df85..42b21f5 100644
--- a/src/efi-boot-generator/efi-boot-generator.c
+++ b/src/efi-boot-generator/efi-boot-generator.c
@@ -123,9 +123,9 @@ int main(int argc, char *argv[]) {
                 "Options=umask=0077,noauto\n",
                 what);
 
-        fflush(f);
-        if (ferror(f)) {
-                log_error_errno(errno, "Failed to write mount unit file: %m");
+        r = fflush_and_check(f);
+        if (r < 0) {
+                log_error_errno(r, "Failed to write mount unit file: %m");
                 return EXIT_FAILURE;
         }
 
@@ -144,9 +144,9 @@ int main(int argc, char *argv[]) {
               "Where=/boot\n"
               "TimeoutIdleSec=120\n", f);
 
-        fflush(f);
-        if (ferror(f)) {
-                log_error_errno(errno, "Failed to write automount unit file: %m");
+        r = fflush_and_check(f);
+        if (r < 0) {
+                log_error_errno(r, "Failed to write automount unit file: %m");
                 return EXIT_FAILURE;
         }
 
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 167ec60..11df81a 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -275,9 +275,9 @@ static int add_mount(
         if (!isempty(filtered) && !streq(filtered, "defaults"))
                 fprintf(f, "Options=%s\n", filtered);
 
-        fflush(f);
-        if (ferror(f))
-                return log_error_errno(errno, "Failed to write unit file %s: %m", unit);
+        r = fflush_and_check(f);
+        if (r < 0)
+                return log_error_errno(r, "Failed to write unit file %s: %m", unit);
 
         if (!noauto && post) {
                 lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
@@ -324,9 +324,9 @@ static int add_mount(
                 if (r < 0)
                         return r;
 
-                fflush(f);
-                if (ferror(f))
-                        return log_error_errno(errno, "Failed to write unit file %s: %m", automount_unit);
+                r = fflush_and_check(f);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to write unit file %s: %m", automount_unit);
 
                 free(lnk);
                 lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);



More information about the systemd-commits mailing list