提交 9e42b40a 编写于 作者: D Daniel P. Berrange

Remove useless code in error path of getnameinfo()

If getnameinfo() with NI_NUMERICHOST set fails, there are no
grounds to expect inet_ntop to succeed, since these calls
are functionally equivalent. Remove useless inet_ntop code
in the getnameinfo() error path.

* daemon/remote.c, src/remote/remote_driver.c: Remove
  calls to inet_ntop
上级 134bcb62
......@@ -3653,23 +3653,9 @@ static char *addrToString(remote_error *rerr,
host, sizeof(host),
port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
char ip[INET6_ADDRSTRLEN];
void *rawaddr;
if (sa->sa_family == AF_INET)
rawaddr = &((struct sockaddr_in *)sa)->sin_addr;
else
rawaddr = &((struct sockaddr_in6 *)sa)->sin6_addr;
if (inet_ntop(sa->sa_family, rawaddr, ip, sizeof ip)) {
remoteDispatchFormatError(rerr,
_("Cannot resolve address %s: %s"),
ip, gai_strerror(err));
} else {
remoteDispatchFormatError(rerr,
_("Cannot resolve address: %s"),
_("Cannot convert socket address to string: %s"),
gai_strerror(err));
}
return NULL;
}
......
......@@ -6910,23 +6910,9 @@ static char *addrToString(struct sockaddr_storage *ss, socklen_t salen)
host, sizeof(host),
port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
char ip[INET6_ADDRSTRLEN];
void *rawaddr;
if (sa->sa_family == AF_INET)
rawaddr = &((struct sockaddr_in *)sa)->sin_addr;
else
rawaddr = &((struct sockaddr_in6 *)sa)->sin6_addr;
if (inet_ntop(sa->sa_family, rawaddr, ip, sizeof ip)) {
remoteError(VIR_ERR_UNKNOWN_HOST,
_("Cannot resolve address %s: %s"),
ip, gai_strerror(err));
} else {
remoteError(VIR_ERR_UNKNOWN_HOST,
_("Cannot resolve address: %s"),
_("Cannot convert socket address to string: %s"),
gai_strerror(err));
}
return NULL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册