mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 10:33:52 +01:00
Problem: redundant else after return
Solution: remove else
This commit is contained in:
parent
1d9c6bcf09
commit
cb2b377d9f
@ -128,8 +128,8 @@ zmq::mechanism_t::status_t zmq::curve_client_t::status () const
|
||||
return mechanism_t::ready;
|
||||
if (_state == error_received)
|
||||
return mechanism_t::error;
|
||||
else
|
||||
return mechanism_t::handshaking;
|
||||
|
||||
return mechanism_t::handshaking;
|
||||
}
|
||||
|
||||
int zmq::curve_client_t::produce_hello (msg_t *msg_)
|
||||
|
10
src/ip.cpp
10
src/ip.cpp
@ -255,9 +255,9 @@ int zmq::bind_to_device (fd_t s_, const std::string &bound_device_)
|
||||
if (rc != 0) {
|
||||
assert_success_or_recoverable (s_, rc);
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
#else
|
||||
LIBZMQ_UNUSED (s_);
|
||||
LIBZMQ_UNUSED (bound_device_);
|
||||
@ -550,10 +550,10 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
|
||||
errno_assert (errno == ENFILE || errno == EMFILE);
|
||||
*w_ = *r_ = -1;
|
||||
return -1;
|
||||
} else {
|
||||
*w_ = *r_ = fd;
|
||||
return 0;
|
||||
}
|
||||
*w_ = *r_ = fd;
|
||||
return 0;
|
||||
|
||||
|
||||
#elif defined ZMQ_HAVE_WINDOWS
|
||||
#ifdef ZMQ_HAVE_IPC
|
||||
|
@ -128,8 +128,8 @@ int forward (class zmq::socket_base_t *from_,
|
||||
if (rc < 0) {
|
||||
if (likely (errno == EAGAIN && i > 0))
|
||||
return 0; // End of burst
|
||||
else
|
||||
return -1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
complete_msg_size += msg_->size ();
|
||||
|
@ -91,11 +91,10 @@ int zmq::socket_poller_t::signaler_fd (fd_t *fd_)
|
||||
if (_signaler) {
|
||||
*fd_ = _signaler->get_fd ();
|
||||
return 0;
|
||||
} else {
|
||||
// Only thread-safe socket types are guaranteed to have a signaler.
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
// Only thread-safe socket types are guaranteed to have a signaler.
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int zmq::socket_poller_t::add (socket_base_t *socket_,
|
||||
|
@ -465,14 +465,13 @@ int zmq::stream_engine_base_t::next_handshake_command (msg_t *msg_)
|
||||
if (_mechanism->status () == mechanism_t::error) {
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
} else {
|
||||
const int rc = _mechanism->next_handshake_command (msg_);
|
||||
|
||||
if (rc == 0)
|
||||
msg_->set_flags (msg_t::command);
|
||||
|
||||
return rc;
|
||||
}
|
||||
const int rc = _mechanism->next_handshake_command (msg_);
|
||||
|
||||
if (rc == 0)
|
||||
msg_->set_flags (msg_t::command);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int zmq::stream_engine_base_t::process_handshake_command (msg_t *msg_)
|
||||
|
@ -108,7 +108,8 @@ int zmq::tipc_address_t::resolve (const char *name_)
|
||||
address.addr.nameseq.upper = upper;
|
||||
address.scope = TIPC_ZONE_SCOPE;
|
||||
return 0;
|
||||
} else if (res == 2 && type > TIPC_RESERVED_TYPES) {
|
||||
}
|
||||
if (res == 2 && type > TIPC_RESERVED_TYPES) {
|
||||
address.family = AF_TIPC;
|
||||
address.addrtype = TIPC_ADDR_NAME;
|
||||
address.addr.name.name.type = type;
|
||||
|
@ -204,8 +204,9 @@ bool zmq::ws_engine_t::select_protocol (char *protocol_)
|
||||
_process_msg = static_cast<int (stream_engine_base_t::*) (msg_t *)> (
|
||||
&ws_engine_t::process_routing_id_msg);
|
||||
return true;
|
||||
} else if (_options.mechanism == ZMQ_NULL
|
||||
&& strcmp ("ZWS2.0/NULL", protocol_) == 0) {
|
||||
}
|
||||
if (_options.mechanism == ZMQ_NULL
|
||||
&& strcmp ("ZWS2.0/NULL", protocol_) == 0) {
|
||||
_mechanism = new (std::nothrow)
|
||||
null_mechanism_t (session (), _peer_address, _options);
|
||||
alloc_assert (_mechanism);
|
||||
@ -510,8 +511,8 @@ bool zmq::ws_engine_t::server_handshake ()
|
||||
_insize--;
|
||||
|
||||
return true;
|
||||
} else
|
||||
_server_handshake_state = handshake_error;
|
||||
}
|
||||
_server_handshake_state = handshake_error;
|
||||
} else
|
||||
_server_handshake_state = handshake_error;
|
||||
break;
|
||||
@ -853,8 +854,8 @@ bool zmq::ws_engine_t::client_handshake ()
|
||||
_insize--;
|
||||
|
||||
return true;
|
||||
} else
|
||||
_client_handshake_state = client_handshake_error;
|
||||
}
|
||||
_client_handshake_state = client_handshake_error;
|
||||
} else
|
||||
_client_handshake_state = client_handshake_error;
|
||||
break;
|
||||
|
@ -126,8 +126,8 @@ std::string zmq::ws_listener_t::get_socket_name (zmq::fd_t fd_,
|
||||
{
|
||||
if (_wss)
|
||||
return zmq::get_socket_name<wss_address_t> (fd_, socket_end_);
|
||||
else
|
||||
return zmq::get_socket_name<ws_address_t> (fd_, socket_end_);
|
||||
|
||||
return zmq::get_socket_name<ws_address_t> (fd_, socket_end_);
|
||||
}
|
||||
|
||||
int zmq::ws_listener_t::create_socket (const char *addr_)
|
||||
|
@ -109,10 +109,9 @@ int zmq::xsub_t::xsetsockopt (int option_,
|
||||
}
|
||||
_only_first_subscribe = (*static_cast<const int *> (optval_) != 0);
|
||||
return 0;
|
||||
} else {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int zmq::xsub_t::xsend (msg_t *msg_)
|
||||
|
@ -274,8 +274,8 @@ zmq::mechanism_t::status_t zap_client_common_handshake_t::status () const
|
||||
return mechanism_t::ready;
|
||||
if (state == error_sent)
|
||||
return mechanism_t::error;
|
||||
else
|
||||
return mechanism_t::handshaking;
|
||||
|
||||
return mechanism_t::handshaking;
|
||||
}
|
||||
|
||||
int zap_client_common_handshake_t::zap_msg_available ()
|
||||
|
@ -1305,9 +1305,8 @@ int zmq_poller_fd (void *poller_, zmq_fd_t *fd_)
|
||||
|| !(static_cast<zmq::socket_poller_t *> (poller_)->check_tag ())) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
} else {
|
||||
return static_cast<zmq::socket_poller_t *> (poller_)->signaler_fd (fd_);
|
||||
}
|
||||
return static_cast<zmq::socket_poller_t *> (poller_)->signaler_fd (fd_);
|
||||
}
|
||||
|
||||
// Peer-specific state
|
||||
|
@ -257,9 +257,8 @@ static const char *mcast_url (int ipv6_)
|
||||
{
|
||||
if (ipv6_) {
|
||||
return "udp://[" MCAST_IPV6 "]:5555";
|
||||
} else {
|
||||
return "udp://" MCAST_IPV4 ":5555";
|
||||
}
|
||||
return "udp://" MCAST_IPV4 ":5555";
|
||||
}
|
||||
|
||||
// OSX uses a different name for this socket option
|
||||
|
@ -335,9 +335,8 @@ static uint64_t host_to_network (uint64_t value_)
|
||||
htonl (static_cast<uint32_t> (value_ & 0xFFFFFFFFLL));
|
||||
|
||||
return (static_cast<uint64_t> (low_part) << 32) | high_part;
|
||||
} else {
|
||||
return value_;
|
||||
}
|
||||
return value_;
|
||||
}
|
||||
|
||||
template <size_t N> void send_command (fd_t s_, char (&command_)[N])
|
||||
|
@ -73,16 +73,16 @@ void test ()
|
||||
if (rc == -1) {
|
||||
TEST_ASSERT_EQUAL_INT (EAGAIN, errno);
|
||||
break;
|
||||
} else {
|
||||
TEST_ASSERT_EQUAL_INT (0, rc);
|
||||
recv_count++;
|
||||
|
||||
if (recv_count == 1) {
|
||||
const int sub_rcvtimeo = 250;
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (
|
||||
sub, ZMQ_RCVTIMEO, &sub_rcvtimeo, sizeof (sub_rcvtimeo)));
|
||||
}
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT (0, rc);
|
||||
recv_count++;
|
||||
|
||||
if (recv_count == 1) {
|
||||
const int sub_rcvtimeo = 250;
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (
|
||||
sub, ZMQ_RCVTIMEO, &sub_rcvtimeo, sizeof (sub_rcvtimeo)));
|
||||
}
|
||||
|
||||
} while (true);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT (send_count, recv_count);
|
||||
|
@ -160,9 +160,9 @@ static void test_resolve (zmq::ip_resolver_options_t opts_,
|
||||
// TODO also check the expected errno
|
||||
TEST_ASSERT_EQUAL (-1, rc);
|
||||
return;
|
||||
} else {
|
||||
TEST_ASSERT_SUCCESS_ERRNO (rc);
|
||||
}
|
||||
TEST_ASSERT_SUCCESS_ERRNO (rc);
|
||||
|
||||
|
||||
validate_address (family, &addr, expected_addr_, expected_port_,
|
||||
expected_zone_, expected_addr_v4_failover_);
|
||||
|
@ -54,9 +54,9 @@ static void test_resolve (bool bind_,
|
||||
TEST_ASSERT_EQUAL (-1, rc);
|
||||
TEST_ASSERT_EQUAL (EINVAL, errno);
|
||||
return;
|
||||
} else {
|
||||
TEST_ASSERT_EQUAL (0, rc);
|
||||
}
|
||||
TEST_ASSERT_EQUAL (0, rc);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL (multicast_, addr.is_mcast ());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user