Also convert these to use take_fdopendir().
_cleanup_(home_setup_undo) HomeSetup setup = HOME_SETUP_INIT;
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL;
_cleanup_(closedirp) DIR *d = NULL;
- int r, copy;
+ _cleanup_close_ int copy = -1;
+ int r;
assert(h);
assert(user_record_storage(h) == USER_CIFS);
if (copy < 0)
return -errno;
- d = fdopendir(copy);
- if (!d) {
- safe_close(copy);
+ d = take_fdopendir(©);
+ if (!d)
return -errno;
- }
errno = 0;
if (readdir_no_dot(d))
goto fail;
}
} else {
- int dfd;
+ _cleanup_close_ int dfd = -1;
/* If there's no path specified, then we use the top-level fd itself. We duplicate the fd here, since
* opendir() will take possession of the fd, and close it, which we don't want. */
goto fail;
}
- d = fdopendir(dfd);
+ d = take_fdopendir(&dfd);
if (!d) {
r = -errno;
- safe_close(dfd);
goto fail;
}