nghttpx: Fix dead code found by coverity scan

This commit is contained in:
Tatsuhiro Tsujikawa 2016-12-18 22:14:26 +09:00
parent 46acf32c41
commit 02d34c8c4c
1 changed files with 15 additions and 18 deletions

View File

@ -293,32 +293,29 @@ void DNSResolver::on_result(int status, hostent *hostent) {
return; return;
} }
auto ap = *hostent->h_addr_list;
assert(ap);
switch (hostent->h_addrtype) { switch (hostent->h_addrtype) {
case AF_INET: case AF_INET:
for (auto ap = hostent->h_addr_list; *ap; ++ap) { status_ = DNS_STATUS_OK;
status_ = DNS_STATUS_OK; result_.len = sizeof(result_.su.in);
result_.len = sizeof(result_.su.in); result_.su.in = {};
result_.su.in = {}; result_.su.in.sin_family = AF_INET;
result_.su.in.sin_family = AF_INET;
#ifdef HAVE_SOCKADDR_IN_SIN_LEN #ifdef HAVE_SOCKADDR_IN_SIN_LEN
result_.su.in.sin_len = sizeof(result_.su.in); result_.su.in.sin_len = sizeof(result_.su.in);
#endif // HAVE_SOCKADDR_IN_SIN_LEN #endif // HAVE_SOCKADDR_IN_SIN_LEN
memcpy(&result_.su.in.sin_addr, *ap, sizeof(result_.su.in.sin_addr)); memcpy(&result_.su.in.sin_addr, ap, sizeof(result_.su.in.sin_addr));
break;
}
break; break;
case AF_INET6: case AF_INET6:
for (auto ap = hostent->h_addr_list; *ap; ++ap) { status_ = DNS_STATUS_OK;
status_ = DNS_STATUS_OK; result_.len = sizeof(result_.su.in6);
result_.len = sizeof(result_.su.in6); result_.su.in6 = {};
result_.su.in6 = {}; result_.su.in6.sin6_family = AF_INET6;
result_.su.in6.sin6_family = AF_INET6;
#ifdef HAVE_SOCKADDR_IN6_SIN6_LEN #ifdef HAVE_SOCKADDR_IN6_SIN6_LEN
result_.su.in6.sin6_len = sizeof(result_.su.in6); result_.su.in6.sin6_len = sizeof(result_.su.in6);
#endif // HAVE_SOCKADDR_IN6_SIN6_LEN #endif // HAVE_SOCKADDR_IN6_SIN6_LEN
memcpy(&result_.su.in6.sin6_addr, *ap, sizeof(result_.su.in6.sin6_addr)); memcpy(&result_.su.in6.sin6_addr, ap, sizeof(result_.su.in6.sin6_addr));
break;
}
break; break;
default: default:
assert(0); assert(0);