Problem: formatting inconsistent

Solution: applied clang-format
This commit is contained in:
sigiesec
2018-02-01 11:46:09 +01:00
parent 6d8baea714
commit 41f459e1dc
331 changed files with 13208 additions and 13691 deletions

View File

@@ -51,8 +51,8 @@ int zmq::tune_tcp_socket (fd_t s_)
// so using Nagle wouldn't improve throughput in anyway, but it would
// hurt latency.
int nodelay = 1;
int rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELAY, (char*) &nodelay,
sizeof (int));
int rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELAY, (char *) &nodelay,
sizeof (int));
tcp_assert_tuning_error (s_, rc);
if (rc != 0)
return rc;
@@ -60,8 +60,8 @@ int zmq::tune_tcp_socket (fd_t s_)
#ifdef ZMQ_HAVE_OPENVMS
// Disable delayed acknowledgements as they hurt latency significantly.
int nodelack = 1;
rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELACK, (char*) &nodelack,
sizeof (int));
rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELACK, (char *) &nodelack,
sizeof (int));
tcp_assert_tuning_error (s_, rc);
#endif
return rc;
@@ -70,7 +70,7 @@ int zmq::tune_tcp_socket (fd_t s_)
int zmq::set_tcp_send_buffer (fd_t sockfd_, int bufsize_)
{
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_SNDBUF,
(char*) &bufsize_, sizeof bufsize_);
(char *) &bufsize_, sizeof bufsize_);
tcp_assert_tuning_error (sockfd_, rc);
return rc;
}
@@ -78,13 +78,16 @@ int zmq::set_tcp_send_buffer (fd_t sockfd_, int bufsize_)
int zmq::set_tcp_receive_buffer (fd_t sockfd_, int bufsize_)
{
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_RCVBUF,
(char *) &bufsize_, sizeof bufsize_);
(char *) &bufsize_, sizeof bufsize_);
tcp_assert_tuning_error (sockfd_, rc);
return rc;
}
int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
int keepalive_idle_, int keepalive_intvl_)
int zmq::tune_tcp_keepalives (fd_t s_,
int keepalive_,
int keepalive_cnt_,
int keepalive_idle_,
int keepalive_intvl_)
{
// These options are used only under certain #ifdefs below.
LIBZMQ_UNUSED (keepalive_);
@@ -101,13 +104,14 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
if (keepalive_ != -1) {
tcp_keepalive keepalive_opts;
keepalive_opts.onoff = keepalive_;
keepalive_opts.keepalivetime = keepalive_idle_ != -1 ?
keepalive_idle_ * 1000 : 7200000;
keepalive_opts.keepaliveinterval = keepalive_intvl_ != -1 ?
keepalive_intvl_ * 1000 : 1000;
keepalive_opts.keepalivetime =
keepalive_idle_ != -1 ? keepalive_idle_ * 1000 : 7200000;
keepalive_opts.keepaliveinterval =
keepalive_intvl_ != -1 ? keepalive_intvl_ * 1000 : 1000;
DWORD num_bytes_returned;
int rc = WSAIoctl (s_, SIO_KEEPALIVE_VALS, &keepalive_opts,
sizeof (keepalive_opts), NULL, 0, &num_bytes_returned, NULL, NULL);
sizeof (keepalive_opts), NULL, 0,
&num_bytes_returned, NULL, NULL);
tcp_assert_tuning_error (s_, rc);
if (rc == SOCKET_ERROR)
return rc;
@@ -115,16 +119,16 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
#else
#ifdef ZMQ_HAVE_SO_KEEPALIVE
if (keepalive_ != -1) {
int rc = setsockopt (s_, SOL_SOCKET, SO_KEEPALIVE,
(char*) &keepalive_, sizeof (int));
int rc = setsockopt (s_, SOL_SOCKET, SO_KEEPALIVE, (char *) &keepalive_,
sizeof (int));
tcp_assert_tuning_error (s_, rc);
if (rc != 0)
return rc;
#ifdef ZMQ_HAVE_TCP_KEEPCNT
if (keepalive_cnt_ != -1) {
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPCNT,
&keepalive_cnt_, sizeof (int));
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPCNT, &keepalive_cnt_,
sizeof (int));
tcp_assert_tuning_error (s_, rc);
if (rc != 0)
return rc;
@@ -134,7 +138,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
#ifdef ZMQ_HAVE_TCP_KEEPIDLE
if (keepalive_idle_ != -1) {
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPIDLE,
&keepalive_idle_, sizeof (int));
&keepalive_idle_, sizeof (int));
tcp_assert_tuning_error (s_, rc);
if (rc != 0)
return rc;
@@ -143,7 +147,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
#ifdef ZMQ_HAVE_TCP_KEEPALIVE
if (keepalive_idle_ != -1) {
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPALIVE,
&keepalive_idle_, sizeof (int));
&keepalive_idle_, sizeof (int));
tcp_assert_tuning_error (s_, rc);
if (rc != 0)
return rc;
@@ -154,7 +158,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
#ifdef ZMQ_HAVE_TCP_KEEPINTVL
if (keepalive_intvl_ != -1) {
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPINTVL,
&keepalive_intvl_, sizeof (int));
&keepalive_intvl_, sizeof (int));
tcp_assert_tuning_error (s_, rc);
if (rc != 0)
return rc;
@@ -163,7 +167,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
}
#endif // ZMQ_HAVE_SO_KEEPALIVE
#endif // ZMQ_HAVE_WINDOWS
return 0;
}
@@ -174,28 +178,28 @@ int zmq::tune_tcp_maxrt (fd_t sockfd_, int timeout_)
LIBZMQ_UNUSED (sockfd_);
#if defined (ZMQ_HAVE_WINDOWS) && defined (TCP_MAXRT)
#if defined(ZMQ_HAVE_WINDOWS) && defined(TCP_MAXRT)
// msdn says it's supported in >= Vista, >= Windows Server 2003
timeout_ /= 1000; // in seconds
int rc = setsockopt (sockfd_, IPPROTO_TCP, TCP_MAXRT, (char*) &timeout_,
sizeof (timeout_));
timeout_ /= 1000; // in seconds
int rc = setsockopt (sockfd_, IPPROTO_TCP, TCP_MAXRT, (char *) &timeout_,
sizeof (timeout_));
tcp_assert_tuning_error (sockfd_, rc);
return rc;
// FIXME: should be ZMQ_HAVE_TCP_USER_TIMEOUT
#elif defined (TCP_USER_TIMEOUT)
#elif defined(TCP_USER_TIMEOUT)
int rc = setsockopt (sockfd_, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout_,
sizeof (timeout_));
sizeof (timeout_));
tcp_assert_tuning_error (sockfd_, rc);
return rc;
#endif
return 0;
}
int zmq::tcp_write (fd_t s_, const void *data_, size_t size_)
int zmq::tcp_write (fd_t s_, const void *data_, size_t size_)
{
#ifdef ZMQ_HAVE_WINDOWS
int nbytes = send (s_, (char*) data_, (int) size_, 0);
int nbytes = send (s_, (char *) data_, (int) size_, 0);
// If not a single byte can be written to the socket in non-blocking mode
// we'll get an error (this may happen during the speculative write).
@@ -204,14 +208,10 @@ int zmq::tune_tcp_maxrt (fd_t sockfd_, int timeout_)
return 0;
// Signalise peer failure.
if (nbytes == SOCKET_ERROR && (
last_error == WSAENETDOWN ||
last_error == WSAENETRESET ||
last_error == WSAEHOSTUNREACH ||
last_error == WSAECONNABORTED ||
last_error == WSAETIMEDOUT ||
last_error == WSAECONNRESET
))
if (nbytes == SOCKET_ERROR
&& (last_error == WSAENETDOWN || last_error == WSAENETRESET
|| last_error == WSAEHOSTUNREACH || last_error == WSAECONNABORTED
|| last_error == WSAETIMEDOUT || last_error == WSAECONNRESET))
return -1;
// Circumvent a Windows bug:
@@ -229,25 +229,20 @@ int zmq::tune_tcp_maxrt (fd_t sockfd_, int timeout_)
// Several errors are OK. When speculative write is being done we may not
// be able to write a single byte from the socket. Also, SIGSTOP issued
// by a debugging tool can result in EINTR error.
if (nbytes == -1 && (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINTR))
if (nbytes == -1
&& (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR))
return 0;
// Signalise peer failure.
if (nbytes == -1) {
errno_assert (errno != EACCES
&& errno != EBADF
&& errno != EDESTADDRREQ
&& errno != EFAULT
&& errno != EISCONN
&& errno != EMSGSIZE
&& errno != ENOMEM
&& errno != ENOTSOCK
&& errno != EOPNOTSUPP);
errno_assert (errno != EACCES && errno != EBADF && errno != EDESTADDRREQ
&& errno != EFAULT && errno != EISCONN
&& errno != EMSGSIZE && errno != ENOMEM
&& errno != ENOTSOCK && errno != EOPNOTSUPP);
return -1;
}
return static_cast <int> (nbytes);
return static_cast<int> (nbytes);
#endif
}
@@ -256,7 +251,7 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
{
#ifdef ZMQ_HAVE_WINDOWS
const int rc = recv (s_, (char*) data_, (int) size_, 0);
const int rc = recv (s_, (char *) data_, (int) size_, 0);
// If not a single byte can be read from the socket in non-blocking mode
// we'll get an error (this may happen during the speculative read).
@@ -264,15 +259,12 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
const int last_error = WSAGetLastError ();
if (last_error == WSAEWOULDBLOCK) {
errno = EAGAIN;
}
else {
wsa_assert (last_error == WSAENETDOWN ||
last_error == WSAENETRESET ||
last_error == WSAECONNABORTED ||
last_error == WSAETIMEDOUT ||
last_error == WSAECONNRESET ||
last_error == WSAECONNREFUSED ||
last_error == WSAENOTCONN);
} else {
wsa_assert (
last_error == WSAENETDOWN || last_error == WSAENETRESET
|| last_error == WSAECONNABORTED || last_error == WSAETIMEDOUT
|| last_error == WSAECONNRESET || last_error == WSAECONNREFUSED
|| last_error == WSAENOTCONN);
errno = wsa_error_to_errno (last_error);
}
}
@@ -287,15 +279,13 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
// be able to read a single byte from the socket. Also, SIGSTOP issued
// by a debugging tool can result in EINTR error.
if (rc == -1) {
errno_assert (errno != EBADF
&& errno != EFAULT
&& errno != ENOMEM
&& errno != ENOTSOCK);
errno_assert (errno != EBADF && errno != EFAULT && errno != ENOMEM
&& errno != ENOTSOCK);
if (errno == EWOULDBLOCK || errno == EINTR)
errno = EAGAIN;
}
return static_cast <int> (rc);
return static_cast<int> (rc);
#endif
}
@@ -312,26 +302,20 @@ void zmq::tcp_assert_tuning_error (zmq::fd_t s_, int rc_)
#else
socklen_t len = sizeof err;
#endif
int rc = getsockopt (s_, SOL_SOCKET, SO_ERROR, (char*) &err, &len);
int rc = getsockopt (s_, SOL_SOCKET, SO_ERROR, (char *) &err, &len);
// Assert if the error was caused by 0MQ bug.
// Networking problems are OK. No need to assert.
#ifdef ZMQ_HAVE_WINDOWS
zmq_assert (rc == 0);
if (err != 0) {
wsa_assert (err == WSAECONNREFUSED
|| err == WSAECONNRESET
|| err == WSAECONNABORTED
|| err == WSAEINTR
|| err == WSAETIMEDOUT
|| err == WSAEHOSTUNREACH
|| err == WSAENETUNREACH
|| err == WSAENETDOWN
|| err == WSAENETRESET
|| err == WSAEACCES
|| err == WSAEINVAL
|| err == WSAEADDRINUSE);
wsa_assert (err == WSAECONNREFUSED || err == WSAECONNRESET
|| err == WSAECONNABORTED || err == WSAEINTR
|| err == WSAETIMEDOUT || err == WSAEHOSTUNREACH
|| err == WSAENETUNREACH || err == WSAENETDOWN
|| err == WSAENETRESET || err == WSAEACCES
|| err == WSAEINVAL || err == WSAEADDRINUSE);
}
#else
// Following code should handle both Berkeley-derived socket
@@ -340,17 +324,11 @@ void zmq::tcp_assert_tuning_error (zmq::fd_t s_, int rc_)
err = errno;
if (err != 0) {
errno = err;
errno_assert (
errno == ECONNREFUSED ||
errno == ECONNRESET ||
errno == ECONNABORTED ||
errno == EINTR ||
errno == ETIMEDOUT ||
errno == EHOSTUNREACH ||
errno == ENETUNREACH ||
errno == ENETDOWN ||
errno == ENETRESET ||
errno == EINVAL);
errno_assert (errno == ECONNREFUSED || errno == ECONNRESET
|| errno == ECONNABORTED || errno == EINTR
|| errno == ETIMEDOUT || errno == EHOSTUNREACH
|| errno == ENETUNREACH || errno == ENETDOWN
|| errno == ENETRESET || errno == EINVAL);
}
#endif
}