Skip to content

Commit e37b0d4

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix unreachable-break-or-return issue in proxygen/lib/http/codec/HTTPCodec.h +5
Summary: LLVM has two warnings `-Wunreachable-code-return` and `-Wunreachable-code-break` which identify `return` and `break` statements that cannot be reached. These compromise readability, can be misleading, and may identify bugs. This diff removes such statements. `break` was often used defensively in `switch` statements. We now have `-Wimplicit-fallthrough` [enabled globally](https://fb.workplace.com/groups/fbcode/posts/8021835991186503), which replaces this inexact practice with a compiler guarantee. The compiler used to be less intelligent and would throw an error if a function didn't return the correct type after a `throw` statement. The compiler is smarter now, so this code is unnecessary. `-Wreturn-type` is enabled globally and prevents functions from ending without an appropriate return. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: dtolnay Differential Revision: D79967259 fbshipit-source-id: 37b547b324af1db83599ccc78a927d4be77ec6f3
1 parent 1d94ca0 commit e37b0d4

File tree

5 files changed

+0
-7
lines changed

5 files changed

+0
-7
lines changed

third-party/proxygen/src/proxygen/lib/http/codec/HTTPCodec.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ class HTTPCodec {
386386
[[fallthrough]];
387387
default:
388388
LOG(FATAL) << "Unreachable";
389-
return std::numeric_limits<size_t>::max();
390389
}
391390
}
392391

third-party/proxygen/src/proxygen/lib/http/codec/HTTPCodecFactory.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ std::unique_ptr<HTTPCodec> HTTPCodecFactory::getCodec(
2929
}
3030
default:
3131
LOG(FATAL) << "Unreachable";
32-
return nullptr;
3332
}
3433
}
3534

third-party/proxygen/src/proxygen/lib/http/codec/compress/QPACKStaticHeaderTable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ namespace proxygen {
141141
bool QPACKStaticHeaderTable::isHeaderCodeInTableWithNonEmptyValue(
142142
HTTPHeaderCode /*headerCode*/) {
143143
LOG(FATAL) << __func__ << " not supported for QPACK";
144-
return false;
145144
}
146145

147146
const StaticHeaderTable& QPACKStaticHeaderTable::get() {

third-party/proxygen/src/proxygen/lib/http/codec/compress/experimental/simulator/CompressionSimulator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ unique_ptr<CompressionScheme> CompressionSimulator::makeScheme() {
279279
return make_unique<HPACKScheme>(this, params_.tableSize);
280280
}
281281
LOG(FATAL) << "Bad scheme";
282-
return nullptr;
283282
}
284283

285284
std::pair<FrameFlags, unique_ptr<IOBuf>> CompressionSimulator::encode(

third-party/proxygen/src/proxygen/lib/http/codec/test/HQCodecTest.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,6 @@ std::string frameParamsToTestName(
905905
break;
906906
default:
907907
LOG(FATAL) << "Unknown Codec Type";
908-
break;
909908
}
910909
switch (info.param.frameType) {
911910
case FrameType::DATA:
@@ -982,7 +981,6 @@ TEST_P(HQCodecTestFrameAllowed, FrameAllowedOnCodec) {
982981
break;
983982
default:
984983
CHECK(false);
985-
break;
986984
}
987985
expectedFrames += GetParam().allowed ? 1 : 0;
988986
EXPECT_EQ(callbacks_.headerFrames, expectedFrames);
@@ -1015,7 +1013,6 @@ TEST_P(HQCodecTestFrameAllowed, FrameAllowedOnCodec) {
10151013
break;
10161014
default:
10171015
CHECK(false);
1018-
break;
10191016
}
10201017
EXPECT_EQ(lenBefore, lenAfter);
10211018
EXPECT_EQ(callbacks_.headerFrames, expectedFrames);

0 commit comments

Comments
 (0)