diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-12-08 01:31:37 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-12-27 19:29:45 +0100 |
commit | b9f4314ef9e7dc8b2852430f6923cbedda46ae38 (patch) | |
tree | b6f7620e4b819017c79414366d9c38c444ecf61e /util.c | |
parent | eae4304000cb72cbb2e422474705ab9b2e38c939 (diff) | |
download | passt-b9f4314ef9e7dc8b2852430f6923cbedda46ae38.tar passt-b9f4314ef9e7dc8b2852430f6923cbedda46ae38.tar.gz passt-b9f4314ef9e7dc8b2852430f6923cbedda46ae38.tar.bz2 passt-b9f4314ef9e7dc8b2852430f6923cbedda46ae38.tar.lz passt-b9f4314ef9e7dc8b2852430f6923cbedda46ae38.tar.xz passt-b9f4314ef9e7dc8b2852430f6923cbedda46ae38.tar.zst passt-b9f4314ef9e7dc8b2852430f6923cbedda46ae38.zip |
util: Drop explicit setting to INADDR_ANY/in6addr_any in sock_l4()
The original commit message says:
---
Currently we initialise the address field of the sockaddrs we construct
to the any/unspecified address, but not in a very clear way: we use
explicit 0 values, which is only interpretable if you know the order of
fields in the sockaddr structures. Use explicit field names, and explicit
initialiser macros for the address.
Because we initialise to this default value, we don't need to explicitly
set the any/unspecified address later on if the caller didn't pass an
overriding bind address.
---
and the original patch modified the initialisation of addr4 and
addr6:
- instead of { 0 }, { 0 } for sin_addr and sin_zero,
.sin_addr = IN4ADDR_ANY_INIT
- instead of 0, IN6ADDR_ANY_INIT, 0:
.sin6_addr = IN6ADDR_ANY_INIT
but I dropped those hunks: they break gcc versions 7 to 9 as reported
in eed6933e6c29 ("udp: Explicitly initialise sin6_scope_id and
sin_zero in sockaddr_in{,6}").
I applied the rest of the changes.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[sbrivio: Dropped first two hunks]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 4 |
1 files changed, 0 insertions, 4 deletions
@@ -162,8 +162,6 @@ int sock_l4(const struct ctx *c, int af, uint8_t proto, if (af == AF_INET) { if (bind_addr) addr4.sin_addr.s_addr = *(in_addr_t *)bind_addr; - else - addr4.sin_addr.s_addr = htonl(INADDR_ANY); sa = (const struct sockaddr *)&addr4; sl = sizeof(addr4); @@ -174,8 +172,6 @@ int sock_l4(const struct ctx *c, int af, uint8_t proto, if (!memcmp(bind_addr, &c->ip6.addr_ll, sizeof(c->ip6.addr_ll))) addr6.sin6_scope_id = c->ifi6; - } else { - addr6.sin6_addr = in6addr_any; } sa = (const struct sockaddr *)&addr6; |