From 811bad8a07079b5f450c9c8557b88fd574cf5996 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Mon, 12 Dec 2016 11:39:32 -0800 Subject: [PATCH] Don't declare a variable for exceptions we discard Summary: They aren't needed and they count as initialized but unused variables. Reviewed By: yfeldblum Differential Revision: D4308844 fbshipit-source-id: a6833dbf434ebdefff0b375729a4e62495463ac0 --- folly/Format-inl.h | 2 +- folly/FormatArg.h | 2 +- folly/experimental/DynamicParser-inl.h | 4 ++-- folly/experimental/JSONSchema.cpp | 2 +- folly/experimental/ProgramOptions.cpp | 2 +- folly/io/async/AsyncSSLSocket.cpp | 2 +- folly/io/async/AsyncServerSocket.cpp | 4 ++-- folly/io/async/NotificationQueue.h | 2 +- folly/io/async/test/AsyncSSLSocketTest.cpp | 2 +- folly/test/AtomicUnorderedMapTest.cpp | 2 +- folly/test/ConvTest.cpp | 8 ++++---- folly/test/DynamicTest.cpp | 2 +- folly/test/LifoSemTests.cpp | 4 ++-- folly/test/StringTest.cpp | 2 +- folly/test/UriTest.cpp | 8 ++++---- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/folly/Format-inl.h b/folly/Format-inl.h index c27b7662..7b717363 100644 --- a/folly/Format-inl.h +++ b/folly/Format-inl.h @@ -256,7 +256,7 @@ void BaseFormatter::operator()(Output& out) try { argIndex = to(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"); diff --git a/folly/FormatArg.h b/folly/FormatArg.h index 701654b3..89c7e933 100644 --- a/folly/FormatArg.h +++ b/folly/FormatArg.h @@ -267,7 +267,7 @@ inline int FormatArg::splitIntKey() { } try { return to(doSplitKey()); - } catch (const std::out_of_range& e) { + } catch (const std::out_of_range&) { error("integer key required"); return 0; // unreached } diff --git a/folly/experimental/DynamicParser-inl.h b/folly/experimental/DynamicParser-inl.h index df390b74..66191328 100644 --- a/folly/experimental/DynamicParser-inl.h +++ b/folly/experimental/DynamicParser-inl.h @@ -263,11 +263,11 @@ template 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) { diff --git a/folly/experimental/JSONSchema.cpp b/folly/experimental/JSONSchema.cpp index a550cee9..e2db5c45 100644 --- a/folly/experimental/JSONSchema.cpp +++ b/folly/experimental/JSONSchema.cpp @@ -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 } } diff --git a/folly/experimental/ProgramOptions.cpp b/folly/experimental/ProgramOptions.cpp index 9e988514..bd8acada 100644 --- a/folly/experimental/ProgramOptions.cpp +++ b/folly/experimental/ProgramOptions.cpp @@ -119,7 +119,7 @@ void GFlagValueSemanticBase::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()); } diff --git a/folly/io/async/AsyncSSLSocket.cpp b/folly/io/async/AsyncSSLSocket.cpp index 8ce16445..aa34b1a0 100644 --- a/folly/io/async/AsyncSSLSocket.cpp +++ b/folly/io/async/AsyncSSLSocket.cpp @@ -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; diff --git a/folly/io/async/AsyncServerSocket.cpp b/folly/io/async/AsyncServerSocket.cpp index cb4c1a2d..cf0a1e99 100644 --- a/folly/io/async/AsyncServerSocket.cpp +++ b/folly/io/async/AsyncServerSocket.cpp @@ -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. diff --git a/folly/io/async/NotificationQueue.h b/folly/io/async/NotificationQueue.h index 88b1c7b9..c1c64617 100644 --- a/folly/io/async/NotificationQueue.h +++ b/folly/io/async/NotificationQueue.h @@ -753,7 +753,7 @@ void NotificationQueue::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. diff --git a/folly/io/async/test/AsyncSSLSocketTest.cpp b/folly/io/async/test/AsyncSSLSocketTest.cpp index f2bd909f..181a3345 100644 --- a/folly/io/async/test/AsyncSSLSocketTest.cpp +++ b/folly/io/async/test/AsyncSSLSocketTest.cpp @@ -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); diff --git a/folly/test/AtomicUnorderedMapTest.cpp b/folly/test/AtomicUnorderedMapTest.cpp index e1a0104c..7093e726 100644 --- a/folly/test/AtomicUnorderedMapTest.cpp +++ b/folly/test/AtomicUnorderedMapTest.cpp @@ -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"; } } diff --git a/folly/test/ConvTest.cpp b/folly/test/ConvTest.cpp index 2109d1a6..5109fbbc 100644 --- a/folly/test/ConvTest.cpp +++ b/folly/test/ConvTest.cpp @@ -667,7 +667,7 @@ TEST(Conv, DoubleToInt) { auto i2 = to(42.1); LOG(ERROR) << "to 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(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(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(x); LOG(ERROR) << "to returned " << i << " instead of throwing"; EXPECT_TRUE(false); - } catch (std::range_error& e) { + } catch (std::range_error&) { } } diff --git a/folly/test/DynamicTest.cpp b/folly/test/DynamicTest.cpp index c19d2625..57d632b4 100644 --- a/folly/test/DynamicTest.cpp +++ b/folly/test/DynamicTest.cpp @@ -252,7 +252,7 @@ TEST(Dynamic, Operator) { LOG(ERROR) << "operator < returned " << static_cast(foo) << " instead of throwing"; - } catch (std::exception const& e) { + } catch (std::exception const&) { caught = true; } EXPECT_TRUE(caught); diff --git a/folly/test/LifoSemTests.cpp b/folly/test/LifoSemTests.cpp index c16fe4a0..8861fedf 100644 --- a/folly/test/LifoSemTests.cpp +++ b/folly/test/LifoSemTests.cpp @@ -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()); } diff --git a/folly/test/StringTest.cpp b/folly/test/StringTest.cpp index 415c6c3d..2341c489 100644 --- a/folly/test/StringTest.cpp +++ b/folly/test/StringTest.cpp @@ -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; diff --git a/folly/test/UriTest.cpp b/folly/test/UriTest.cpp index 19fa9538..9dcac859 100644 --- a/folly/test/UriTest.cpp +++ b/folly/test/UriTest.cpp @@ -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 } } -- 2.34.1