Commit 811bad8a authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

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
parent b4a27a03
......@@ -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");
......
......@@ -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
}
......
......@@ -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) {
......
......@@ -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
}
}
......
......@@ -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());
}
......
......@@ -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;
......
......@@ -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.
......
......@@ -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.
......
......@@ -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);
......
......@@ -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";
}
}
......
......@@ -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&) {
}
}
......
......@@ -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);
......
......@@ -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());
}
......
......@@ -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;
......
......@@ -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
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment