util: add safe_closedir() similar to safe_fclose()

This commit is contained in:
Lennart Poettering
2015-09-22 16:30:24 +02:00
parent f6d9c616b6
commit ed0d40229b
5 changed files with 41 additions and 4 deletions
+11
View File
@@ -354,6 +354,17 @@ FILE* safe_fclose(FILE *f) {
return NULL;
}
DIR* safe_closedir(DIR *d) {
if (d) {
PROTECT_ERRNO;
assert_se(closedir(d) >= 0 || errno != EBADF);
}
return NULL;
}
int unlink_noerrno(const char *path) {
PROTECT_ERRNO;
int r;
+1
View File
@@ -151,6 +151,7 @@ void close_many(const int fds[], unsigned n_fd);
int fclose_nointr(FILE *f);
FILE* safe_fclose(FILE *f);
DIR* safe_closedir(DIR *f);
int parse_size(const char *t, uint64_t base, uint64_t *size);