Skip to content

Commit

Permalink
remove unreachable code branches
Browse files Browse the repository at this point in the history
  • Loading branch information
sewenew committed Jun 15, 2023
1 parent e14d19d commit 6d2f0d5
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/sw/redis++/async_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ AsyncConnection::AsyncConnection(const ConnectionOptions &opts,

default:
throw Error("not supporeted async connection mode");
break;
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/sw/redis++/async_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,9 @@ class ClusterEvent : public CommandEvent<Result, ResultParser> {
switch (event->_state) {
case State::MOVED:
throw Error("too many moved error");
break;

case State::ASKING:
throw Error("Slot migrating...");
break;

default:
break;
Expand Down
9 changes: 5 additions & 4 deletions src/sw/redis++/async_subscriber_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void AsyncSubscriberImpl::_run_callback(redisReply &reply) {
break;

default:
assert(false);
assert(type == Subscriber::MsgType::UNKNOWN);

throw ProtoError("unknown message type.");
}
}

Expand All @@ -99,10 +101,9 @@ Subscriber::MsgType AsyncSubscriberImpl::_msg_type(const std::string &type) cons
return Subscriber::MsgType::PSUBSCRIBE;
} else if ("punsubscribe" == type) {
return Subscriber::MsgType::PUNSUBSCRIBE;
} else {
return Subscriber::MsgType::UNKNOWN;
}

throw ProtoError("Invalid message type.");
return Subscriber::MsgType::MESSAGE; // Silence "no return" warnings.
}

void AsyncSubscriberImpl::_handle_message(redisReply &reply) {
Expand Down
1 change: 0 additions & 1 deletion src/sw/redis++/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ void set_geo_unit(CmdArgs &args, GeoUnit unit) {

default:
throw Error("Unknown geo unit type");
break;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/sw/redis++/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ std::string ConnectionOptions::_server_info() const {
default:
// Never goes here.
throw Error("unknown connection type");
break;
}

return info;
Expand Down
9 changes: 0 additions & 9 deletions src/sw/redis++/errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,22 @@ void throw_error(const redisContext &context, const std::string &err_info) {
} else {
throw IoError(err_msg);
}
break;

case REDIS_ERR_EOF:
throw ClosedError(err_msg);
break;

case REDIS_ERR_PROTOCOL:
throw ProtoError(err_msg);
break;

case REDIS_ERR_OOM:
throw OomError(err_msg);
break;

case REDIS_ERR_OTHER:
throw Error(err_msg);
break;

#ifdef REDIS_ERR_TIMEOUT
case REDIS_ERR_TIMEOUT:
throw TimeoutError(err_msg);
break;
#endif

default:
Expand All @@ -99,15 +93,12 @@ void throw_error(const redisReply &reply) {
switch (err_type) {
case ReplyErrorType::MOVED:
throw MovedError(err_msg);
break;

case ReplyErrorType::ASK:
throw AskError(err_msg);
break;

default:
throw ReplyError(err_str);
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sw/redis++/reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ T parse(ParseTag<T>, redisReply &reply) {
throw ParseError("ARRAY or SET", reply);
#else
if (!is_array(reply)) {
#endif
throw ParseError("ARRAY", reply);
#endif
}

T container;
Expand Down
9 changes: 5 additions & 4 deletions src/sw/redis++/subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ void Subscriber::consume() {
break;

default:
assert(false);
assert(type == MsgType::UNKNOWN);

throw ProtoError("unknown message type.");
}
}

Expand All @@ -135,10 +137,9 @@ Subscriber::MsgType Subscriber::_msg_type(std::string const& type) const
return MsgType::PSUBSCRIBE;
} else if ("punsubscribe" == type) {
return MsgType::PUNSUBSCRIBE;
} else {
return MsgType::UNKNOWN;
}

throw ProtoError("Invalid message type.");
return MsgType::MESSAGE; // Silence "no return" warnings.
}

void Subscriber::_check_connection() {
Expand Down
3 changes: 2 additions & 1 deletion src/sw/redis++/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class Subscriber {
PSUBSCRIBE,
PUNSUBSCRIBE,
MESSAGE,
PMESSAGE
PMESSAGE,
UNKNOWN
};

template <typename MsgCb>
Expand Down
1 change: 0 additions & 1 deletion test/src/sw/redis++/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ auto parse_options(int argc, char **argv)

default:
throw sw::redis::Error("Unknown command line option");
break;
}
} catch (const sw::redis::Error &e) {
print_help();
Expand Down

0 comments on commit 6d2f0d5

Please sign in to comment.