Re: buildworld broken due to INET6 not being set

2023-07-05 Thread Gary Jennejohn
On Tue, 4 Jul 2023 16:48:10 +
Gary Jennejohn  wrote:

> buildworld breaks because I do not have INET6 defined:
>
> /usr/src/sbin/ping/main.c:76:7: error: variable 'ipv4' set but not used 
> [-Werror,-Wunused-but-set-variable]
> bool ipv4 = false;
>  ^
> 1 error generated.
>

I bit the bullet and enabled INET6, so there won't be any more reports like
this from me in the future.

--
Gary Jennejohn



buildworld broken due to INET6 not being set

2023-07-04 Thread Gary Jennejohn
buildworld breaks because I do not have INET6 defined:

/usr/src/sbin/ping/main.c:76:7: error: variable 'ipv4' set but not used 
[-Werror,-Wunused-but-set-variable]
bool ipv4 = false;
 ^
1 error generated.

ipv4 is set in various places but it's _used_ only bracketed in
#if defined(INET) && defined(INET6)...#endif!

Note that ipv6 will have the same error if INET6 is defined but INET is not
defined due to this chunk of code:

#if defined(INET) && defined(INET6)
if (inet_pton(AF_INET, argv[argc - 1], ) == 1) {
if (ipv6)
errx(1, "IPv6 requested but IPv4 target address "
"provided");
hints.ai_family = AF_INET;
}
else if (inet_pton(AF_INET6, argv[argc - 1], ) == 1) {
if (ipv4)
errx(1, "IPv4 requested but IPv6 target address "
"provided");
hints.ai_family = AF_INET6;
} else if (ipv6)
hints.ai_family = AF_INET6;
else if (ipv4)
hints.ai_family = AF_INET;
else {
if (!feature_present("inet6"))
hints.ai_family = AF_INET;
else if (!feature_present("inet"))
hints.ai_family = AF_INET6;
else {
struct addrinfo *res;

memset(, 0, sizeof(hints));
hints.ai_socktype = SOCK_RAW;
hints.ai_family = AF_UNSPEC;
getaddrinfo(argv[argc - 1], NULL, , );
if (res != NULL) {
hints.ai_family = res[0].ai_family;
freeaddrinfo(res);
}
}
}
#elif defined(INET)
hints.ai_family = AF_INET; <== ipv4 set but not used
#elif defined(INET6)
hints.ai_family = AF_INET6; <== ipv6 set but not used
#endif

--
Gary Jennejohn