Let lock_guard deduce its template argument
No functional change, this is a cleanup.
With C++17, it's no longer necessary to specify the teplate argument
when it can be deduced from the types of constructor arguments. This
allows de-cluttering our locking statements.
To avoid typos, this patch was mechanically generated:
perl -p -i -e 's/std::lock_guard<std::mutex>/std::lock_guard/g' \
$(find . -name '*.cpp' -o -name '*.h')
Change-Id: Ibb15d9a6c5b1c861d81353e47d25474eb1d4c2df
diff --git a/server/dns/DnsTlsSocket.cpp b/server/dns/DnsTlsSocket.cpp
index 8e25b1f..df48d91 100644
--- a/server/dns/DnsTlsSocket.cpp
+++ b/server/dns/DnsTlsSocket.cpp
@@ -132,7 +132,7 @@
bool DnsTlsSocket::initialize() {
// This method should only be called once, at the beginning, so locking should be
// unnecessary. This lock only serves to help catch bugs in code that calls this method.
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
if (mSslCtx) {
// This is a bug in the caller.
return false;
@@ -340,7 +340,7 @@
}
void DnsTlsSocket::loop() {
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
// Buffer at most one query.
Query q;
@@ -413,7 +413,7 @@
mIpcInFd.reset();
{
// Wait for the orderly shutdown to complete.
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
if (mLoopThread && std::this_thread::get_id() == mLoopThread->get_id()) {
ALOGE("Violation of re-entrance precondition");
return;