Problem: redundant else after return

Solution: remove else
This commit is contained in:
Simon Giesecke 2019-12-08 15:04:50 +01:00 committed by Simon Giesecke
parent 1d9c6bcf09
commit cb2b377d9f
16 changed files with 49 additions and 53 deletions

View File

@ -128,8 +128,8 @@ zmq::mechanism_t::status_t zmq::curve_client_t::status () const
return mechanism_t::ready; return mechanism_t::ready;
if (_state == error_received) if (_state == error_received)
return mechanism_t::error; return mechanism_t::error;
else
return mechanism_t::handshaking; return mechanism_t::handshaking;
} }
int zmq::curve_client_t::produce_hello (msg_t *msg_) int zmq::curve_client_t::produce_hello (msg_t *msg_)

View File

@ -255,9 +255,9 @@ int zmq::bind_to_device (fd_t s_, const std::string &bound_device_)
if (rc != 0) { if (rc != 0) {
assert_success_or_recoverable (s_, rc); assert_success_or_recoverable (s_, rc);
return -1; return -1;
} else {
return 0;
} }
return 0;
#else #else
LIBZMQ_UNUSED (s_); LIBZMQ_UNUSED (s_);
LIBZMQ_UNUSED (bound_device_); LIBZMQ_UNUSED (bound_device_);
@ -550,10 +550,10 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
errno_assert (errno == ENFILE || errno == EMFILE); errno_assert (errno == ENFILE || errno == EMFILE);
*w_ = *r_ = -1; *w_ = *r_ = -1;
return -1; return -1;
} else {
*w_ = *r_ = fd;
return 0;
} }
*w_ = *r_ = fd;
return 0;
#elif defined ZMQ_HAVE_WINDOWS #elif defined ZMQ_HAVE_WINDOWS
#ifdef ZMQ_HAVE_IPC #ifdef ZMQ_HAVE_IPC

View File

@ -128,8 +128,8 @@ int forward (class zmq::socket_base_t *from_,
if (rc < 0) { if (rc < 0) {
if (likely (errno == EAGAIN && i > 0)) if (likely (errno == EAGAIN && i > 0))
return 0; // End of burst return 0; // End of burst
else
return -1; return -1;
} }
complete_msg_size += msg_->size (); complete_msg_size += msg_->size ();

View File

@ -91,11 +91,10 @@ int zmq::socket_poller_t::signaler_fd (fd_t *fd_)
if (_signaler) { if (_signaler) {
*fd_ = _signaler->get_fd (); *fd_ = _signaler->get_fd ();
return 0; 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_, int zmq::socket_poller_t::add (socket_base_t *socket_,

View File

@ -465,14 +465,13 @@ int zmq::stream_engine_base_t::next_handshake_command (msg_t *msg_)
if (_mechanism->status () == mechanism_t::error) { if (_mechanism->status () == mechanism_t::error) {
errno = EPROTO; errno = EPROTO;
return -1; 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_) int zmq::stream_engine_base_t::process_handshake_command (msg_t *msg_)

View File

@ -108,7 +108,8 @@ int zmq::tipc_address_t::resolve (const char *name_)
address.addr.nameseq.upper = upper; address.addr.nameseq.upper = upper;
address.scope = TIPC_ZONE_SCOPE; address.scope = TIPC_ZONE_SCOPE;
return 0; return 0;
} else if (res == 2 && type > TIPC_RESERVED_TYPES) { }
if (res == 2 && type > TIPC_RESERVED_TYPES) {
address.family = AF_TIPC; address.family = AF_TIPC;
address.addrtype = TIPC_ADDR_NAME; address.addrtype = TIPC_ADDR_NAME;
address.addr.name.name.type = type; address.addr.name.name.type = type;

View File

@ -204,8 +204,9 @@ bool zmq::ws_engine_t::select_protocol (char *protocol_)
_process_msg = static_cast<int (stream_engine_base_t::*) (msg_t *)> ( _process_msg = static_cast<int (stream_engine_base_t::*) (msg_t *)> (
&ws_engine_t::process_routing_id_msg); &ws_engine_t::process_routing_id_msg);
return true; 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) _mechanism = new (std::nothrow)
null_mechanism_t (session (), _peer_address, _options); null_mechanism_t (session (), _peer_address, _options);
alloc_assert (_mechanism); alloc_assert (_mechanism);
@ -510,8 +511,8 @@ bool zmq::ws_engine_t::server_handshake ()
_insize--; _insize--;
return true; return true;
} else }
_server_handshake_state = handshake_error; _server_handshake_state = handshake_error;
} else } else
_server_handshake_state = handshake_error; _server_handshake_state = handshake_error;
break; break;
@ -853,8 +854,8 @@ bool zmq::ws_engine_t::client_handshake ()
_insize--; _insize--;
return true; return true;
} else }
_client_handshake_state = client_handshake_error; _client_handshake_state = client_handshake_error;
} else } else
_client_handshake_state = client_handshake_error; _client_handshake_state = client_handshake_error;
break; break;

