summaryrefslogtreecommitdiff
path: root/src/basic/util.h
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-09-09 15:45:03 +0200
committerDaniel Mack <github@zonque.org>2015-09-09 15:45:03 +0200
commit01da201420edfb2a57e384f109def05f25429305 (patch)
tree1c3090f3b5200ba62613285553afa0f7a6d30b9a /src/basic/util.h
parent37b76fd3ee5a03d76786e7bd1e0f8596e6ce47d6 (diff)
parent74ca738f6a01fb5fc19c5c3899f5cb1fdc1d7f68 (diff)
Merge pull request #1218 from poettering/safe-fclose
util: introduce safe_fclose() and port everything over to it
Diffstat (limited to 'src/basic/util.h')
-rw-r--r--src/basic/util.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/basic/util.h b/src/basic/util.h
index 8313675477..5fa44b5cf3 100644
--- a/src/basic/util.h
+++ b/src/basic/util.h
@@ -149,6 +149,9 @@ void safe_close_pair(int p[]);
void close_many(const int fds[], unsigned n_fd);
+int fclose_nointr(FILE *f);
+FILE* safe_fclose(FILE *f);
+
int parse_size(const char *t, off_t base, off_t *size);
int parse_boolean(const char *v) _pure_;
@@ -514,7 +517,10 @@ static inline void close_pairp(int (*p)[2]) {
safe_close_pair(*p);
}
-DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, fclose);
+static inline void fclosep(FILE **f) {
+ safe_fclose(*f);
+}
+
DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, pclose);
DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir);
DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent);