Implement clang-tidy fixes

clang-tidy allows the CI robot to check many things via static analysis.

All changes here were made by the clang-tidy robot, and include a number
of modernization fixes.  updating the tidy file will be done at a later
date.

Signed-off-by: Ed Tanous <etanous@nvidia.com>
Change-Id: I98cc4d600a3c589675507958f6d2350b2141216b
diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp
index 7e34b55..8b18b4f 100644
--- a/dbus/dbusconfiguration.cpp
+++ b/dbus/dbusconfiguration.cpp
@@ -73,7 +73,7 @@
 
 inline std::string getSensorNameFromPath(const std::string& dbusPath)
 {
-    return dbusPath.substr(dbusPath.find_last_of("/") + 1);
+    return dbusPath.substr(dbusPath.find_last_of('/') + 1);
 }
 
 inline std::string sensorNameToDbusName(const std::string& sensorName)
diff --git a/dbus/dbushelper.hpp b/dbus/dbushelper.hpp
index 780f708..357d80e 100644
--- a/dbus/dbushelper.hpp
+++ b/dbus/dbushelper.hpp
@@ -25,7 +25,7 @@
 
     explicit DbusHelper(sdbusplus::bus_t& bus) : _bus(bus) {}
     DbusHelper() = delete;
-    ~DbusHelper() = default;
+    ~DbusHelper() override = default;
 
     DbusHelper(const DbusHelper&) = delete;
     DbusHelper& operator=(const DbusHelper&) = delete;
diff --git a/dbus/dbusutil.cpp b/dbus/dbusutil.cpp
index 18d8f36..2a0c923 100644
--- a/dbus/dbusutil.cpp
+++ b/dbus/dbusutil.cpp
@@ -84,7 +84,7 @@
     {
         if (std::regex_search(sensor.first, match, reg))
         {
-            matches.push_back(sensor);
+            matches.emplace_back(sensor);
         }
     }
     return matches.size() > 0;
diff --git a/errors/exception.hpp b/errors/exception.hpp
index 889b98a..ddc3804 100644
--- a/errors/exception.hpp
+++ b/errors/exception.hpp
@@ -9,7 +9,7 @@
     explicit SensorBuildException(const std::string& message) : message(message)
     {}
 
-    virtual const char* what() const noexcept override
+    const char* what() const noexcept override
     {
         return message.c_str();
     }
@@ -25,7 +25,7 @@
         message(message)
     {}
 
-    virtual const char* what() const noexcept override
+    const char* what() const noexcept override
     {
         return message.c_str();
     }
@@ -41,7 +41,7 @@
         message(message)
     {}
 
-    virtual const char* what() const noexcept override
+    const char* what() const noexcept override
     {
         return message.c_str();
     }
diff --git a/experiments/drive.cpp b/experiments/drive.cpp
index 15ce05a..9d3e6dc 100644
--- a/experiments/drive.cpp
+++ b/experiments/drive.cpp
@@ -35,8 +35,8 @@
 #define DRIVE DRIVE_TIME
 #define MAX_PWM 255
 
