From dd753e6fa6bbc8b8f452db050f3b9d87a7120582 Mon Sep 17 00:00:00 2001 From: Ian Bastos Date: Fri, 25 Jan 2019 14:25:54 +0000 Subject: [PATCH 1/4] removed error prone unsigned integer max comparison removed error prone unsigned integer max comparison between 0 and the right value since that value will always be higher or equal --- src/mongo/db/geo/r2_region_coverer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mongo/db/geo/r2_region_coverer.cpp b/src/mongo/db/geo/r2_region_coverer.cpp index 47ba252832879..4a05ab16f1537 100644 --- a/src/mongo/db/geo/r2_region_coverer.cpp +++ b/src/mongo/db/geo/r2_region_coverer.cpp @@ -70,13 +70,13 @@ R2RegionCoverer::~R2RegionCoverer() {} void R2RegionCoverer::setMinLevel(unsigned int minLevel) { dassert(minLevel >= 0); dassert(minLevel <= GeoHash::kMaxBits); - _minLevel = max(0u, min(GeoHash::kMaxBits, minLevel)); + _minLevel = min(GeoHash::kMaxBits, minLevel); } void R2RegionCoverer::setMaxLevel(unsigned int maxLevel) { dassert(maxLevel >= 0); dassert(maxLevel <= GeoHash::kMaxBits); - _maxLevel = max(0u, min(GeoHash::kMaxBits, maxLevel)); + _maxLevel = min(GeoHash::kMaxBits, maxLevel); } void R2RegionCoverer::setMaxCells(int maxCells) { From 3b2833507541877d5ac753d38da9b0a15044cf60 Mon Sep 17 00:00:00 2001 From: Ian Bastos Date: Fri, 25 Jan 2019 14:46:01 +0000 Subject: [PATCH 2/4] removed unused lambda captures which causes compilation errors --- src/mongo/executor/network_interface_asio.cpp | 2 +- src/mongo/executor/network_interface_asio_command.cpp | 6 +++--- src/mongo/executor/thread_pool_task_executor.cpp | 2 +- src/mongo/util/net/hostname_canonicalization.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mongo/executor/network_interface_asio.cpp b/src/mongo/executor/network_interface_asio.cpp index 6b3ad4fc687f7..4f7ee747ed464 100644 --- a/src/mongo/executor/network_interface_asio.cpp +++ b/src/mongo/executor/network_interface_asio.cpp @@ -394,7 +394,7 @@ Status NetworkInterfaceASIO::startCommand(const TaskExecutor::CallbackHandle& cb } op->_timeoutAlarm->asyncWait( - [this, op, access, generation, requestId, adjustedTimeout](std::error_code ec) { + [op, access, generation, requestId, adjustedTimeout](std::error_code ec) { // We must pass a check for safe access before using op inside the // callback or we may attempt access on an invalid pointer. stdx::lock_guard lk(access->mutex); diff --git a/src/mongo/executor/network_interface_asio_command.cpp b/src/mongo/executor/network_interface_asio_command.cpp index c72a7b7450518..e3855299589c4 100644 --- a/src/mongo/executor/network_interface_asio_command.cpp +++ b/src/mongo/executor/network_interface_asio_command.cpp @@ -386,7 +386,7 @@ void NetworkInterfaceASIO::_asyncRunCommand(AsyncOp* op, NetworkOpHandler handle auto cmd = op->command(); // Step 4 - auto recvMessageCallback = [this, cmd, handler, op](std::error_code ec, size_t bytes) { + auto recvMessageCallback = [handler](std::error_code ec, size_t bytes) { // We don't call _validateAndRun here as we assume the caller will. handler(ec, bytes); }; @@ -396,7 +396,7 @@ void NetworkInterfaceASIO::_asyncRunCommand(AsyncOp* op, NetworkOpHandler handle size_t bytes) { // The operation could have been canceled after starting the command, but before // receiving the header - _validateAndRun(op, ec, [this, op, recvMessageCallback, ec, bytes, cmd, handler] { + _validateAndRun(op, ec, [recvMessageCallback, bytes, cmd, handler] { // validate response id uint32_t expectedId = cmd->toSend().header().getId(); uint32_t actualId = cmd->header().constView().getResponseToMsgId(); @@ -417,7 +417,7 @@ void NetworkInterfaceASIO::_asyncRunCommand(AsyncOp* op, NetworkOpHandler handle // Step 2 auto sendMessageCallback = [this, cmd, handler, recvHeaderCallback, op](std::error_code ec, size_t bytes) { - _validateAndRun(op, ec, [this, cmd, op, recvHeaderCallback] { + _validateAndRun(op, ec, [cmd, recvHeaderCallback] { asyncRecvMessageHeader( cmd->conn().stream(), &cmd->header(), std::move(recvHeaderCallback)); }); diff --git a/src/mongo/executor/thread_pool_task_executor.cpp b/src/mongo/executor/thread_pool_task_executor.cpp index f1f990df41b20..be2e12490eef3 100644 --- a/src/mongo/executor/thread_pool_task_executor.cpp +++ b/src/mongo/executor/thread_pool_task_executor.cpp @@ -287,7 +287,7 @@ StatusWith ThreadPoolTaskExecutor::scheduleWorkAt( return cbHandle; } lk.unlock(); - _net->setAlarm(when, [this, when, cbHandle] { + _net->setAlarm(when, [this, cbHandle] { auto cbState = checked_cast(getCallbackFromHandle(cbHandle.getValue())); if (cbState->canceled.load()) { return; diff --git a/src/mongo/util/net/hostname_canonicalization.cpp b/src/mongo/util/net/hostname_canonicalization.cpp index 5dfc69d6ba459..bc2d430078d9f 100644 --- a/src/mongo/util/net/hostname_canonicalization.cpp +++ b/src/mongo/util/net/hostname_canonicalization.cpp @@ -92,7 +92,7 @@ std::vector getHostFQDNs(std::string hostName, HostnameCanonicaliza << getAddrInfoStrError(err); return results; } - const auto guard = MakeGuard([&shim_freeaddrinfo, &info] { shim_freeaddrinfo(info); }); + const auto guard = MakeGuard([&info] { shim_freeaddrinfo(info); }); if (mode == HostnameCanonicalizationMode::kForward) { results.emplace_back(shim_fromNativeString(info->ai_canonname)); From e414c60e2376e71371e0fae2d2b5e3e475df1a10 Mon Sep 17 00:00:00 2001 From: Ian Bastos Date: Fri, 25 Jan 2019 14:57:17 +0000 Subject: [PATCH 3/4] compiler throws error with noexcept modifier coupled with throw clause --- src/mongo/util/assert_util.cpp | 2 +- src/mongo/util/assert_util.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mongo/util/assert_util.cpp b/src/mongo/util/assert_util.cpp index 9d40b1f5d629f..2c444c261b9ad 100644 --- a/src/mongo/util/assert_util.cpp +++ b/src/mongo/util/assert_util.cpp @@ -308,7 +308,7 @@ string demangleName(const type_info& typeinfo) { #endif } -Status exceptionToStatus() noexcept { +Status exceptionToStatus() { try { throw; } catch (const DBException& ex) { diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index ab7dfab85a05d..484bda8fb9fe4 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -464,7 +464,7 @@ std::string demangleName(const std::type_info& typeinfo); * } * } */ -Status exceptionToStatus() noexcept; +Status exceptionToStatus(); } // namespace mongo From f2551939ee999686f66c180d42294f6560458640 Mon Sep 17 00:00:00 2001 From: Ian Bastos Date: Fri, 25 Jan 2019 14:59:06 +0000 Subject: [PATCH 4/4] template already defined, no need for redefining explicit specialization --- src/third_party/s2/util/math/mathutil.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/third_party/s2/util/math/mathutil.cc b/src/third_party/s2/util/math/mathutil.cc index 7ca3b890f8a80..f85306701f5e4 100755 --- a/src/third_party/s2/util/math/mathutil.cc +++ b/src/third_party/s2/util/math/mathutil.cc @@ -27,7 +27,7 @@ using std::vector; return static_cast(x < 0 ? (x - 0.5) : (x + 0.5)); } -template int MathUtil::Round(double x); +//template int MathUtil::Round(double x); MathUtil::QuadraticRootType MathUtil::RealRootsForQuadratic(long double a, long double b,