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/RouteController.cpp b/server/RouteController.cpp
index 16947af..6774fd5 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -155,7 +155,7 @@
}
uint32_t RouteController::getIfIndex(const char* interface) {
- std::lock_guard<std::mutex> lock(sInterfaceToTableLock);
+ std::lock_guard lock(sInterfaceToTableLock);
auto iter = sInterfaceToTable.find(interface);
if (iter == sInterfaceToTable.end()) {
@@ -167,7 +167,7 @@
}
uint32_t RouteController::getRouteTableForInterface(const char* interface) {
- std::lock_guard<std::mutex> lock(sInterfaceToTableLock);
+ std::lock_guard lock(sInterfaceToTableLock);
return getRouteTableForInterfaceLocked(interface);
}
@@ -191,7 +191,7 @@
addTableName(ROUTE_TABLE_LEGACY_NETWORK, ROUTE_TABLE_NAME_LEGACY_NETWORK, &contents);
addTableName(ROUTE_TABLE_LEGACY_SYSTEM, ROUTE_TABLE_NAME_LEGACY_SYSTEM, &contents);
- std::lock_guard<std::mutex> lock(sInterfaceToTableLock);
+ std::lock_guard lock(sInterfaceToTableLock);
for (const auto& entry : sInterfaceToTable) {
addTableName(entry.second, entry.first, &contents);
}
@@ -927,7 +927,7 @@
// Returns 0 on success or negative errno on failure.
WARN_UNUSED_RESULT int RouteController::flushRoutes(const char* interface) {
- std::lock_guard<std::mutex> lock(sInterfaceToTableLock);
+ std::lock_guard lock(sInterfaceToTableLock);
uint32_t table = getRouteTableForInterfaceLocked(interface);
if (table == RT_TABLE_UNSPEC) {