From 5cada561863bb2bf95ef9bad6c18d6c306b82662 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 8 Dec 2023 01:31:39 +1100 Subject: treewide: Avoid in_addr_t IPv4 addresses can be stored in an in_addr_t or a struct in_addr. The former is just a type alias to a 32-bit integer, so doesn't really give us any type checking. Therefore we generally prefer the structure, since we mostly want to treat IP address as opaque objects. Fix a few places where we still use in_addr_t, but can just as easily use struct in_addr. Note there are still some uses of in_addr_t in conf.c, but those are justified: since they're doing prefix calculations, they actually need to look at the internals of the address as an integer. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util.c') diff --git a/util.c b/util.c index 43547c3..6e90371 100644 --- a/util.c +++ b/util.c @@ -161,7 +161,7 @@ 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; + addr4.sin_addr = *(struct in_addr *)bind_addr; sa = (const struct sockaddr *)&addr4; sl = sizeof(addr4); -- cgit v1.2.3