socket-util: Replace sockaddr length macros with functions

There's no need for these to be macros, let's just make them regular
functions instead.
This commit is contained in:
Daan De Meyer
2025-05-02 09:41:41 +02:00
parent 256c4203f9
commit a0233fcd86
21 changed files with 78 additions and 81 deletions
+3 -3
View File
@@ -680,16 +680,16 @@ int local_outbounds(
* make use of the binding and return it. Hence, let's not unnecessarily fail early here: we
* can still easily detect if the auto-binding worked or not, by comparing the bound IP
* address with zero — which we do below. */
if (connect(fd, &sa.sa, SOCKADDR_LEN(sa)) < 0)
if (connect(fd, &sa.sa, sockaddr_len(&sa)) < 0)
log_debug_errno(errno, "Failed to connect SOCK_DGRAM socket to gateway, ignoring: %m");
/* Let's now read the socket address of the socket. A routing decision should have been
* made. Let's verify that and use the data. */
salen = SOCKADDR_LEN(sa);
salen = sockaddr_len(&sa);
if (getsockname(fd, &sa.sa, &salen) < 0)
return -errno;
assert(sa.sa.sa_family == i->family);
assert(salen == SOCKADDR_LEN(sa));
assert(salen == sockaddr_len(&sa));
switch (i->family) {
+1 -1
View File
@@ -17,7 +17,7 @@ int plymouth_connect(int flags) {
if (fd < 0)
return -errno;
if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
if (connect(fd, &sa.sa, sockaddr_un_len(&sa.un)) < 0)
return -errno;
return TAKE_FD(fd);