(addr)->superfamily == UNIX ? AF_UNIX : \
(step).ai ? (step).ai->ai_family : AF_INET)
#else
+/* Here we gratuitously reference 'step' to avoid gcc warnings about
+ * 'set but not used' when compiling -DNO_IPV6 */
#define SOCKADDR_FAMILY(addr, step) \
((addr)->superfamily == UNRESOLVED ? AF_UNSPEC : \
- (addr)->superfamily == UNIX ? AF_UNIX : AF_INET)
+ (addr)->superfamily == UNIX ? AF_UNIX : \
+ (step).curraddr ? AF_INET : AF_INET)
#endif
/*
{
int s;
#ifndef NO_IPV6
- struct addrinfo hints, *ai;
+ struct addrinfo hints, *ai = NULL;
char portstr[6];
#endif
union sockaddr_union u;
}
retcode = bind(s, &addr->sa, addrlen);
+
+#ifndef NO_IPV6
+ if (ai)
+ freeaddrinfo(ai);
+#endif
+
if (retcode < 0) {
close(s);
ret->error = strerror(errno);