Skip to content

Commit 6d2f0d5

Browse files
committed
remove unreachable code branches
1 parent e14d19d commit 6d2f0d5

File tree

10 files changed

+13
-25
lines changed

10 files changed

+13
-25
lines changed

src/sw/redis++/async_connection.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ AsyncConnection::AsyncConnection(const ConnectionOptions &opts,
132132

133133
default:
134134
throw Error("not supporeted async connection mode");
135-
break;
136135
}
137136
}
138137

src/sw/redis++/async_connection.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,9 @@ class ClusterEvent : public CommandEvent<Result, ResultParser> {
544544
switch (event->_state) {
545545
case State::MOVED:
546546
throw Error("too many moved error");
547-
break;
548547

549548
case State::ASKING:
550549
throw Error("Slot migrating...");
551-
break;
552550

553551
default:
554552
break;

src/sw/redis++/async_subscriber_impl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ void AsyncSubscriberImpl::_run_callback(redisReply &reply) {
7474
break;
7575

7676
default:
77-
assert(false);
77+
assert(type == Subscriber::MsgType::UNKNOWN);
78+
79+
throw ProtoError("unknown message type.");
7880
}
7981
}
8082

@@ -99,10 +101,9 @@ Subscriber::MsgType AsyncSubscriberImpl::_msg_type(const std::string &type) cons
99101
return Subscriber::MsgType::PSUBSCRIBE;
100102
} else if ("punsubscribe" == type) {
101103
return Subscriber::MsgType::PUNSUBSCRIBE;
104+
} else {
105+
return Subscriber::MsgType::UNKNOWN;
102106
}
103-
104-
throw ProtoError("Invalid message type.");
105-
return Subscriber::MsgType::MESSAGE; // Silence "no return" warnings.
106107
}
107108

108109
void AsyncSubscriberImpl::_handle_message(redisReply &reply) {

src/sw/redis++/command.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ void set_geo_unit(CmdArgs &args, GeoUnit unit) {
347347

348348
default:
349349
throw Error("Unknown geo unit type");
350-
break;
351350
}
352351
}
353352

src/sw/redis++/connection.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ std::string ConnectionOptions::_server_info() const {
169169
default:
170170
// Never goes here.
171171
throw Error("unknown connection type");
172-
break;
173172
}
174173

175174
return info;

src/sw/redis++/errors.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,22 @@ void throw_error(const redisContext &context, const std::string &err_info) {
5454
} else {
5555
throw IoError(err_msg);
5656
}
57-
break;
5857

5958
case REDIS_ERR_EOF:
6059
throw ClosedError(err_msg);
61-
break;
6260

6361
case REDIS_ERR_PROTOCOL:
6462
throw ProtoError(err_msg);
65-
break;
6663

6764
case REDIS_ERR_OOM:
6865
throw OomError(err_msg);
69-
break;
7066

7167
case REDIS_ERR_OTHER:
7268
throw Error(err_msg);
73-
break;
7469

7570
#ifdef REDIS_ERR_TIMEOUT
7671
case REDIS_ERR_TIMEOUT:
7772
throw TimeoutError(err_msg);
78-
break;
7973
#endif
8074

8175
default:
@@ -99,15 +93,12 @@ void throw_error(const redisReply &reply) {
9993
switch (err_type) {
10094
case ReplyErrorType::MOVED:
10195
throw MovedError(err_msg);
102-
break;
10396

10497
case ReplyErrorType::ASK:
10598
throw AskError(err_msg);
106-
break;
10799

108100
default:
109101
throw ReplyError(err_str);
110-
break;
111102
}
112103
}
113104

src/sw/redis++/reply.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ T parse(ParseTag<T>, redisReply &reply) {
426426
throw ParseError("ARRAY or SET", reply);
427427
#else
428428
if (!is_array(reply)) {
429-
#endif
430429
throw ParseError("ARRAY", reply);
430+
#endif
431431
}
432432

433433
T container;

src/sw/redis++/subscriber.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ void Subscriber::consume() {
109109
break;
110110

111111
default:
112-
assert(false);
112+
assert(type == MsgType::UNKNOWN);
113+
114+
throw ProtoError("unknown message type.");
113115
}
114116
}
115117

@@ -135,10 +137,9 @@ Subscriber::MsgType Subscriber::_msg_type(std::string const& type) const
135137
return MsgType::PSUBSCRIBE;
136138
} else if ("punsubscribe" == type) {
137139
return MsgType::PUNSUBSCRIBE;
140+
} else {
141+
return MsgType::UNKNOWN;
138142
}
139-
140-
throw ProtoError("Invalid message type.");
141-
return MsgType::MESSAGE; // Silence "no return" warnings.
142143
}
143144

144145
void Subscriber::_check_connection() {

src/sw/redis++/subscriber.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class Subscriber {
7676
PSUBSCRIBE,
7777
PUNSUBSCRIBE,
7878
MESSAGE,
79-
PMESSAGE
79+
PMESSAGE,
80+
UNKNOWN
8081
};
8182

8283
template <typename MsgCb>

test/src/sw/redis++/test_main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ auto parse_options(int argc, char **argv)
321321

322322
default:
323323
throw sw::redis::Error("Unknown command line option");
324-
break;
325324
}
326325
} catch (const sw::redis::Error &e) {
327326
print_help();

0 commit comments

Comments
 (0)