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:
parent
1eac79486e
commit
b44d87e200
@ -1037,14 +1037,15 @@ static int event_setup_timer_fd(
|
|||||||
struct clock_data *d,
|
struct clock_data *d,
|
||||||
clockid_t clock) {
|
clockid_t clock) {
|
||||||
|
|
||||||
int r, fd;
|
|
||||||
|
|
||||||
assert(e);
|
assert(e);
|
||||||
assert(d);
|
assert(d);
|
||||||
|
|
||||||
if (_likely_(d->fd >= 0))
|
if (_likely_(d->fd >= 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
_cleanup_close_ int fd = -1;
|
||||||
|
int r;
|
||||||
|
|
||||||
fd = timerfd_create(clock, TFD_NONBLOCK|TFD_CLOEXEC);
|
fd = timerfd_create(clock, TFD_NONBLOCK|TFD_CLOEXEC);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
@ -1057,12 +1058,10 @@ static int event_setup_timer_fd(
|
|||||||
};
|
};
|
||||||
|
|
||||||
r = epoll_ctl(e->epoll_fd, EPOLL_CTL_ADD, fd, &ev);
|
r = epoll_ctl(e->epoll_fd, EPOLL_CTL_ADD, fd, &ev);
|
||||||
if (r < 0) {
|
if (r < 0)
|
||||||
safe_close(fd);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
|
|
||||||
d->fd = fd;
|
d->fd = TAKE_FD(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user