Make clang-tidy changes
clang-tidy has a number of checks it recommends. These checks are
documented in the next commit, but make the code pass our coding
standard.
Tested:
Minor changes made by the robot.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I6cfaab92211af9c4c1eccd981ba9fe7b8c523457
diff --git a/src/perform_scan.cpp b/src/perform_scan.cpp
index bf3c750..559b822 100644
--- a/src/perform_scan.cpp
+++ b/src/perform_scan.cpp
@@ -50,7 +50,7 @@
const std::vector<std::shared_ptr<PerformProbe>>& probeVector,
const std::shared_ptr<PerformScan>& scan, size_t retries = 5)
{
- if (!retries)
+ if (retries == 0U)
{
std::cerr << "retries exhausted on " << instance.busName << " "
<< instance.path << " " << instance.interface << "\n";
@@ -83,7 +83,7 @@
if constexpr (debug)
{
- std::cerr << __func__ << " " << __LINE__ << "\n";
+ std::cerr << __LINE__ << "\n";
}
}
@@ -172,7 +172,7 @@
}
std::cerr << "Error communicating to mapper.\n";
- if (!retries)
+ if (retries == 0U)
{
// if we can't communicate to the mapper something is very
// wrong
@@ -202,7 +202,7 @@
if constexpr (debug)
{
- std::cerr << __func__ << " " << __LINE__ << "\n";
+ std::cerr << __LINE__ << "\n";
}
}
@@ -216,7 +216,7 @@
// use an array so alphabetical order from the flat_map is maintained
auto device = nlohmann::json::array();
- for (auto& devPair : probe)
+ for (const auto& devPair : probe)
{
device.push_back(devPair.first);
std::visit([&device](auto&& v) { device.push_back(v); },
@@ -283,7 +283,9 @@
int index = 0;
auto str = nameIt->get<std::string>().substr(indexIdx);
- auto [p, ec] = std::from_chars(str.data(), str.data() + str.size(), index);
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
+ const char* endPtr = str.data() + str.size();
+ auto [p, ec] = std::from_chars(str.data(), endPtr, index);
if (ec != std::errc())
{
return; // non-numeric replacement
@@ -638,7 +640,7 @@
std::cerr << "Probe statement wasn't a string, can't parse";
continue;
}
- if (findProbeType(probe->c_str()))
+ if (findProbeType(*probe))
{
continue;
}
@@ -657,7 +659,7 @@
std::move(dbusProbeInterfaces), shared_from_this());
if constexpr (debug)
{
- std::cerr << __func__ << " " << __LINE__ << "\n";
+ std::cerr << __LINE__ << "\n";
}
}
@@ -674,7 +676,7 @@
if constexpr (debug)
{
- std::cerr << __func__ << " " << __LINE__ << "\n";
+ std::cerr << __LINE__ << "\n";
}
}
else
@@ -683,7 +685,7 @@
if constexpr (debug)
{
- std::cerr << __func__ << " " << __LINE__ << "\n";
+ std::cerr << __LINE__ << "\n";
}
}
}