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/include/fru_reader.hpp b/include/fru_reader.hpp
index b1d21d8..f54d900 100644
--- a/include/fru_reader.hpp
+++ b/include/fru_reader.hpp
@@ -39,7 +39,7 @@
class FRUReader
{
public:
- FRUReader(ReadBlockFunc readFunc) : readFunc(std::move(readFunc))
+ explicit FRUReader(ReadBlockFunc readFunc) : readFunc(std::move(readFunc))
{}
// The ::read() operation here is analogous to ReadBlockFunc (with the same
// return value semantics), but is not subject to SMBus block size
diff --git a/include/fru_utils.hpp b/include/fru_utils.hpp
index ebb2b19..e50b580 100644
--- a/include/fru_utils.hpp
+++ b/include/fru_utils.hpp
@@ -17,6 +17,7 @@
#pragma once
#include "fru_reader.hpp"
+
#include <boost/container/flat_map.hpp>
#include <cstdint>
@@ -94,7 +95,7 @@
char sixBitToChar(uint8_t val);
/* 0xd - 0xf are reserved values, but not fatal; use a placeholder char. */
-const char bcdHighChars[] = {
+constexpr std::array<char, 6> bcdHighChars = {
' ', '-', '.', 'X', 'X', 'X',
};
diff --git a/include/utils.hpp b/include/utils.hpp
index bc8ac1b..99e2f85 100644
--- a/include/utils.hpp
+++ b/include/utils.hpp
@@ -132,22 +132,20 @@
}
std::optional<std::string> templateCharReplace(
- nlohmann::json::iterator& keyPair, const DBusObject& object,
- const size_t index,
+ nlohmann::json::iterator& keyPair, const DBusObject& object, size_t index,
const std::optional<std::string>& replaceStr = std::nullopt);
std::optional<std::string> templateCharReplace(
nlohmann::json::iterator& keyPair, const DBusInterface& interface,
- const size_t index,
- const std::optional<std::string>& replaceStr = std::nullopt);
+ size_t index, const std::optional<std::string>& replaceStr = std::nullopt);
inline bool deviceHasLogging(const nlohmann::json& json)
{
auto logging = json.find("Logging");
if (logging != json.end())
{
- auto ptr = logging->get_ptr<const std::string*>();
- if (ptr)
+ const auto* ptr = logging->get_ptr<const std::string*>();
+ if (ptr != nullptr)
{
if (*ptr == "Off")
{