-static std::unique_ptr<Sensor> Create(std::string readpath,
-                                      std::string writepath)
+static std::unique_ptr<Sensor> Create(const std::string& readpath,
+                                      const std::string& writepath)
 {
     return std::make_unique<PluggableSensor>(
         readpath, 0, /* default the timeout to disabled */
@@ -91,7 +91,7 @@
 
         tstamp t1 = std::chrono::high_resolution_clock::now();
 
-        series.push_back(std::make_tuple(t1, n0, n1));
+        series.emplace_back(t1, n0, n1);
         seriesCnt += 1;
 
         int64_t avgn = (n0 + n1) / 2;
@@ -156,7 +156,7 @@
         int64_t n1 = static_cast<int64_t>(r1.value);
         tstamp t1 = std::chrono::high_resolution_clock::now();
 
-        series.push_back(std::make_tuple(t1, n0, n1));
+        series.emplace_back(t1, n0, n1);
 
         auto duration =
             std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0)
@@ -222,7 +222,7 @@
      * improvement is less.
      */
 
-    series.push_back(std::make_tuple(t1, fan0_start, fan1_start));
+    series.emplace_back(t1, fan0_start, fan1_start);
     seriesCnt += 1;
 
     int64_t average = (fan0_start + fan1_start) / 2;
diff --git a/failsafeloggers/failsafe_logger.cpp b/failsafeloggers/failsafe_logger.cpp
index 91416e0..f1fcb14 100644
--- a/failsafeloggers/failsafe_logger.cpp
+++ b/failsafeloggers/failsafe_logger.cpp
@@ -8,7 +8,7 @@
 
 void FailsafeLogger::outputFailsafeLog(
     const int64_t zoneId, const bool newFailsafeState,
-    const std::string location, const std::string reason)
+    const std::string& location, const std::string& reason)
 {
     // Remove outdated log entries.
     const auto now = std::chrono::high_resolution_clock::now();
diff --git a/failsafeloggers/failsafe_logger.hpp b/failsafeloggers/failsafe_logger.hpp
index 0e13919..b53e9f2 100644
--- a/failsafeloggers/failsafe_logger.hpp
+++ b/failsafeloggers/failsafe_logger.hpp
@@ -39,8 +39,8 @@
     /** Attempt to output an entering/leaving-failsafe-mode log.
      */
     void outputFailsafeLog(int64_t zoneId, bool newFailsafeState,
-                           const std::string location,
-                           const std::string reason);
+                           const std::string& location,
+                           const std::string& reason);
 
   private:
     // The maximum number of log entries to be output within 1 second.
