valgrind: fix warning in test case

pull/802/head
Brad House 5 months ago
parent 51ca744459
commit c96200353d
  1. 7
      test/ares-test.cc

7
test/ares-test.cc vendored

@ -526,8 +526,12 @@ static unsigned short getaddrport(struct sockaddr_storage *addr)
{ {
if (addr->ss_family == AF_INET) if (addr->ss_family == AF_INET)
return ntohs(((struct sockaddr_in *)(void *)addr)->sin_port); return ntohs(((struct sockaddr_in *)(void *)addr)->sin_port);
if (addr->ss_family == AF_INET6)
return ntohs(((struct sockaddr_in6 *)(void *)addr)->sin6_port);
return ntohs(((struct sockaddr_in6 *)(void *)addr)->sin6_port); /* TCP should use getpeername() to get the port, getting this from recvfrom
* won't work */
return 0;
} }
void MockServer::ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, ares_socklen_t addrlen, void MockServer::ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, ares_socklen_t addrlen,
@ -616,6 +620,7 @@ void MockServer::ProcessFD(ares_socket_t fd) {
// Activity on a data-bearing file descriptor. // Activity on a data-bearing file descriptor.
struct sockaddr_storage addr; struct sockaddr_storage addr;
socklen_t addrlen = sizeof(addr); socklen_t addrlen = sizeof(addr);
memset(&addr, 0, sizeof(addr));
byte buffer[2048]; byte buffer[2048];
ares_ssize_t len = (ares_ssize_t)recvfrom(fd, BYTE_CAST buffer, sizeof(buffer), 0, ares_ssize_t len = (ares_ssize_t)recvfrom(fd, BYTE_CAST buffer, sizeof(buffer), 0,
(struct sockaddr *)&addr, &addrlen); (struct sockaddr *)&addr, &addrlen);

Loading…
Cancel
Save