diff --git a/tests/test_radio_dish.cpp b/tests/test_radio_dish.cpp index be029c1a..da6e4858 100644 --- a/tests/test_radio_dish.cpp +++ b/tests/test_radio_dish.cpp @@ -280,8 +280,8 @@ union sa_u static bool is_multicast_available (int ipv6_) { int family = ipv6_ ? AF_INET6 : AF_INET; - int bind_sock = -1; - int send_sock = -1; + fd_t bind_sock = retired_fd; + fd_t send_sock = retired_fd; int port = 5555; bool success = false; const char *msg = "it works"; @@ -357,15 +357,15 @@ static bool is_multicast_available (int ipv6_) mreq.ipv6mr_multiaddr = mcast_ipv6->sin6_addr; mreq.ipv6mr_interface = 0; - rc = setsockopt (bind_sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq, - sizeof (mreq)); + rc = setsockopt (bind_sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, + as_setsockopt_opt_t (&mreq), sizeof (mreq)); if (rc < 0) { goto out; } int loop = 1; - rc = setsockopt (send_sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, - sizeof (loop)); + rc = setsockopt (send_sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, + as_setsockopt_opt_t (&loop), sizeof (loop)); if (rc < 0) { goto out; } @@ -376,15 +376,15 @@ static bool is_multicast_available (int ipv6_) mreq.imr_multiaddr = mcast_ipv4->sin_addr; mreq.imr_interface.s_addr = htonl (INADDR_ANY); - rc = setsockopt (bind_sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, - sizeof (mreq)); + rc = setsockopt (bind_sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, + as_setsockopt_opt_t (&mreq), sizeof (mreq)); if (rc < 0) { goto out; } int loop = 1; - rc = setsockopt (send_sock, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, - sizeof (loop)); + rc = setsockopt (send_sock, IPPROTO_IP, IP_MULTICAST_LOOP, + as_setsockopt_opt_t (&loop), sizeof (loop)); if (rc < 0) { goto out; } @@ -392,7 +392,8 @@ static bool is_multicast_available (int ipv6_) msleep (SETTLE_TIME); - rc = sendto (send_sock, msg, strlen (msg), 0, &mcast.generic, sl); + rc = sendto (send_sock, msg, static_cast (strlen (msg)), 0, + &mcast.generic, sl); if (rc < 0) { goto out; } diff --git a/tests/testutil.hpp b/tests/testutil.hpp index 6ed29c35..3552a9fc 100644 --- a/tests/testutil.hpp +++ b/tests/testutil.hpp @@ -92,6 +92,10 @@ #ifdef ZMQ_HAVE_WINDOWS #define close closesocket typedef int socket_size_t; +const char *as_setsockopt_opt_t (const void *opt) +{ + return static_cast (opt); +} #if defined _MSC_VER && _MSC_VER <= 1400 typedef UINT_PTR fd_t; enum @@ -107,6 +111,10 @@ enum #endif #else typedef size_t socket_size_t; +const void *as_setsockopt_opt_t (const void *opt) +{ + return opt; +} typedef int fd_t; enum {