From 4168732ce0baa354cb86a1ed819a25b0af10795d Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Fri, 9 Dec 2016 18:26:52 -0800 Subject: [PATCH] Enable -Wunreachable-code-break Summary: Because the `break;` can be dead, and sometimes is indicitive of a different type of error. Reviewed By: meyering Differential Revision: D4310056 fbshipit-source-id: ad215eb9b2e5bb4d5c703582203efce893b26a76 --- folly/io/async/test/EventBaseTest.cpp | 35 ++++++++++++--------------- folly/io/test/IOBufTest.cpp | 1 - 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/folly/io/async/test/EventBaseTest.cpp b/folly/io/async/test/EventBaseTest.cpp index 940a1829..4fa84ed7 100644 --- a/folly/io/async/test/EventBaseTest.cpp +++ b/folly/io/async/test/EventBaseTest.cpp @@ -1578,28 +1578,23 @@ TEST(EventBaseTest, IdleTime) { int latencyCallbacks = 0; eventBase.setMaxLatency(6000, [&]() { ++latencyCallbacks; - - switch (latencyCallbacks) { - case 1: - if (tos0.getTimeouts() < 6) { - // This could only happen if the host this test is running - // on is heavily loaded. - int64_t maxLatencyReached = duration_cast( - std::chrono::steady_clock::now().time_since_epoch()).count(); - ASSERT_LE(43800, maxLatencyReached - testStart); - hostOverloaded = true; - break; - } - ASSERT_EQ(6, tos0.getTimeouts()); - ASSERT_GE(6100, eventBase.getAvgLoopTime() - 1200); - ASSERT_LE(6100, eventBase.getAvgLoopTime() + 1200); - tos.reset(new IdleTimeTimeoutSeries(&eventBase, timeouts)); - break; - - default: + if (latencyCallbacks != 1) { FAIL() << "Unexpected latency callback"; - break; } + + if (tos0.getTimeouts() < 6) { + // This could only happen if the host this test is running + // on is heavily loaded. + int64_t maxLatencyReached = duration_cast( + std::chrono::steady_clock::now().time_since_epoch()).count(); + ASSERT_LE(43800, maxLatencyReached - testStart); + hostOverloaded = true; + return; + } + ASSERT_EQ(6, tos0.getTimeouts()); + ASSERT_GE(6100, eventBase.getAvgLoopTime() - 1200); + ASSERT_LE(6100, eventBase.getAvgLoopTime() + 1200); + tos.reset(new IdleTimeTimeoutSeries(&eventBase, timeouts)); }); // Kick things off with an "immedite" timeout diff --git a/folly/io/test/IOBufTest.cpp b/folly/io/test/IOBufTest.cpp index a615496c..a84eb84b 100644 --- a/folly/io/test/IOBufTest.cpp +++ b/folly/io/test/IOBufTest.cpp @@ -883,7 +883,6 @@ class MoveToFbStringTest } default: throw std::invalid_argument("unexpected buffer type parameter"); - break; } memset(buf->writableData(), 'x', elementSize_); return buf; -- 2.34.1