tree-wide: introduce setsockopt_int() helper and make use of it everywhere

As suggested by @heftig:

https://github.com/systemd/systemd/commit/6d5e65f6454212cd400d0ebda34978a9f20cc26a#commitcomment-30938667
This commit is contained in:
Lennart Poettering
2018-10-18 19:50:29 +02:00
parent 0fef958361
commit 2ff48e981e
22 changed files with 195 additions and 169 deletions
+3 -2
View File
@@ -293,8 +293,9 @@ int device_monitor_enable_receiving(sd_device_monitor *m) {
return log_debug_errno(r, "Failed to set address: %m");
/* enable receiving of sender credentials */
if (setsockopt(m->sock, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one)) < 0)
return log_debug_errno(errno, "Failed to set socket option SO_PASSCRED: %m");
r = setsockopt_int(m->sock, SOL_SOCKET, SO_PASSCRED, true);
if (r < 0)
return log_debug_errno(r, "Failed to set socket option SO_PASSCRED: %m");
return 0;
}
+2 -2
View File
@@ -90,9 +90,9 @@ int socket_bind(sd_netlink *nl) {
socklen_t addrlen;
int r;
r = setsockopt(nl->fd, SOL_NETLINK, NETLINK_PKTINFO, &const_int_one, sizeof(const_int_one));
r = setsockopt_int(nl->fd, SOL_NETLINK, NETLINK_PKTINFO, true);
if (r < 0)
return -errno;
return r;
addrlen = sizeof(nl->sockaddr);