Don't declare a variable for exceptions we discard
authorChristopher Dykes <cdykes@fb.com>
Mon, 12 Dec 2016 19:39:32 +0000 (11:39 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Mon, 12 Dec 2016 19:48:05 +0000 (11:48 -0800)
Summary: They aren't needed and they count as initialized but unused variables.

Reviewed By: yfeldblum

Differential Revision: D4308844

fbshipit-source-id: a6833dbf434ebdefff0b375729a4e62495463ac0

15 files changed:
folly/Format-inl.h
folly/FormatArg.h
folly/experimental/DynamicParser-inl.h
folly/experimental/JSONSchema.cpp
folly/experimental/ProgramOptions.cpp
folly/io/async/AsyncSSLSocket.cpp
folly/io/async/AsyncServerSocket.cpp
folly/io/async/NotificationQueue.h
folly/io/async/test/AsyncSSLSocketTest.cpp
folly/test/AtomicUnorderedMapTest.cpp
folly/test/ConvTest.cpp
folly/test/DynamicTest.cpp
folly/test/LifoSemTests.cpp
folly/test/StringTest.cpp
folly/test/UriTest.cpp

index c27b7662ae1f71c52fe31512945ccd50f074d69c..7b717363152cd0d2b67219805ebff951c0638789 100644 (file)
@@ -256,7 +256,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out)
 
         try {
           argIndex = to<int>(piece);
-        } catch (const std::out_of_range& e) {
+        } catch (const std::out_of_range&) {
           arg.error("argument index must be integer");
         }
         arg.enforce(argIndex >= 0, "argument index must be non-negative");
index 701654b3397453a8a59e7c924c0a6ff08ff858dc..89c7e9337b5a3486f2841ba1da2b00889d5dd827 100644 (file)
@@ -267,7 +267,7 @@ inline int FormatArg::splitIntKey() {
   }
   try {
     return to<int>(doSplitKey<true>());
-  } catch (const std::out_of_range& e) {
+  } catch (const std::out_of_range&) {
     error("integer key required");
     return 0;  // unreached
   }
index df390b74f2a5ccc0ee83c0b90605a672f527d7c4..6619132837e7544c21ea1363f2fb77c290600c12 100644 (file)
@@ -263,11 +263,11 @@ template <typename Fn>
 void DynamicParser::wrapError(const folly::dynamic* lookup_k, Fn fn) {
   try {
     fn();
-  } catch (DynamicParserLogicError& ex) {
+  } catch (DynamicParserLogicError&) {
     // When the parser is misused, we throw all the way up to the user,
     // instead of reporting it as if the input is invalid.
     throw;
-  } catch (DynamicParserParseError& ex) {
+  } catch (DynamicParserParseError&) {
     // We are just bubbling up a parse error for OnError::THROW.
     throw;
   } catch (const std::exception& ex) {
index a550cee93518253b78787396c5cc3fd87a178aa3..e2db5c450691f648cc1043079de1bcd15c3e30f4 100644 (file)
@@ -691,7 +691,7 @@ void SchemaValidator::loadSchema(SchemaValidatorContext& context,
               s = s->get_ptr(pos);
               continue;
             }
-          } catch (const std::range_error& e) {
+          } catch (const std::range_error&) {
             // ignore
           }
         }
index 9e988514a4736a197b567c95e136a51c244f9b4e..bd8acada7d132d67fc4f10767f548fd1ab4a7ff3 100644 (file)
@@ -119,7 +119,7 @@ void GFlagValueSemanticBase<T>::parse(boost::any& valueStore,
   try {
     val = this->parseValue(tokens);
     this->transform(val);
-  } catch (const std::exception& e) {
+  } catch (const std::exception&) {
     throw po::invalid_option_value(
         tokens.empty() ? std::string() : tokens.front());
   }
index 8ce1644580d2ce2e3c0dfdc109c7219fff754609..aa34b1a08764a7ee9f9e7bf7d45149c714d98fc7 100644 (file)
@@ -1710,7 +1710,7 @@ void AsyncSSLSocket::clientHelloParsingCallback(int written,
         }
       }
     }
-  } catch (std::out_of_range& e) {
+  } catch (std::out_of_range&) {
     // we'll use what we found and cleanup below.
     VLOG(4) << "AsyncSSLSocket::clientHelloParsingCallback(): "
       << "buffer finished unexpectedly." << " AsyncSSLSocket socket=" << sock;
index cb4c1a2d2c42dc0feacbd13a4149eef74a66f4d0..cf0a1e9913f3a5f6a990c168476ac9f0370a4cc5 100644 (file)
@@ -449,7 +449,7 @@ void AsyncServerSocket::bind(uint16_t port) {
           setupAddress(res);
         }
       }
-    } catch (const std::system_error& e) {
+    } catch (const std::system_error&) {
       // If we can't bind to the same port on ipv4 as ipv6 when using
       // port=0 then we will retry again before giving up after
       // kNumTries attempts.  We do this by closing the sockets that
@@ -953,7 +953,7 @@ void AsyncServerSocket::enterBackoff() {
   if (backoffTimeout_ == nullptr) {
     try {
       backoffTimeout_ = new BackoffTimeout(this);
-    } catch (const std::bad_alloc& ex) {
+    } catch (const std::bad_alloc&) {
       // Man, we couldn't even allocate the timer to re-enable accepts.
       // We must be in pretty bad shape.  Don't pause accepting for now,
       // since we won't be able to re-enable ourselves later.
index 88b1c7b9565874071e6360bc9c717d6f0a834aee..c1c64617ae11e73dc597ed85c031602714e664da 100644 (file)
@@ -753,7 +753,7 @@ void NotificationQueue<MessageT>::Consumer::consumeMessages(
       if (wasEmpty) {
         return;
       }
-    } catch (const std::exception& ex) {
+    } catch (const std::exception&) {
       // This catch block is really just to handle the case where the MessageT
       // constructor throws.  The messageAvailable() callback itself is
       // declared as noexcept and should never throw.
index f2bd909ff81b12155347b40ceb127c2a618d3148..181a33451e226b0f227f9cc2b9688988a592ed7d 100644 (file)
@@ -311,7 +311,7 @@ TEST(AsyncSSLSocketTest, HandshakeError) {
     uint8_t readbuf[128];
     uint32_t bytesRead = socket->readAll(readbuf, sizeof(readbuf));
     LOG(ERROR) << "readAll returned " << bytesRead << " instead of throwing";
-  } catch (AsyncSocketException &e) {
+  } catch (AsyncSocketException&) {
     ex = true;
   }
   EXPECT_TRUE(ex);
index e1a0104c5f3ca643b1f879a6c4bb255608a2bb31..7093e726c0427b6a99780a6f28ecc23443c445e0 100644 (file)
@@ -275,7 +275,7 @@ void contendedRW(size_t itersPerThread,
               if (!pr.second) {
                 pr.first->second.data++;
               }
-            } catch (std::bad_alloc& x) {
+            } catch (std::bad_alloc&) {
               LOG(INFO) << "bad alloc";
             }
           }
index 2109d1a6a2c532308ef26cde3ecb5d934000cece..5109fbbc382662ae6c21acdbfe925bc1e4098e94 100644 (file)
@@ -667,7 +667,7 @@ TEST(Conv, DoubleToInt) {
     auto i2 = to<int>(42.1);
     LOG(ERROR) << "to<int> returned " << i2 << " instead of throwing";
     EXPECT_TRUE(false);
-  } catch (std::range_error& e) {
+  } catch (std::range_error&) {
     //LOG(INFO) << e.what();
   }
 }
@@ -684,7 +684,7 @@ TEST(Conv, EnumToInt) {
                << static_cast<unsigned int>(i2)
                << " instead of throwing";
     EXPECT_TRUE(false);
-  } catch (std::range_error& e) {
+  } catch (std::range_error&) {
     //LOG(INFO) << e.what();
   }
 }
@@ -709,7 +709,7 @@ TEST(Conv, IntToEnum) {
                << static_cast<unsigned int>(i2)
                << " instead of throwing";
     EXPECT_TRUE(false);
-  } catch (std::range_error& e) {
+  } catch (std::range_error&) {
     //LOG(INFO) << e.what();
   }
 }
@@ -726,7 +726,7 @@ TEST(Conv, UnsignedEnum) {
     auto i = to<int32_t>(x);
     LOG(ERROR) << "to<int32_t> returned " << i << " instead of throwing";
     EXPECT_TRUE(false);
-  } catch (std::range_error& e) {
+  } catch (std::range_error&) {
   }
 }
 
index c19d26253865bef022de71d45d3c384629c63415..57d632b4a43de8c43cf1325c224adc8e1991b3d5 100644 (file)
@@ -252,7 +252,7 @@ TEST(Dynamic, Operator) {
     LOG(ERROR) << "operator < returned "
                << static_cast<int>(foo)
                << " instead of throwing";
-  } catch (std::exception const& e) {
+  } catch (std::exception const&) {
     caught = true;
   }
   EXPECT_TRUE(caught);
index c16fe4a0feb28c5cb804a7546aeb45e961885906..8861fedf8341db79f83746e4066f1fc9c79684a5 100644 (file)
@@ -196,7 +196,7 @@ TEST(LifoSem, shutdown_race) {
           a.wait();
           ++waitCount;
         }
-      } catch (ShutdownSemError& x) {
+      } catch (ShutdownSemError&) {
         // expected
         EXPECT_TRUE(a.isShutdown());
       }
@@ -228,7 +228,7 @@ TEST(LifoSem, shutdown_multi) {
         try {
           a.wait();
           EXPECT_TRUE(false);
-        } catch (ShutdownSemError& x) {
+        } catch (ShutdownSemError&) {
           // expected
           EXPECT_TRUE(a.isShutdown());
         }
index 415c6c3df05051e28b051f5fb38102526db7bb3e..2341c4891a1949b37816b46f2ef6af40d342d2a4 100644 (file)
@@ -437,7 +437,7 @@ TEST(PrettyToDouble, Basic) {
         try{
           recoveredX = prettyToDouble(prettyPrint(x, formatType, addSpace),
                                              formatType);
-        } catch (std::range_error &ex){
+        } catch (std::range_error&) {
           EXPECT_TRUE(false);
         }
         double relativeError = (x - recoveredX) / x;
index 19fa9538b25bc8804c9e4484677620b6cab2efb6..9dcac8598df483ab78f449dfd47e973ee65686e2 100644 (file)
@@ -347,7 +347,7 @@ TEST(Uri, Simple) {
     try {
       Uri u(s);
       CHECK(false) << "Control should not have reached here";
-    } catch (const std::invalid_argument& ex) {
+    } catch (const std::invalid_argument&) {
       // success
     }
   }
@@ -358,7 +358,7 @@ TEST(Uri, Simple) {
     try {
       Uri u(s);
       CHECK(false) << "Control should not have reached here";
-    } catch (const std::invalid_argument& ex) {
+    } catch (const std::invalid_argument&) {
       // success
     }
   }
@@ -369,7 +369,7 @@ TEST(Uri, Simple) {
     try {
       Uri u(s);
       CHECK(false) << "Control should not have reached here";
-    } catch (const std::invalid_argument& ex) {
+    } catch (const std::invalid_argument&) {
       // success
     }
   }
@@ -380,7 +380,7 @@ TEST(Uri, Simple) {
     try {
       Uri u(s);
       CHECK(false) << "Control should not have reached here";
-    } catch (const std::invalid_argument& ex) {
+    } catch (const std::invalid_argument&) {
       // success
     }
   }