From d451a95234ec9aedf168cfb4a72e5c74105f1ddf Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Sun, 3 Feb 2019 13:53:29 +0100 Subject: [PATCH] Problem: redundant code in different preprocessor branches Solution: change preprocessor guard scope --- src/udp_engine.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/udp_engine.cpp b/src/udp_engine.cpp index 3bd23f5f..c4804d2c 100644 --- a/src/udp_engine.cpp +++ b/src/udp_engine.cpp @@ -465,39 +465,25 @@ void zmq::udp_engine_t::restart_output () void zmq::udp_engine_t::in_event () { sockaddr_storage in_address; - socklen_t in_addrlen = sizeof (sockaddr_storage); -#ifdef ZMQ_HAVE_WINDOWS - int nbytes = + zmq_socklen_t in_addrlen = + static_cast (sizeof (sockaddr_storage)); + + const int nbytes = recvfrom (_fd, _in_buffer, MAX_UDP_MSG, 0, reinterpret_cast (&in_address), &in_addrlen); - const int last_error = WSAGetLastError (); +#ifdef ZMQ_HAVE_WINDOWS if (nbytes == SOCKET_ERROR) { + const int last_error = WSAGetLastError (); wsa_assert (last_error == WSAENETDOWN || last_error == WSAENETRESET || last_error == WSAEWOULDBLOCK); return; } -#elif defined ZMQ_HAVE_VXWORKS - int nbytes = recvfrom (_fd, _in_buffer, MAX_UDP_MSG, 0, - (sockaddr *) &in_address, (int *) &in_addrlen); +#else if (nbytes == -1) { errno_assert (errno != EBADF && errno != EFAULT && errno != ENOMEM && errno != ENOTSOCK); return; } -#else - int nbytes = - recvfrom (_fd, _in_buffer, MAX_UDP_MSG, 0, - reinterpret_cast (&in_address), &in_addrlen); - if (nbytes == -1) { -#if !defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE - errno_assert (errno != EBADF && errno != EFAULT && errno != ENOMEM - && errno != ENOTSOCK); -#else - errno_assert (errno != EBADF && errno != EFAULT && errno != ENOMEM - && errno != ENOTSOCK); -#endif - return; - } #endif int rc; int body_size;