mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
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
This commit is contained in:
parent
134bcb62db
commit
9e42b40a95
@ -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"),
|
||||
gai_strerror(err));
|
||||
}
|
||||
remoteDispatchFormatError(rerr,
|
||||
_("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"),
|
||||
gai_strerror(err));
|
||||
}
|
||||
remoteError(VIR_ERR_UNKNOWN_HOST,
|
||||
_("Cannot convert socket address to string: %s"),
|
||||
gai_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user