1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

sd-event: use _cleanup_ in one more place

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-01-08 16:22:23 +01:00
parent 1eac79486e
commit b44d87e200

View File

@ -1037,14 +1037,15 @@ static int event_setup_timer_fd(
struct clock_data *d,
clockid_t clock) {
int r, fd;
assert(e);
assert(d);
if (_likely_(d->fd >= 0))
return 0;
_cleanup_close_ int fd = -1;
int r;
fd = timerfd_create(clock, TFD_NONBLOCK|TFD_CLOEXEC);
if (fd < 0)
return -errno;
@ -1057,12 +1058,10 @@ static int event_setup_timer_fd(
};
r = epoll_ctl(e->epoll_fd, EPOLL_CTL_ADD, fd, &ev);
if (r < 0) {
safe_close(fd);
if (r < 0)
return -errno;
}
d->fd = fd;
d->fd = TAKE_FD(fd);
return 0;
}