summaryrefslogtreecommitdiffstats
path: root/Settings.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-03-13 18:15:20 +0100
committerChristian Göttsche <cgzones@googlemail.com>2021-03-13 18:15:20 +0100
commit1275139795e9b751af13ec10f96806d852591e39 (patch)
treee30e39bcc066588911205050e6ebba9d9537ef80 /Settings.c
parent23797e730ef79408deb055afb48e6470824f31d9 (diff)
Settings_write: fix return value on error
Return a negative errno on fprintf() or flcose() failure, not a return value of ferror() or flcose().
Diffstat (limited to 'Settings.c')
-rw-r--r--Settings.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Settings.c b/Settings.c
index 62fadf07..83b6cf37 100644
--- a/Settings.c
+++ b/Settings.c
@@ -333,9 +333,15 @@ int Settings_write(const Settings* this) {
fprintf(fd, "topology_affinity=%d\n", (int) this->topologyAffinity);
#endif
- int r1 = ferror(fd);
- int r2 = fclose(fd);
- return r1 ? r1 : r2;
+ int r = 0;
+
+ if (ferror(fd) != 0)
+ r = (errno != 0) ? -errno : -EBADF;
+
+ if (fclose(fd) != 0)
+ r = r ? r : -errno;
+
+ return r;
}
Settings* Settings_new(int initialCpuCount) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy