Enable -Wunreachable-code-break v2016.12.12.00
authorChristopher Dykes <cdykes@fb.com>
Sat, 10 Dec 2016 02:26:52 +0000 (18:26 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Sat, 10 Dec 2016 02:32:58 +0000 (18:32 -0800)
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
folly/io/test/IOBufTest.cpp

index 940a1829dd180b226346d02b19385296fe46f1c7..4fa84ed7eeec3004b7651ddd023e213dd80837a8 100644 (file)
@@ -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<microseconds>(
-            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<microseconds>(
+          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
index a615496c1d8e9a9abaedb5fde82d3a2cba23d374..a84eb84b8096bfa70f036f5bb2a495499202551c 100644 (file)
@@ -883,7 +883,6 @@ class MoveToFbStringTest
       }
       default:
         throw std::invalid_argument("unexpected buffer type parameter");
-        break;
     }
     memset(buf->writableData(), 'x', elementSize_);
     return buf;