mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +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,
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user