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
+4 -3
View File
@@ -455,7 +455,7 @@ static int create_socket(char **ret) {
_cleanup_free_ char *path = NULL;
union sockaddr_union sa = {};
_cleanup_close_ int fd = -1;
int salen;
int salen, r;
assert(ret);
@@ -475,8 +475,9 @@ static int create_socket(char **ret) {
return -errno;
}
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one)) < 0)
return -errno;
r = setsockopt_int(fd, SOL_SOCKET, SO_PASSCRED, true);
if (r < 0)
return r;
*ret = TAKE_PTR(path);
return TAKE_FD(fd);