View File

@ -126,8 +126,8 @@ std::string zmq::ws_listener_t::get_socket_name (zmq::fd_t fd_,
{ {
if (_wss) if (_wss)
return zmq::get_socket_name<wss_address_t> (fd_, socket_end_); 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_) int zmq::ws_listener_t::create_socket (const char *addr_)

View File

@ -109,10 +109,9 @@ int zmq::xsub_t::xsetsockopt (int option_,
} }
_only_first_subscribe = (*static_cast<const int *> (optval_) != 0); _only_first_subscribe = (*static_cast<const int *> (optval_) != 0);
return 0; return 0;
} else {
errno = EINVAL;
return -1;
} }
errno = EINVAL;
return -1;
} }
int zmq::xsub_t::xsend (msg_t *msg_) int zmq::xsub_t::xsend (msg_t *msg_)

View File

@ -274,8 +274,8 @@ zmq::mechanism_t::status_t zap_client_common_handshake_t::status () const
return mechanism_t::ready; return mechanism_t::ready;
if (state == error_sent) if (state == error_sent)
return mechanism_t::error; return mechanism_t::error;
else
return mechanism_t::handshaking; return mechanism_t::handshaking;
} }
int zap_client_common_handshake_t::zap_msg_available () int zap_client_common_handshake_t::zap_msg_available ()

View File

@ -1305,9 +1305,8 @@ int zmq_poller_fd (void *poller_, zmq_fd_t *fd_)
|| !(static_cast<zmq::socket_poller_t *> (poller_)->check_tag ())) { || !(static_cast<zmq::socket_poller_t *> (poller_)->check_tag ())) {
errno = EFAULT; errno = EFAULT;
return -1; 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 // Peer-specific state

View File

@ -257,9 +257,8 @@ static const char *mcast_url (int ipv6_)
{ {
if (ipv6_) { if (ipv6_) {
return "udp://[" MCAST_IPV6 "]:5555"; 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 // OSX uses a different name for this socket option

View File

@ -335,9 +335,8 @@ static uint64_t host_to_network (uint64_t value_)
htonl (static_cast<uint32_t> (value_ & 0xFFFFFFFFLL)); htonl (static_cast<uint32_t> (value_ & 0xFFFFFFFFLL));
return (static_cast<uint64_t> (low_part) << 32) | high_part; 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]) template <size_t N> void send_command (fd_t s_, char (&command_)[N])

View File

@ -73,16 +73,16 @@ void test ()
if (rc == -1) { if (rc == -1) {
TEST_ASSERT_EQUAL_INT (EAGAIN, errno); TEST_ASSERT_EQUAL_INT (EAGAIN, errno);
break; 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); } while (true);
TEST_ASSERT_EQUAL_INT (send_count, recv_count); TEST_ASSERT_EQUAL_INT (send_count, recv_count);

View File

@ -160,9 +160,9 @@ static void test_resolve (zmq::ip_resolver_options_t opts_,
// TODO also check the expected errno // TODO also check the expected errno
TEST_ASSERT_EQUAL (-1, rc); TEST_ASSERT_EQUAL (-1, rc);
return; return;
} else {
TEST_ASSERT_SUCCESS_ERRNO (rc);
} }
TEST_ASSERT_SUCCESS_ERRNO (rc);
validate_address (family, &addr, expected_addr_, expected_port_, validate_address (family, &addr, expected_addr_, expected_port_,
expected_zone_, expected_addr_v4_failover_); expected_zone_, expected_addr_v4_failover_);

View File

@ -54,9 +54,9 @@ static void test_resolve (bool bind_,
TEST_ASSERT_EQUAL (-1, rc); TEST_ASSERT_EQUAL (-1, rc);
TEST_ASSERT_EQUAL (EINVAL, errno); TEST_ASSERT_EQUAL (EINVAL, errno);
return; return;
} else {
TEST_ASSERT_EQUAL (0, rc);
} }
TEST_ASSERT_EQUAL (0, rc);
TEST_ASSERT_EQUAL (multicast_, addr.is_mcast ()); TEST_ASSERT_EQUAL (multicast_, addr.is_mcast ());