summaryrefslogtreecommitdiff
path: root/src/shared/fileio.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-03 20:04:57 +0200
committerLennart Poettering <lennart@poettering.net>2013-04-03 20:12:57 +0200
commitfec6fc6baeca4d306cc70a61a08aef7b69da0172 (patch)
treefbb44a6f01535699ff87d658e17eba36ec5eb80c /src/shared/fileio.c
parent768100efd57ffbbefe9beaa33d1dd5ecc7f69173 (diff)
fileio: don't check for errors more often than really necessary
Diffstat (limited to 'src/shared/fileio.c')
-rw-r--r--src/shared/fileio.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/shared/fileio.c b/src/shared/fileio.c
index 2ccb9e7edc..400a416162 100644
--- a/src/shared/fileio.c
+++ b/src/shared/fileio.c
@@ -35,9 +35,7 @@ int write_string_file(const char *fn, const char *line) {
return -errno;
errno = 0;
- if (fputs(line, f) < 0)
- return errno ? -errno : -EIO;
-
+ fputs(line, f);
if (!endswith(line, "\n"))
fputc('\n', f);
@@ -64,11 +62,7 @@ int write_string_file_atomic(const char *fn, const char *line) {
fchmod_umask(fileno(f), 0644);
errno = 0;
- if (fputs(line, f) < 0) {
- r = -errno;
- goto finish;
- }
-
+ fputs(line, f);
if (!endswith(line, "\n"))
fputc('\n', f);
@@ -83,7 +77,6 @@ int write_string_file_atomic(const char *fn, const char *line) {
r = 0;
}
-finish:
if (r < 0)
unlink(p);
@@ -571,12 +564,9 @@ int write_env_file(const char *fname, char **l) {
fflush(f);
- if (ferror(f)) {
- if (errno > 0)
- r = -errno;
- else
- r = -EIO;
- } else {
+ if (ferror(f))
+ r = errno ? -errno : -EIO;
+ else {
if (rename(p, fname) < 0)
r = -errno;
else