net/ToString: make variables more local
This commit is contained in:
parent
6f22452b54
commit
d4d9a85ad8
@ -82,11 +82,6 @@ sockaddr_to_string(SocketAddress address)
|
|||||||
const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *)
|
const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *)
|
||||||
address.GetAddress();
|
address.GetAddress();
|
||||||
struct sockaddr_in a4;
|
struct sockaddr_in a4;
|
||||||
#endif
|
|
||||||
int ret;
|
|
||||||
char host[NI_MAXHOST], serv[NI_MAXSERV];
|
|
||||||
|
|
||||||
#if defined(HAVE_IPV6) && defined(IN6_IS_ADDR_V4MAPPED)
|
|
||||||
if (address.GetFamily() == AF_INET6 &&
|
if (address.GetFamily() == AF_INET6 &&
|
||||||
IN6_IS_ADDR_V4MAPPED(&a6->sin6_addr)) {
|
IN6_IS_ADDR_V4MAPPED(&a6->sin6_addr)) {
|
||||||
/* convert "::ffff:127.0.0.1" to "127.0.0.1" */
|
/* convert "::ffff:127.0.0.1" to "127.0.0.1" */
|
||||||
@ -101,9 +96,10 @@ sockaddr_to_string(SocketAddress address)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = getnameinfo(address.GetAddress(), address.GetSize(),
|
char host[NI_MAXHOST], serv[NI_MAXSERV];
|
||||||
host, sizeof(host), serv, sizeof(serv),
|
int ret = getnameinfo(address.GetAddress(), address.GetSize(),
|
||||||
NI_NUMERICHOST|NI_NUMERICSERV);
|
host, sizeof(host), serv, sizeof(serv),
|
||||||
|
NI_NUMERICHOST|NI_NUMERICSERV);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return "unknown";
|
return "unknown";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user