diff --git a/failsafeloggers/failsafe_logger_utility.hpp b/failsafeloggers/failsafe_logger_utility.hpp
index 05ed3ea..465fcdb 100644
--- a/failsafeloggers/failsafe_logger_utility.hpp
+++ b/failsafeloggers/failsafe_logger_utility.hpp
@@ -24,8 +24,8 @@
  * logs for its corresponding zones.
  */
 inline void outputFailsafeLogWithSensor(
-    const std::string sensorName, const bool newFailsafeState,
-    const std::string location, const std::string reason)
+    const std::string& sensorName, const bool newFailsafeState,
+    const std::string& location, const std::string& reason)
 {
     for (const int64_t zoneId : sensorNameToZoneId[sensorName])
     {
@@ -42,7 +42,7 @@
  */
 inline void outputFailsafeLogWithZone(
     const int64_t zoneId, const bool newFailsafeState,
-    const std::string location, const std::string reason)
+    const std::string& location, const std::string& reason)
 {
     if (zoneIdToFailsafeLogger.count(zoneId))
     {
diff --git a/interfaces.hpp b/interfaces.hpp
index 013822c..d9934db 100644
--- a/interfaces.hpp
+++ b/interfaces.hpp
@@ -34,9 +34,9 @@
 class ReadInterface
 {
   public:
-    ReadInterface() {}
+    ReadInterface() = default;
 
-    virtual ~ReadInterface() {}
+    virtual ~ReadInterface() = default;
 
     virtual ReadReturn read(void) = 0;
 
@@ -60,7 +60,7 @@
   public:
     WriteInterface(int64_t min, int64_t max) : _min(min), _max(max) {}
 
-    virtual ~WriteInterface() {}
+    virtual ~WriteInterface() = default;
 
     virtual void write(double value) = 0;
 
diff --git a/ipmi/dbus_mode.hpp b/ipmi/dbus_mode.hpp
index b063ac4..c073162 100644
--- a/ipmi/dbus_mode.hpp
+++ b/ipmi/dbus_mode.hpp
@@ -14,7 +14,7 @@
 {
   public:
     DbusZoneControl() = default;
-    ~DbusZoneControl() = default;
+    ~DbusZoneControl() override = default;
 
     /*
      * busctl call xyz.openbmc_project.State.FanCtrl \
diff --git a/ipmi/main_ipmi.cpp b/ipmi/main_ipmi.cpp
index d1eed13..2dd6a75 100644
--- a/ipmi/main_ipmi.cpp
+++ b/ipmi/main_ipmi.cpp
@@ -47,9 +47,8 @@
         "Registering OEM:[%#08X], Cmd:[%#04X] for Manual Zone Control\n",
         oem::obmcOemNumber, oem::Cmd::fanManualCmd);
 
-    using namespace std::placeholders;
     router->registerHandler(
         oem::obmcOemNumber, oem::Cmd::fanManualCmd,
-        std::bind(pid_control::ipmi::manualModeControl,
-                  &pid_control::ipmi::handler, _1, _2, _3, _4));
+        std::bind_front(pid_control::ipmi::manualModeControl,
+                        &pid_control::ipmi::handler));
 }
diff --git a/main.cpp b/main.cpp
index 4539d83..823181a 100644
--- a/main.cpp
+++ b/main.cpp
@@ -93,9 +93,9 @@
 {
     static constexpr auto name = "config.json";
 
-    for (auto pathSeg : {std::filesystem::current_path(),
-                         std::filesystem::path{"/var/lib/swampd"},
-                         std::filesystem::path{"/usr/share/swampd"}})
+    for (const auto& pathSeg : {std::filesystem::current_path(),
+                                std::filesystem::path{"/var/lib/swampd"},
+                                std::filesystem::path{"/usr/share/swampd"}})
     {
         auto file = pathSeg / name;
         if (std::filesystem::exists(file))
@@ -213,8 +213,9 @@
     // first time of trying to restart the control loop without a delay
     if (first)
     {
-        boost::asio::post(io,
-                          std::bind(restartLbd, boost::system::error_code()));
+        boost::asio::post(io, [restartLbd] {
+            restartLbd(boost::system::error_code());
+        });
     }
     // re-try control loop, set up a delay.
     else
@@ -255,7 +256,8 @@
     // first time of trying to stop the control loop without a delay
     if (first)
     {
-        boost::asio::post(io, std::bind(stopLbd, boost::system::error_code()));
+        boost::asio::post(io,
+                          [stopLbd] { stopLbd(boost::system::error_code()); });
     }
     // re-try control loop, set up a delay.
     else
@@ -399,8 +401,8 @@
 
     static constexpr auto modeRoot = "/xyz/openbmc_project/settings/fanctrl";
     // Create a manager for the ModeBus because we own it.
-    sdbusplus::server::manager_t(static_cast<sdbusplus::bus_t&>(modeControlBus),
-                                 modeRoot);
+    sdbusplus::server::manager_t manager(
+        static_cast<sdbusplus::bus_t&>(modeControlBus), modeRoot);
     hostBus.request_name("xyz.openbmc_project.Hwmon.external");
     modeControlBus.request_name("xyz.openbmc_project.State.FanCtrl");
     sdbusplus::server::manager_t objManager(modeControlBus, modeRoot);
diff --git a/pid/builder.cpp b/pid/builder.cpp
index 1164355..afb6989 100644
--- a/pid/builder.cpp
+++ b/pid/builder.cpp
@@ -45,7 +45,7 @@
     return std::string(objectPath) + std::to_string(zone);
 }
 
-static std::string getPidControlPath(int64_t zone, std::string pidname)
+static std::string getPidControlPath(int64_t zone, const std::string& pidname)
 {
     return std::string(objectPath) + std::to_string(zone) + "/" + pidname;
 }
diff --git a/pid/ec/logging.hpp b/pid/ec/logging.hpp
index 3cef589..049d2ed 100644
--- a/pid/ec/logging.hpp
+++ b/pid/ec/logging.hpp
@@ -53,24 +53,24 @@
     std::ofstream fileCoeffs;
     std::chrono::milliseconds lastLog;
     PidCoreContext lastContext;
-    bool moved;
+    bool moved = false;
 
     PidCoreLog() :
         nameOriginal(), nameClean(), fileContext(), fileCoeffs(), lastLog(),
-        lastContext(), moved(false)
+        lastContext()
     {}
 
     PidCoreLog(const PidCoreLog& copy) = delete;
 
     PidCoreLog& operator=(const PidCoreLog& copy) = delete;
 
-    PidCoreLog(PidCoreLog&& move)
+    PidCoreLog(PidCoreLog&& move) noexcept
     {
         // Reuse assignment operator below
         *this = std::move(move);
     }
 
-    PidCoreLog& operator=(PidCoreLog&& move)
+    PidCoreLog& operator=(PidCoreLog&& move) noexcept
     {
         if (this != &move)
         {
@@ -79,8 +79,8 @@
             nameClean = std::move(move.nameClean);
             fileContext = std::move(move.fileContext);
             fileCoeffs = std::move(move.fileCoeffs);
-            lastLog = std::move(move.lastLog);
-            lastContext = std::move(move.lastContext);
+            lastLog = move.lastLog;
+            lastContext = move.lastContext;
 
             // Mark the moved object, so destructor knows it was moved
             move.moved = true;
diff --git a/pid/ec/pid.cpp b/pid/ec/pid.cpp
index 762513a..ad547d9 100644
--- a/pid/ec/pid.cpp
+++ b/pid/ec/pid.cpp
@@ -34,7 +34,7 @@
     {
         return min;
     }
-    else if (x > max)
+    if (x > max)
     {
         return max;
     }
diff --git a/pid/ec/pid.hpp b/pid/ec/pid.hpp
index ac77f05..02138cd 100644
--- a/pid/ec/pid.hpp
+++ b/pid/ec/pid.hpp
@@ -8,16 +8,16 @@
 namespace ec
 {
 
-typedef struct limits_t
+struct limits_t
 {
     double min = 0.0;
     double max = 0.0;
-} limits_t;
+};
 
 /* Note: If you update these structs you need to update the copy code in
  * pid/util.cpp and the initialization code in pid/buildjson.hpp files.
  */
-typedef struct pid_info_t
+struct pid_info_t
 {
     bool initialized = false;          // has pid been initialized
     bool checkHysterWithSetpt = false; // compare current input and setpoint to
@@ -40,7 +40,7 @@
     double slewPos = 0.0;
     double positiveHysteresis = 0.0;
     double negativeHysteresis = 0.0;
-} pid_info_t;
+};
 
 double pid(pid_info_t* pidinfoptr, double input, double setpoint,
            const std::string* nameptr = nullptr);
diff --git a/pid/fancontroller.hpp b/pid/fancontroller.hpp
index 700f651..cfcaf99 100644
--- a/pid/fancontroller.hpp
+++ b/pid/fancontroller.hpp
@@ -25,10 +25,10 @@
 
     FanController(const std::string& id, const std::vector<std::string>& inputs,
                   ZoneInterface* owner) :
-        PIDController(id, owner), _inputs(inputs),
-        _direction(FanSpeedDirection::NEUTRAL)
+        PIDController(id, owner), _inputs(inputs)
     {}
-    ~FanController();
+
+    ~FanController() override;
     double inputProc(void) override;
     double setptProc(void) override;
     void outputProc(double value) override;
@@ -45,7 +45,7 @@
 
   private:
     std::vector<std::string> _inputs;
-    FanSpeedDirection _direction;
+    FanSpeedDirection _direction = FanSpeedDirection::NEUTRAL;
 
     // Cosmetic only, to reduce frequency of repetitive messages
     bool failsafeTransition = true;
diff --git a/pid/pidcontroller.hpp b/pid/pidcontroller.hpp
index 91147d9..e1868f4 100644
--- a/pid/pidcontroller.hpp
+++ b/pid/pidcontroller.hpp
@@ -43,11 +43,11 @@
         _pid_info.positiveHysteresis = static_cast<double>(0.0);
     }
 
-    virtual ~PIDController() {}
+    ~PIDController() override = default;
 
-    virtual double inputProc(void) override = 0;
+    double inputProc(void) override = 0;
     virtual double setptProc(void) = 0;
-    virtual void outputProc(double value) override = 0;
+    void outputProc(double value) override = 0;
 
     void process(void) override;
 
diff --git a/pid/pidloop.cpp b/pid/pidloop.cpp
index 888419b..9d30798 100644
--- a/pid/pidloop.cpp
+++ b/pid/pidloop.cpp
@@ -32,7 +32,7 @@
 namespace pid_control
 {
 
-static void processThermals(std::shared_ptr<ZoneInterface> zone)
+static void processThermals(const std::shared_ptr<ZoneInterface>& zone)
 {
     // Get the latest margins.
     zone->updateSensors();
@@ -45,12 +45,14 @@
     zone->determineMaxSetPointRequest();
 }
 
-void pidControlLoop(std::shared_ptr<ZoneInterface> zone,
-                    std::shared_ptr<boost::asio::steady_timer> timer,
+void pidControlLoop(const std::shared_ptr<ZoneInterface>& zone,
+                    const std::shared_ptr<boost::asio::steady_timer>& timer,
                     const bool* isCanceling, bool first, uint64_t cycleCnt)
 {
     if (*isCanceling)
+    {
         return;
+    }
 
     std::chrono::steady_clock::time_point nextTime;
 
diff --git a/pid/pidloop.hpp b/pid/pidloop.hpp
index 0a143e7..70e0415 100644
--- a/pid/pidloop.hpp
+++ b/pid/pidloop.hpp
@@ -19,8 +19,8 @@
  * @param[in] first - boolean to denote if initialization needs to be run.
  * @param[in] cycleCnt - loop timer counter.
  */
-void pidControlLoop(std::shared_ptr<ZoneInterface> zone,
-                    std::shared_ptr<boost::asio::steady_timer> timer,
+void pidControlLoop(const std::shared_ptr<ZoneInterface>& zone,
+                    const std::shared_ptr<boost::asio::steady_timer>& timer,
                     const bool* isCanceling, bool first = true,
                     uint64_t cycleCnt = 0);
 
diff --git a/pid/zone.cpp b/pid/zone.cpp
index f8272bf..dfa5123 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -149,14 +149,14 @@
          * If the name of controller is Linear_Temp_CPU0.
          * The profile name will be Temp_CPU0.
          */
-        profileName = name.substr(name.find("_") + 1);
-        _SetPoints[profileName] += setPoint;
+        profileName = name.substr(name.find('_') + 1);
+        setPoints[profileName] += setPoint;
     }
     else
     {
-        if (_SetPoints[profileName] < setPoint)
+        if (setPoints[profileName] < setPoint)
         {
-            _SetPoints[profileName] = setPoint;
+            setPoints[profileName] = setPoint;
         }
     }
 
@@ -164,26 +164,26 @@
      * if there are multiple thermal controllers with the same
      * value, pick the first one in the iterator
      */
-    if (_maximumSetPoint < _SetPoints[profileName])
+    if (_maximumSetPoint < setPoints[profileName])
     {
-        _maximumSetPoint = _SetPoints[profileName];
+        _maximumSetPoint = setPoints[profileName];
         _maximumSetPointName = profileName;
     }
 }
 
 void DbusPidZone::addRPMCeiling(double ceiling)
 {
-    _RPMCeilings.push_back(ceiling);
+    rpmCeilings.push_back(ceiling);
 }
 
 void DbusPidZone::clearRPMCeilings(void)
 {
-    _RPMCeilings.clear();
+    rpmCeilings.clear();
 }
 
 void DbusPidZone::clearSetPoints(void)
 {
-    _SetPoints.clear();
+    setPoints.clear();
     _maximumSetPoint = 0;
     _maximumSetPointName.clear();
 }
@@ -197,8 +197,8 @@
 
     FailSafeSensorsMap::iterator maxData = std::max_element(
         _failSafeSensors.begin(), _failSafeSensors.end(),
-        [](const FailSafeSensorPair firstData,
-           const FailSafeSensorPair secondData) {
+        [](const FailSafeSensorPair& firstData,
+           const FailSafeSensorPair& secondData) {
             return firstData.second.second < secondData.second.second;
         });
 
@@ -210,10 +210,8 @@
     {
         return _zoneFailSafePercent;
     }
-    else
-    {
-        return (*maxData).second.second;
-    }
+
+    return (*maxData).second.second;
 }
 
 double DbusPidZone::getMinThermalSetPoint(void) const
@@ -344,9 +342,9 @@
     std::vector<double>::iterator result;
     double minThermalThreshold = getMinThermalSetPoint();
 
-    if (_RPMCeilings.size() > 0)
+    if (rpmCeilings.size() > 0)
     {
-        result = std::min_element(_RPMCeilings.begin(), _RPMCeilings.end());
+        result = std::min_element(rpmCeilings.begin(), rpmCeilings.end());
         // if Max set point is larger than the lowest ceiling, reset to lowest
         // ceiling.
         if (*result < _maximumSetPoint)
@@ -595,9 +593,9 @@
     return getFailSafeMode();
 }
 
-void DbusPidZone::addPidControlProcess(std::string name, std::string type,
-                                       double setpoint, sdbusplus::bus_t& bus,
-                                       std::string objPath, bool defer)
+void DbusPidZone::addPidControlProcess(
+    const std::string& name, const std::string& type, double setpoint,
+    sdbusplus::bus_t& bus, const std::string& objPath, bool defer)
 {
     _pidsControlProcess[name] = std::make_unique<ProcessObject>(
         bus, objPath.c_str(),
@@ -625,12 +623,12 @@
     }
 }
 
-bool DbusPidZone::isPidProcessEnabled(std::string name)
+bool DbusPidZone::isPidProcessEnabled(const std::string& name)
 {
     return _pidsControlProcess[name]->enabled();
 }
 
-void DbusPidZone::addPidFailSafePercent(std::vector<std::string> inputs,
+void DbusPidZone::addPidFailSafePercent(const std::vector<std::string>& inputs,
                                         double percent)
 {
     for (const auto& sensorName : inputs)
diff --git a/pid/zone.hpp b/pid/zone.hpp
index 325eb6c..7223f76 100644
--- a/pid/zone.hpp
+++ b/pid/zone.hpp
@@ -59,8 +59,7 @@
         ModeObject(bus, objPath,
                    defer ? ModeObject::action::defer_emit
                          : ModeObject::action::emit_object_added),
-        _zoneId(zone), _maximumSetPoint(),
-        _accumulateSetPoint(accumulateSetPoint),
+        _zoneId(zone), _accumulateSetPoint(accumulateSetPoint),
         _minThermalOutputSetPt(minThermalOutput),
         _zoneFailSafePercent(failSafePercent), _cycleTime(cycleTime), _mgr(mgr)
     {
@@ -124,12 +123,13 @@
     /* Method for recording the maximum SetPoint PID config name */
     std::string leader() const override;
     /* Method for control process for each loop at runtime */
-    void addPidControlProcess(std::string name, std::string type,
+    void addPidControlProcess(const std::string& name, const std::string& type,
                               double setpoint, sdbusplus::bus_t& bus,
-                              std::string objPath, bool defer);
-    bool isPidProcessEnabled(std::string name);
+                              const std::string& objPath, bool defer);
+    bool isPidProcessEnabled(const std::string& name);
 
-    void addPidFailSafePercent(std::vector<std::string> inputs, double percent);
+    void addPidFailSafePercent(const std::vector<std::string>& inputs,
+                               double percent);
 
     void updateThermalPowerDebugInterface(std::string pidName,
                                           std::string leader, double input,
@@ -237,8 +237,8 @@
     FailSafeSensorsMap _failSafeSensors;
     std::set<std::string> _missingAcceptable;
 
-    std::map<std::string, double> _SetPoints;
-    std::vector<double> _RPMCeilings;
+    std::map<std::string, double> setPoints;
+    std::vector<double> rpmCeilings;
     std::vector<std::string> _fanInputs;
     std::vector<std::string> _thermalInputs;
     std::map<std::string, ValueCacheEntry> _cachedValuesByName;
diff --git a/sensors/sensor.hpp b/sensors/sensor.hpp
index 9bd39b9..ca1813e 100644
--- a/sensors/sensor.hpp
+++ b/sensors/sensor.hpp
@@ -31,7 +31,7 @@
         _name(name), _timeout(timeout)
     {}
 
-    virtual ~Sensor() {}
+    virtual ~Sensor() = default;
 
     virtual ReadReturn read(void) = 0;
     virtual void write(double value) = 0;
diff --git a/setsensor.cpp b/setsensor.cpp
index 543700e..61bdfb4 100644
--- a/setsensor.cpp
+++ b/setsensor.cpp
@@ -56,7 +56,7 @@
 
 static void SetManualMode(int8_t zone)
 {
-    bool setValue = (bool)0x01;
+    bool setValue = true;
 
     Value v{setValue};
 
diff --git a/sysfs/util.cpp b/sysfs/util.cpp
index 8266040..214d668 100644
--- a/sysfs/util.cpp
+++ b/sysfs/util.cpp
@@ -59,11 +59,9 @@
 
         return fldr + f;
     }
-    else
-    {
-        /* It'll throw an exception when we use it if it's still bad. */
-        return original;
-    }
+
+    /* It'll throw an exception when we use it if it's still bad. */
+    return original;
 }
 
 } // namespace pid_control
diff --git a/test/controller_mock.hpp b/test/controller_mock.hpp
index 9a8e7a6..533b6db 100644
--- a/test/controller_mock.hpp
+++ b/test/controller_mock.hpp
@@ -12,7 +12,7 @@
 class ControllerMock : public PIDController
 {
   public:
-    virtual ~ControllerMock() = default;
+    ~ControllerMock() override = default;
 
     ControllerMock(const std::string& id, ZoneInterface* owner) :
         PIDController(id, owner)
diff --git a/test/dbus_passive_unittest.cpp b/test/dbus_passive_unittest.cpp
index bee64c7..9989e0d 100644
--- a/test/dbus_passive_unittest.cpp
+++ b/test/dbus_passive_unittest.cpp
@@ -20,8 +20,6 @@
 namespace
 {
 
-using ::testing::_;
-using ::testing::InSequence;
 using ::testing::Invoke;
 using ::testing::IsNull;
 using ::testing::NotNull;
diff --git a/test/dbushelper_mock.hpp b/test/dbushelper_mock.hpp
index cdbc59d..b11eff3 100644
--- a/test/dbushelper_mock.hpp
+++ b/test/dbushelper_mock.hpp
@@ -12,7 +12,7 @@
 class DbusHelperMock : public DbusHelperInterface
 {
   public:
-    virtual ~DbusHelperMock() = default;
+    ~DbusHelperMock() override = default;
 
     MOCK_METHOD2(getService,
                  std::string(const std::string&, const std::string&));
diff --git a/test/pid_fancontroller_unittest.cpp b/test/pid_fancontroller_unittest.cpp
index 97dda0a..3fc6433 100644
--- a/test/pid_fancontroller_unittest.cpp
+++ b/test/pid_fancontroller_unittest.cpp
@@ -21,8 +21,6 @@
 {
 
 using ::testing::_;
-using ::testing::DoubleEq;
-using ::testing::Invoke;
 using ::testing::Return;
 using ::testing::StrEq;
 
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index e4e7a26..37fb0fa 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -92,7 +92,7 @@
 {
   protected:
     PidZoneTest() :
-        property_index(), properties(), sdbus_mock_passive(), sdbus_mock_host(),
+        properties(), sdbus_mock_passive(), sdbus_mock_host(),
         sdbus_mock_mode(), sdbus_mock_enable()
     {
         EXPECT_CALL(sdbus_mock_host,
@@ -122,7 +122,7 @@
     }
 
     // unused
-    double property_index;
+    double property_index{};
     std::vector<std::string> properties;
     double propertyenable_index;
     std::vector<std::string> propertiesenable;
@@ -322,7 +322,7 @@
 
     std::map<std::string, std::pair<std::string, double>> failSensorList =
         zone->getFailSafeSensors();
-    EXPECT_EQ(1, failSensorList.size());
+    EXPECT_EQ(1U, failSensorList.size());
     EXPECT_EQ("Sensor threshold asserted", failSensorList["temp1"].first);
     EXPECT_EQ(failSafePercent, failSensorList["temp1"].second);
 }
@@ -349,7 +349,7 @@
 
     std::map<std::string, std::pair<std::string, double>> failSensorList =
         zone->getFailSafeSensors();
-    EXPECT_EQ(3, failSensorList.size());
+    EXPECT_EQ(3U, failSensorList.size());
     EXPECT_EQ("Sensor threshold asserted", failSensorList["temp1"].first);
     EXPECT_EQ(60, failSensorList["temp1"].second);
     EXPECT_EQ("Sensor reading bad", failSensorList["temp2"].first);
diff --git a/test/readinterface_mock.hpp b/test/readinterface_mock.hpp
index 0b77c8a..3634518 100644
--- a/test/readinterface_mock.hpp
+++ b/test/readinterface_mock.hpp
@@ -10,7 +10,7 @@
 class ReadInterfaceMock : public ReadInterface
 {
   public:
-    virtual ~ReadInterfaceMock() = default;
+    ~ReadInterfaceMock() override = default;
 
     MOCK_METHOD0(read, ReadReturn());
 };
diff --git a/test/sensor_mock.hpp b/test/sensor_mock.hpp
index 1de68b6..ae4cf13 100644
--- a/test/sensor_mock.hpp
+++ b/test/sensor_mock.hpp
@@ -11,7 +11,7 @@
 class SensorMock : public Sensor
 {
   public:
-    virtual ~SensorMock() = default;
+    ~SensorMock() override = default;
 
     SensorMock(const std::string& name, int64_t timeout) : Sensor(name, timeout)
     {}
diff --git a/test/writeinterface_mock.hpp b/test/writeinterface_mock.hpp
index 669c1d9..409178c 100644
--- a/test/writeinterface_mock.hpp
+++ b/test/writeinterface_mock.hpp
@@ -10,7 +10,7 @@
 class WriteInterfaceMock : public WriteInterface
 {
   public:
-    virtual ~WriteInterfaceMock() = default;
+    ~WriteInterfaceMock() override = default;
 
     WriteInterfaceMock(int64_t min, int64_t max) : WriteInterface(min, max) {}
 
diff --git a/test/zone_mock.hpp b/test/zone_mock.hpp
index 7d08f63..dcf6b2a 100644
--- a/test/zone_mock.hpp
+++ b/test/zone_mock.hpp
@@ -13,7 +13,7 @@
 class ZoneMock : public ZoneInterface
 {
   public:
-    virtual ~ZoneMock() = default;
+    ~ZoneMock() override = default;
 
     MOCK_METHOD0(updateFanTelemetry, void());
     MOCK_METHOD0(updateSensors, void());
@@ -21,7 +21,7 @@
     MOCK_METHOD1(getCachedValue, double(const std::string&));
 
     // Compatibility interface for getCachedValues
-    ValueCacheEntry getCachedValues(const std::string& s)
+    ValueCacheEntry getCachedValues(const std::string& s) override
     {
         auto v = getCachedValue(s);
         return {v, v};
diff --git a/util.cpp b/util.cpp
index de92772..84c1889 100644
--- a/util.cpp
+++ b/util.cpp
@@ -158,6 +158,7 @@
 {
     std::vector<std::string> results;
 
+    results.reserve(sensorInputs.size());
     for (const auto& sensorInput : sensorInputs)
     {
         results.emplace_back(sensorInput.name);