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.
This commit is contained in:
+2
-8
@@ -28,21 +28,15 @@
|
||||
#include "fileio.h"
|
||||
|
||||
int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
|
||||
|
||||
assert(f);
|
||||
assert(line);
|
||||
|
||||
errno = 0;
|
||||
|
||||
fputs(line, f);
|
||||
if (enforce_newline && !endswith(line, "\n"))
|
||||
fputc('\n', f);
|
||||
|
||||
fflush(f);
|
||||
|
||||
if (ferror(f))
|
||||
return errno ? -errno : -EIO;
|
||||
|
||||
return 0;
|
||||
return fflush_and_check(f);
|
||||
}
|
||||
|
||||
static int write_string_file_atomic(const char *fn, const char *line, bool enforce_newline) {
|
||||
|
||||
Reference in New Issue
Block a user