clang-tidy: Enable readability-redundant-smartptr-get check
This check finds and removes redundant calls to smart pointer’s
.get() method.
Change-Id: I0cc34b41fb118a93673e36cd684b67e147ab914a
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index 51ee20b..24f78f0 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -246,6 +246,7 @@
readability-redundant-function-ptr-dereference,
readability-redundant-member-init,
readability-redundant-preprocessor,
+readability-redundant-smartptr-get,
readability-simplify-subscript-expr,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
diff --git a/item_updater.cpp b/item_updater.cpp
index fd51adb..2215b71 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -517,7 +517,7 @@
if (intf.second->redundancyPriority)
{
priorityMap.insert(std::make_pair(
- intf.first, intf.second->redundancyPriority.get()->priority()));
+ intf.first, intf.second->redundancyPriority->priority()));
}
}
@@ -546,8 +546,7 @@
{
++freePriorityValue;
auto it = activations.find(element.first);
- it->second->redundancyPriority.get()->sdbusPriority(
- freePriorityValue);
+ it->second->redundancyPriority->sdbusPriority(freePriorityValue);
}
}
@@ -703,7 +702,7 @@
{
if (intf.second->redundancyPriority)
{
- if (intf.second->redundancyPriority.get()->priority() < value)
+ if (intf.second->redundancyPriority->priority() < value)
{
return false;
}
@@ -725,20 +724,20 @@
void ItemUpdater::resetUbootEnvVars()
{
- decltype(activations.begin()->second->redundancyPriority.get()->priority())
+ decltype(activations.begin()->second->redundancyPriority->priority())
lowestPriority = std::numeric_limits<uint8_t>::max();
decltype(activations.begin()->second->versionId) lowestPriorityVersion;
for (const auto& intf : activations)
{
- if (!intf.second->redundancyPriority.get())
+ if (!intf.second->redundancyPriority)
{
// Skip this version if the redundancyPriority is not initialized.
continue;
}
- if (intf.second->redundancyPriority.get()->priority() <= lowestPriority)
+ if (intf.second->redundancyPriority->priority() <= lowestPriority)
{
- lowestPriority = intf.second->redundancyPriority.get()->priority();
+ lowestPriority = intf.second->redundancyPriority->priority();
lowestPriorityVersion = intf.second->versionId;
}
}
@@ -755,7 +754,7 @@
for (const auto& iter : activations)
{
if (iter.second->redundancyPriority &&
- iter.second->redundancyPriority.get()->priority() == 0)
+ iter.second->redundancyPriority->priority() == 0)
{
versionIDtoErase = iter.second->versionId;
break;