From: Lennart Poettering Date: Tue, 7 Mar 2023 21:50:41 +0000 (+0100) Subject: socket-util: fix socket_get_family() X-Git-Tag: v254-rc1~1071 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f64d2bf332371bdfdcb91b588e57d4c0c20428f;p=thirdparty%2Fsystemd.git socket-util: fix socket_get_family() Function didn't actually return anything useful. Quite a shame. --- diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index f01873e6080..43b292252cc 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -1307,7 +1307,7 @@ ssize_t recvmsg_safe(int sockfd, struct msghdr *msg, int flags) { return n; } -int socket_get_family(int fd, int *ret) { +int socket_get_family(int fd) { int af; socklen_t sl = sizeof(af); @@ -1321,12 +1321,11 @@ int socket_get_family(int fd, int *ret) { } int socket_set_recvpktinfo(int fd, int af, bool b) { - int r; if (af == AF_UNSPEC) { - r = socket_get_family(fd, &af); - if (r < 0) - return r; + af = socket_get_family(fd); + if (af < 0) + return af; } switch (af) { @@ -1350,12 +1349,11 @@ int socket_set_recvpktinfo(int fd, int af, bool b) { int socket_set_unicast_if(int fd, int af, int ifi) { be32_t ifindex_be = htobe32(ifi); - int r; if (af == AF_UNSPEC) { - r = socket_get_family(fd, &af); - if (r < 0) - return r; + af = socket_get_family(fd); + if (af < 0) + return af; } switch (af) { @@ -1372,12 +1370,10 @@ int socket_set_unicast_if(int fd, int af, int ifi) { } int socket_set_option(int fd, int af, int opt_ipv4, int opt_ipv6, int val) { - int r; - if (af == AF_UNSPEC) { - r = socket_get_family(fd, &af); - if (r < 0) - return r; + af = socket_get_family(fd); + if (af < 0) + return af; } switch (af) { @@ -1397,9 +1393,9 @@ int socket_get_mtu(int fd, int af, size_t *ret) { int mtu, r; if (af == AF_UNSPEC) { - r = socket_get_family(fd, &af); - if (r < 0) - return r; + af = socket_get_family(fd); + if (af < 0) + return af; } switch (af) { diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h index 5cb35f65fb9..0bfb29d4175 100644 --- a/src/basic/socket-util.h +++ b/src/basic/socket-util.h @@ -306,7 +306,7 @@ struct timespec_large { ssize_t recvmsg_safe(int sockfd, struct msghdr *msg, int flags); -int socket_get_family(int fd, int *ret); +int socket_get_family(int fd); int socket_set_recvpktinfo(int fd, int af, bool b); int socket_set_unicast_if(int fd, int af, int ifi); diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 3d456bbc9ab..ec854774af2 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -1749,9 +1749,9 @@ int socket_disable_pmtud(int fd, int af) { assert(fd >= 0); if (af == AF_UNSPEC) { - r = socket_get_family(fd, &af); - if (r < 0) - return r; + af = socket_get_family(fd); + if (af < 0) + return af; } switch (af) {