sd-{login,netlink,network}: use TAKE_FD() in more places

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-09-22 17:33:06 +02:00
parent 90e207e41f
commit d52e1c420c
3 changed files with 7 additions and 21 deletions

View File

@ -997,20 +997,13 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) {
if (!good)
return -EINVAL;
*m = FD_TO_MONITOR(fd);
fd = -1;
*m = FD_TO_MONITOR(TAKE_FD(fd));
return 0;
}
_public_ sd_login_monitor* sd_login_monitor_unref(sd_login_monitor *m) {
int fd;
if (!m)
return NULL;
fd = MONITOR_TO_FD(m);
close_nointr(fd);
if (m)
close_nointr(MONITOR_TO_FD(m));
return NULL;
}

View File

@ -135,8 +135,7 @@ int netlink_open_family(sd_netlink **ret, int family) {
r = sd_netlink_open_fd(ret, fd);
if (r < 0)
return r;
fd = -1;
TAKE_FD(fd);
return 0;
}

View File

@ -373,19 +373,13 @@ _public_ int sd_network_monitor_new(sd_network_monitor **m, const char *category
if (!good)
return -EINVAL;
*m = FD_TO_MONITOR(fd);
fd = -1;
*m = FD_TO_MONITOR(TAKE_FD(fd));
return 0;
}
_public_ sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m) {
int fd;
if (m) {
fd = MONITOR_TO_FD(m);
close_nointr(fd);
}
if (m)
close_nointr(MONITOR_TO_FD(m));
return NULL;
}