From 0f706bdd9706f64130823726a724ad091f5cc1f6 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 21 Sep 2021 19:11:11 +0100 Subject: [PATCH] Problem: formatting errors Solution: run make clang-format-diff --- include/zmq.h | 6 +++--- src/address.cpp | 4 +--- src/blob.hpp | 4 +--- src/channel.cpp | 3 +-- src/dealer.cpp | 3 +-- src/decoder.hpp | 5 +---- src/dgram.cpp | 4 +--- src/dish.cpp | 3 +-- src/dist.cpp | 5 +---- src/endpoint.hpp | 4 +--- src/generic_mtrie_impl.hpp | 5 +---- src/ipc_listener.cpp | 3 +-- src/mechanism_base.cpp | 3 +-- src/msg.hpp | 2 +- src/object.cpp | 3 +-- src/pair.cpp | 3 +-- src/plain_client.cpp | 3 +-- src/poll.cpp | 3 +-- src/polling_util.hpp | 2 +- src/pollset.cpp | 3 +-- src/radio.cpp | 3 +-- src/select.cpp | 4 ++-- src/socket_base.cpp | 18 ++++++++---------- src/socks.cpp | 20 ++++++-------------- src/thread.cpp | 2 +- src/thread.hpp | 2 +- src/timers.hpp | 2 +- src/udp_address.cpp | 3 +-- src/v1_decoder.cpp | 3 +-- src/ws_encoder.cpp | 3 +-- src/ws_listener.cpp | 3 +-- src/wss_engine.cpp | 2 +- src/zap_client.cpp | 3 +-- tests/testutil.cpp | 21 ++++++++++----------- tests/testutil_security.hpp | 2 +- 35 files changed, 59 insertions(+), 103 deletions(-) diff --git a/include/zmq.h b/include/zmq.h index 90b5567f..e3313ce5 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -249,7 +249,7 @@ typedef struct zmq_msg_t #endif } zmq_msg_t; -typedef void(zmq_free_fn) (void *data_, void *hint_); +typedef void (zmq_free_fn) (void *data_, void *hint_); ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg_); ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_); @@ -583,7 +583,7 @@ ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p_); #define ZMQ_HAVE_TIMERS -typedef void(zmq_timer_fn) (int timer_id, void *arg); +typedef void (zmq_timer_fn) (int timer_id, void *arg); ZMQ_EXPORT void *zmq_timers_new (void); ZMQ_EXPORT int zmq_timers_destroy (void **timers_p); @@ -620,7 +620,7 @@ ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); /* Sleeps for specified number of seconds. */ ZMQ_EXPORT void zmq_sleep (int seconds_); -typedef void(zmq_thread_fn) (void *); +typedef void (zmq_thread_fn) (void *); /* Start a thread. Returns a handle to the thread. */ ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func_, void *arg_); diff --git a/src/address.cpp b/src/address.cpp index 9ec83c2f..f1e23eae 100644 --- a/src/address.cpp +++ b/src/address.cpp @@ -48,9 +48,7 @@ zmq::address_t::address_t (const std::string &protocol_, const std::string &address_, ctx_t *parent_) : - protocol (protocol_), - address (address_), - parent (parent_) + protocol (protocol_), address (address_), parent (parent_) { resolved.dummy = NULL; } diff --git a/src/blob.hpp b/src/blob.hpp index 54221618..54a41d52 100644 --- a/src/blob.hpp +++ b/src/blob.hpp @@ -100,9 +100,7 @@ struct blob_t // Use with caution and ensure that the blob_t will not outlive // the referenced data. blob_t (unsigned char *const data_, const size_t size_, reference_tag_t) : - _data (data_), - _size (size_), - _owned (false) + _data (data_), _size (size_), _owned (false) { } diff --git a/src/channel.cpp b/src/channel.cpp index 6a396228..bae4407e 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -35,8 +35,7 @@ #include "msg.hpp" zmq::channel_t::channel_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_, true), - _pipe (NULL) + socket_base_t (parent_, tid_, sid_, true), _pipe (NULL) { options.type = ZMQ_CHANNEL; } diff --git a/src/dealer.cpp b/src/dealer.cpp index c5584974..7045e4a6 100644 --- a/src/dealer.cpp +++ b/src/dealer.cpp @@ -34,8 +34,7 @@ #include "msg.hpp" zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_), - _probe_router (false) + socket_base_t (parent_, tid_, sid_), _probe_router (false) { options.type = ZMQ_DEALER; options.can_send_hello_msg = true; diff --git a/src/decoder.hpp b/src/decoder.hpp index a2cd5a99..f89e10d9 100644 --- a/src/decoder.hpp +++ b/src/decoder.hpp @@ -58,10 +58,7 @@ class decoder_base_t : public i_decoder { public: explicit decoder_base_t (const size_t buf_size_) : - _next (NULL), - _read_pos (NULL), - _to_read (0), - _allocator (buf_size_) + _next (NULL), _read_pos (NULL), _to_read (0), _allocator (buf_size_) { _buf = _allocator.allocate (); } diff --git a/src/dgram.cpp b/src/dgram.cpp index 437b4819..2cca4af9 100644 --- a/src/dgram.cpp +++ b/src/dgram.cpp @@ -37,9 +37,7 @@ #include "err.hpp" zmq::dgram_t::dgram_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_), - _pipe (NULL), - _more_out (false) + socket_base_t (parent_, tid_, sid_), _pipe (NULL), _more_out (false) { options.type = ZMQ_DGRAM; options.raw_socket = true; diff --git a/src/dish.cpp b/src/dish.cpp index d8a4befc..0e881b04 100644 --- a/src/dish.cpp +++ b/src/dish.cpp @@ -35,8 +35,7 @@ #include "err.hpp" zmq::dish_t::dish_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_, true), - _has_message (false) + socket_base_t (parent_, tid_, sid_, true), _has_message (false) { options.type = ZMQ_DISH; diff --git a/src/dist.cpp b/src/dist.cpp index a205f70f..cb11bf8e 100644 --- a/src/dist.cpp +++ b/src/dist.cpp @@ -35,10 +35,7 @@ #include "likely.hpp" zmq::dist_t::dist_t () : - _matching (0), - _active (0), - _eligible (0), - _more (false) + _matching (0), _active (0), _eligible (0), _more (false) { } diff --git a/src/endpoint.hpp b/src/endpoint.hpp index 56b7d0e7..e1b5fff9 100644 --- a/src/endpoint.hpp +++ b/src/endpoint.hpp @@ -47,9 +47,7 @@ struct endpoint_uri_pair_t endpoint_uri_pair_t (const std::string &local, const std::string &remote, endpoint_type_t local_type) : - local (local), - remote (remote), - local_type (local_type) + local (local), remote (remote), local_type (local_type) { } diff --git a/src/generic_mtrie_impl.hpp b/src/generic_mtrie_impl.hpp index 35dae307..4a7a353d 100644 --- a/src/generic_mtrie_impl.hpp +++ b/src/generic_mtrie_impl.hpp @@ -45,10 +45,7 @@ namespace zmq { template generic_mtrie_t::generic_mtrie_t () : - _pipes (0), - _min (0), - _count (0), - _live_nodes (0) + _pipes (0), _min (0), _count (0), _live_nodes (0) { } diff --git a/src/ipc_listener.cpp b/src/ipc_listener.cpp index fc5bc51a..d6f7ee51 100644 --- a/src/ipc_listener.cpp +++ b/src/ipc_listener.cpp @@ -78,8 +78,7 @@ zmq::ipc_listener_t::ipc_listener_t (io_thread_t *io_thread_, socket_base_t *socket_, const options_t &options_) : - stream_listener_base_t (io_thread_, socket_, options_), - _has_file (false) + stream_listener_base_t (io_thread_, socket_, options_), _has_file (false) { } diff --git a/src/mechanism_base.cpp b/src/mechanism_base.cpp index d51b3695..ddb179e7 100644 --- a/src/mechanism_base.cpp +++ b/src/mechanism_base.cpp @@ -34,8 +34,7 @@ zmq::mechanism_base_t::mechanism_base_t (session_base_t *const session_, const options_t &options_) : - mechanism_t (options_), - session (session_) + mechanism_t (options_), session (session_) { } diff --git a/src/msg.hpp b/src/msg.hpp index d956b2ac..e2eaa09e 100644 --- a/src/msg.hpp +++ b/src/msg.hpp @@ -46,7 +46,7 @@ // Note that it has to be declared as "C" so that it is the same as // zmq_free_fn defined in zmq.h. extern "C" { -typedef void(msg_free_fn) (void *data_, void *hint_); +typedef void (msg_free_fn) (void *data_, void *hint_); } namespace zmq diff --git a/src/object.cpp b/src/object.cpp index ba3558f6..5946959a 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -44,8 +44,7 @@ zmq::object_t::object_t (ctx_t *ctx_, uint32_t tid_) : _ctx (ctx_), _tid (tid_) } zmq::object_t::object_t (object_t *parent_) : - _ctx (parent_->_ctx), - _tid (parent_->_tid) + _ctx (parent_->_ctx), _tid (parent_->_tid) { } diff --git a/src/pair.cpp b/src/pair.cpp index d1fb80b1..83551ddd 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -35,8 +35,7 @@ #include "msg.hpp" zmq::pair_t::pair_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_), - _pipe (NULL) + socket_base_t (parent_, tid_, sid_), _pipe (NULL) { options.type = ZMQ_PAIR; } diff --git a/src/plain_client.cpp b/src/plain_client.cpp index 2af6d1dd..6ba56a84 100644 --- a/src/plain_client.cpp +++ b/src/plain_client.cpp @@ -41,8 +41,7 @@ zmq::plain_client_t::plain_client_t (session_base_t *const session_, const options_t &options_) : - mechanism_base_t (session_, options_), - _state (sending_hello) + mechanism_base_t (session_, options_), _state (sending_hello) { } diff --git a/src/poll.cpp b/src/poll.cpp index 67de088d..0a94625e 100644 --- a/src/poll.cpp +++ b/src/poll.cpp @@ -42,8 +42,7 @@ #include "i_poll_events.hpp" zmq::poll_t::poll_t (const zmq::thread_ctx_t &ctx_) : - worker_poller_base_t (ctx_), - retired (false) + worker_poller_base_t (ctx_), retired (false) { } diff --git a/src/polling_util.hpp b/src/polling_util.hpp index 3adcdee6..a73ec747 100644 --- a/src/polling_util.hpp +++ b/src/polling_util.hpp @@ -82,7 +82,7 @@ template class resizable_fast_vector_t _dynamic_buf = new (std::nothrow) std::vector (nitems_); // TODO since this function is called by a client, we could return errno == ENOMEM here alloc_assert (_dynamic_buf); - memcpy(&(*_dynamic_buf)[0], _static_buf, sizeof _static_buf); + memcpy (&(*_dynamic_buf)[0], _static_buf, sizeof _static_buf); } } diff --git a/src/pollset.cpp b/src/pollset.cpp index 1a1dee95..35baf839 100644 --- a/src/pollset.cpp +++ b/src/pollset.cpp @@ -43,8 +43,7 @@ #include "i_poll_events.hpp" zmq::pollset_t::pollset_t (const zmq::thread_ctx_t &ctx_) : - ctx (ctx_), - stopping (false) + ctx (ctx_), stopping (false) { pollset_fd = pollset_create (-1); errno_assert (pollset_fd != -1); diff --git a/src/radio.cpp b/src/radio.cpp index aa9f100a..0ebb0815 100644 --- a/src/radio.cpp +++ b/src/radio.cpp @@ -37,8 +37,7 @@ #include "msg.hpp" zmq::radio_t::radio_t (class ctx_t *parent_, uint32_t tid_, int sid_) : - socket_base_t (parent_, tid_, sid_, true), - _lossy (true) + socket_base_t (parent_, tid_, sid_, true), _lossy (true) { options.type = ZMQ_RADIO; } diff --git a/src/select.cpp b/src/select.cpp index 159f44f2..46852c79 100644 --- a/src/select.cpp +++ b/src/select.cpp @@ -477,8 +477,8 @@ zmq::select_t::fds_set_t::fds_set_t (const fds_set_t &other_) #endif } -zmq::select_t::fds_set_t &zmq::select_t::fds_set_t:: -operator= (const fds_set_t &other_) +zmq::select_t::fds_set_t & +zmq::select_t::fds_set_t::operator= (const fds_set_t &other_) { #if defined ZMQ_HAVE_WINDOWS // On Windows we don't need to copy the whole fd_set. diff --git a/src/socket_base.cpp b/src/socket_base.cpp index bbb378cc..ee78d8b7 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -804,16 +804,14 @@ int zmq::socket_base_t::connect_internal (const char *endpoint_uri_) // The total HWM for an inproc connection should be the sum of // the binder's HWM and the connector's HWM. - const int sndhwm = peer.socket == NULL - ? options.sndhwm - : options.sndhwm != 0 && peer.options.rcvhwm != 0 - ? options.sndhwm + peer.options.rcvhwm - : 0; - const int rcvhwm = peer.socket == NULL - ? options.rcvhwm - : options.rcvhwm != 0 && peer.options.sndhwm != 0 - ? options.rcvhwm + peer.options.sndhwm - : 0; + const int sndhwm = peer.socket == NULL ? options.sndhwm + : options.sndhwm != 0 && peer.options.rcvhwm != 0 + ? options.sndhwm + peer.options.rcvhwm + : 0; + const int rcvhwm = peer.socket == NULL ? options.rcvhwm + : options.rcvhwm != 0 && peer.options.sndhwm != 0 + ? options.rcvhwm + peer.options.sndhwm + : 0; // Create a bi-directional pipe to connect the peers. object_t *parents[2] = {this, peer.socket == NULL ? this : peer.socket}; diff --git a/src/socks.cpp b/src/socks.cpp index 9da12be6..b5a2f8fc 100644 --- a/src/socks.cpp +++ b/src/socks.cpp @@ -55,8 +55,7 @@ zmq::socks_greeting_t::socks_greeting_t (const uint8_t *methods_, } zmq::socks_greeting_encoder_t::socks_greeting_encoder_t () : - _bytes_encoded (0), - _bytes_written (0) + _bytes_encoded (0), _bytes_written (0) { } @@ -131,8 +130,7 @@ void zmq::socks_choice_decoder_t::reset () zmq::socks_basic_auth_request_t::socks_basic_auth_request_t ( const std::string &username_, const std::string &password_) : - username (username_), - password (password_) + username (username_), password (password_) { zmq_assert (username_.size () <= UINT8_MAX); zmq_assert (password_.size () <= UINT8_MAX); @@ -140,8 +138,7 @@ zmq::socks_basic_auth_request_t::socks_basic_auth_request_t ( zmq::socks_basic_auth_request_encoder_t::socks_basic_auth_request_encoder_t () : - _bytes_encoded (0), - _bytes_written (0) + _bytes_encoded (0), _bytes_written (0) { } @@ -223,16 +220,13 @@ void zmq::socks_auth_response_decoder_t::reset () zmq::socks_request_t::socks_request_t (uint8_t command_, std::string hostname_, uint16_t port_) : - command (command_), - hostname (ZMQ_MOVE (hostname_)), - port (port_) + command (command_), hostname (ZMQ_MOVE (hostname_)), port (port_) { zmq_assert (hostname.size () <= UINT8_MAX); } zmq::socks_request_encoder_t::socks_request_encoder_t () : - _bytes_encoded (0), - _bytes_written (0) + _bytes_encoded (0), _bytes_written (0) { } @@ -308,9 +302,7 @@ void zmq::socks_request_encoder_t::reset () zmq::socks_response_t::socks_response_t (uint8_t response_code_, const std::string &address_, uint16_t port_) : - response_code (response_code_), - address (address_), - port (port_) + response_code (response_code_), address (address_), port (port_) { } diff --git a/src/thread.cpp b/src/thread.cpp index d7e17826..3504236f 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -279,7 +279,7 @@ void zmq::thread_t::stop () bool zmq::thread_t::is_current_thread () const { - return bool(pthread_equal (pthread_self (), _descriptor)); + return bool (pthread_equal (pthread_self (), _descriptor)); } void zmq::thread_t::setSchedulingParameters ( diff --git a/src/thread.hpp b/src/thread.hpp index 256bfef3..1d58f4b6 100644 --- a/src/thread.hpp +++ b/src/thread.hpp @@ -41,7 +41,7 @@ namespace zmq { -typedef void(thread_fn) (void *); +typedef void (thread_fn) (void *); // Class encapsulating OS thread. Thread initiation/termination is done // using special functions rather than in constructor/destructor so that diff --git a/src/timers.hpp b/src/timers.hpp index 384d5e3f..ba8cdfba 100644 --- a/src/timers.hpp +++ b/src/timers.hpp @@ -38,7 +38,7 @@ along with this program. If not, see . namespace zmq { -typedef void(timers_timer_fn) (int timer_id_, void *arg_); +typedef void (timers_timer_fn) (int timer_id_, void *arg_); class timers_t { diff --git a/src/udp_address.cpp b/src/udp_address.cpp index 41e4770d..5d1713fe 100644 --- a/src/udp_address.cpp +++ b/src/udp_address.cpp @@ -46,8 +46,7 @@ #endif zmq::udp_address_t::udp_address_t () : - _bind_interface (-1), - _is_multicast (false) + _bind_interface (-1), _is_multicast (false) { _bind_address = ip_addr_t::any (AF_INET); _target_address = ip_addr_t::any (AF_INET); diff --git a/src/v1_decoder.cpp b/src/v1_decoder.cpp index e988ed72..df162b5f 100644 --- a/src/v1_decoder.cpp +++ b/src/v1_decoder.cpp @@ -40,8 +40,7 @@ #include "err.hpp" zmq::v1_decoder_t::v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_) : - decoder_base_t (bufsize_), - _max_msg_size (maxmsgsize_) + decoder_base_t (bufsize_), _max_msg_size (maxmsgsize_) { int rc = _in_progress.init (); errno_assert (rc == 0); diff --git a/src/ws_encoder.cpp b/src/ws_encoder.cpp index bc0b38c7..7d833615 100644 --- a/src/ws_encoder.cpp +++ b/src/ws_encoder.cpp @@ -38,8 +38,7 @@ #include zmq::ws_encoder_t::ws_encoder_t (size_t bufsize_, bool must_mask_) : - encoder_base_t (bufsize_), - _must_mask (must_mask_) + encoder_base_t (bufsize_), _must_mask (must_mask_) { // Write 0 bytes to the batch and go to message_ready state. next_step (NULL, 0, &ws_encoder_t::message_ready, true); diff --git a/src/ws_listener.cpp b/src/ws_listener.cpp index 2c7978ba..43ca198a 100644 --- a/src/ws_listener.cpp +++ b/src/ws_listener.cpp @@ -70,8 +70,7 @@ zmq::ws_listener_t::ws_listener_t (io_thread_t *io_thread_, socket_base_t *socket_, const options_t &options_, bool wss_) : - stream_listener_base_t (io_thread_, socket_, options_), - _wss (wss_) + stream_listener_base_t (io_thread_, socket_, options_), _wss (wss_) { #ifdef ZMQ_HAVE_WSS if (_wss) { diff --git a/src/wss_engine.cpp b/src/wss_engine.cpp index fc729d2a..935e9c1f 100644 --- a/src/wss_engine.cpp +++ b/src/wss_engine.cpp @@ -194,7 +194,7 @@ int zmq::wss_engine_t::read (void *data_, size_t size_) return -1; } - if (rc == 0) { + if (rc == 0) { errno = EPIPE; return -1; } diff --git a/src/zap_client.cpp b/src/zap_client.cpp index 7ba28c91..1eba76b0 100644 --- a/src/zap_client.cpp +++ b/src/zap_client.cpp @@ -44,8 +44,7 @@ const size_t id_len = sizeof (id) - 1; zap_client_t::zap_client_t (session_base_t *const session_, const std::string &peer_address_, const options_t &options_) : - mechanism_base_t (session_, options_), - peer_address (peer_address_) + mechanism_base_t (session_, options_), peer_address (peer_address_) { } diff --git a/tests/testutil.cpp b/tests/testutil.cpp index a8349a49..386cbcab 100644 --- a/tests/testutil.cpp +++ b/tests/testutil.cpp @@ -383,9 +383,9 @@ fd_t connect_socket (const char *endpoint_, const int af_, const int protocol_) // OSX is very opinionated and wants the size to match the AF family type socklen_t addr_len; const fd_t s_pre = socket (af_, SOCK_STREAM, - protocol_ == IPPROTO_UDP - ? IPPROTO_UDP - : protocol_ == IPPROTO_TCP ? IPPROTO_TCP : 0); + protocol_ == IPPROTO_UDP ? IPPROTO_UDP + : protocol_ == IPPROTO_TCP ? IPPROTO_TCP + : 0); TEST_ASSERT_NOT_EQUAL (-1, s_pre); if (af_ == AF_INET || af_ == AF_INET6) { @@ -440,9 +440,9 @@ fd_t bind_socket_resolve_port (const char *address_, // OSX is very opinionated and wants the size to match the AF family type socklen_t addr_len; const fd_t s_pre = socket (af_, SOCK_STREAM, - protocol_ == IPPROTO_UDP - ? IPPROTO_UDP - : protocol_ == IPPROTO_TCP ? IPPROTO_TCP : 0); + protocol_ == IPPROTO_UDP ? IPPROTO_UDP + : protocol_ == IPPROTO_TCP ? IPPROTO_TCP + : 0); TEST_ASSERT_NOT_EQUAL (-1, s_pre); if (af_ == AF_INET || af_ == AF_INET6) { @@ -511,11 +511,10 @@ fd_t bind_socket_resolve_port (const char *address_, TEST_ASSERT_SUCCESS_RAW_ERRNO ( getsockname (s_pre, (struct sockaddr *) &addr, &addr_len)); sprintf (my_endpoint_, "%s://%s:%u", - protocol_ == IPPROTO_TCP - ? "tcp" - : protocol_ == IPPROTO_UDP - ? "udp" - : protocol_ == IPPROTO_WSS ? "wss" : "ws", + protocol_ == IPPROTO_TCP ? "tcp" + : protocol_ == IPPROTO_UDP ? "udp" + : protocol_ == IPPROTO_WSS ? "wss" + : "ws", address_, af_ == AF_INET ? ntohs ((*(struct sockaddr_in *) &addr).sin_port) diff --git a/tests/testutil_security.hpp b/tests/testutil_security.hpp index 909bbeb9..03d01765 100644 --- a/tests/testutil_security.hpp +++ b/tests/testutil_security.hpp @@ -35,7 +35,7 @@ // security test utils -typedef void(socket_config_fn) (void *, void *); +typedef void (socket_config_fn) (void *, void *); // NULL specific functions void socket_config_null_client (void *server_, void *server_secret_);