mirror of
https://github.com/systemd/systemd
synced 2024-10-15 12:34:37 +00:00
*: use _cleanup_close_ with fdopendir() where trivial
Also convert these to use take_fdopendir().
This commit is contained in:
parent
b46c3e4913
commit
8e06af804b
|
@ -142,7 +142,8 @@ int home_create_cifs(UserRecord *h, UserRecord **ret_home) {
|
|||
_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);
|
||||
|
@ -166,11 +167,9 @@ int home_create_cifs(UserRecord *h, UserRecord **ret_home) {
|
|||
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))
|
||||
|
|
|
@ -1718,7 +1718,7 @@ static int add_root_directory(sd_journal *j, const char *p, bool missing_ok) {
|
|||
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. */
|
||||
|
@ -1731,10 +1731,9 @@ static int add_root_directory(sd_journal *j, const char *p, bool missing_ok) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
d = fdopendir(dfd);
|
||||
d = take_fdopendir(&dfd);
|
||||
if (!d) {
|
||||
r = -errno;
|
||||
safe_close(dfd);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue