From dacd6cee76a08331b8c8616c5f30f70ee49aa2f9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 29 Jul 2015 20:31:07 +0200 Subject: tree-wide: port everything over to fflush_and_check() Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers. --- src/gpt-auto-generator/gpt-auto-generator.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/gpt-auto-generator') diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 22dfd5496d..9fc576fb45 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -97,9 +97,9 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi id, what, rw ? "" : "read-only", id); - 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); @@ -223,9 +223,9 @@ static int add_mount( else fprintf(f, "Options=%s\n", rw ? "rw" : "ro"); - fflush(f); - if (ferror(f)) - return log_error_errno(errno, "Failed to write unit file %s: %m", p); + r = fflush_and_check(f); + if (r < 0) + return log_error_errno(r, "Failed to write unit file %s: %m", p); if (post) { lnk = strjoin(arg_dest, "/", post, ".requires/", unit, NULL); @@ -301,9 +301,9 @@ static int add_automount( where, (unsigned long long)timeout / USEC_PER_SEC); - fflush(f); - if (ferror(f)) - return log_error_errno(errno, "Failed to write unit file %s: %m", p); + r = fflush_and_check(f); + if (r < 0) + return log_error_errno(r, "Failed to write unit file %s: %m", p); lnk = strjoin(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/", unit, NULL); if (!lnk) @@ -426,9 +426,9 @@ static int add_swap(const char *path) { "What=%s\n", path); - 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); lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL); if (!lnk) -- cgit v1.2.3-54-g00ecf