meson support: remove code warnings 1

This commit contains code changes necessary to support the increased
warning level from Meson builds. Most changes are for unused variables.

To keep the review size manageable, this commit contains only monitor
and presence changes (and top-level json_config.hpp).

Signed-off-by: Mike Capps <mikepcapps@gmail.com>
Change-Id: I7280b512c54e8d5aeba3300764a239f3dcbab14d
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 3949e18..457324c 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -794,8 +794,8 @@
 void Manager::setProfiles()
 {
     // Profiles JSON config file is optional
-    auto confFile = fan::JsonConfig::getConfFile(_bus, confAppName,
-                                                 Profile::confFileName, true);
+    auto confFile =
+        fan::JsonConfig::getConfFile(confAppName, Profile::confFileName, true);
 
     _profiles.clear();
     if (!confFile.empty())
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
index 8c2be03..3fbcc9c 100644
--- a/control/json/manager.hpp
+++ b/control/json/manager.hpp
@@ -204,9 +204,9 @@
     {
         std::map<configKey, std::unique_ptr<T>> config;
 
-        auto confFile =
-            fan::JsonConfig::getConfFile(util::SDBusPlus::getBus(), confAppName,
-                                         T::confFileName, isOptional);
+        auto confFile = fan::JsonConfig::getConfFile(
+            confAppName, T::confFileName, isOptional);
+
         if (!confFile.empty())
         {
             FlightRecorder::instance().log(
diff --git a/json_config.hpp b/json_config.hpp
index 82d7c58..aae33b9 100644
--- a/json_config.hpp
+++ b/json_config.hpp
@@ -209,7 +209,6 @@
      *
      * @brief Get the configuration file to be used
      *
-     * @param[in] bus - The dbus bus object
      * @param[in] appName - The phosphor-fan-presence application name
      * @param[in] fileName - Application's configuration file's name
      * @param[in] isOptional - Config file is optional, default to 'false'
@@ -217,8 +216,7 @@
      * @return filesystem path
      *     The filesystem path to the configuration file to use
      */
-    static const fs::path getConfFile(sdbusplus::bus::bus& bus,
-                                      const std::string& appName,
+    static const fs::path getConfFile(const std::string& appName,
                                       const std::string& fileName,
                                       bool isOptional = false)
     {
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index fa8b392..7bd1542 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -506,7 +506,7 @@
     }
 }
 
-void Fan::powerStateChanged(bool powerStateOn)
+void Fan::powerStateChanged([[maybe_unused]] bool powerStateOn)
 {
 #ifdef MONITOR_USE_JSON
     if (powerStateOn)
diff --git a/monitor/json_parser.cpp b/monitor/json_parser.cpp
index a46e2a9..1144998 100644
--- a/monitor/json_parser.cpp
+++ b/monitor/json_parser.cpp
@@ -198,7 +198,7 @@
         }
         // Valid deviation range is 0 - 100%
         auto deviation = fan["deviation"].get<size_t>();
-        if (deviation < 0 || 100 < deviation)
+        if (100 < deviation)
         {
             auto msg = fmt::format(
                 "Invalid deviation of {} found, must be between 0 and 100",
diff --git a/monitor/json_parser.hpp b/monitor/json_parser.hpp
index c6b64ec..7f09fd3 100644
--- a/monitor/json_parser.hpp
+++ b/monitor/json_parser.hpp
@@ -43,15 +43,13 @@
 /**
  * @brief Get the JSON object
  *
- * @param[in] bus - The dbus bus object
- *
  * @return JSON object
  *     A JSON object created after loading the JSON configuration file
  */
-inline const json getJsonObj(sdbusplus::bus::bus& bus)
+inline const json getJsonObj()
 {
     return fan::JsonConfig::load(
-        fan::JsonConfig::getConfFile(bus, confAppName, confFileName));
+        fan::JsonConfig::getConfFile(confAppName, confFileName));
 }
 
 /**
diff --git a/monitor/main.cpp b/monitor/main.cpp
index 0949c77..5ed0953 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -33,7 +33,7 @@
 
 using namespace phosphor::fan::monitor;
 
-int main(int argc, char* argv[])
+int main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
 {
     auto event = sdeventplus::Event::get_default();
     auto bus = sdbusplus::bus::new_default();
diff --git a/monitor/system.cpp b/monitor/system.cpp
index aff3bdc..6e2ccfa 100644
--- a/monitor/system.cpp
+++ b/monitor/system.cpp
@@ -84,7 +84,7 @@
 #ifdef MONITOR_USE_JSON
     try
     {
-        jsonObj = getJsonObj(_bus);
+        jsonObj = getJsonObj();
 #endif
         auto trustGrps = getTrustGroups(jsonObj);
         auto fanDefs = getFanDefinitions(jsonObj);
@@ -231,7 +231,7 @@
 }
 
 const std::vector<CreateGroupFunction>
-    System::getTrustGroups(const json& jsonObj)
+    System::getTrustGroups([[maybe_unused]] const json& jsonObj)
 {
 #ifdef MONITOR_USE_JSON
     return getTrustGrps(jsonObj);
@@ -245,7 +245,8 @@
     _trust = std::make_unique<trust::Manager>(groupFuncs);
 }
 
-const std::vector<FanDefinition> System::getFanDefinitions(const json& jsonObj)
+const std::vector<FanDefinition>
+    System::getFanDefinitions([[maybe_unused]] const json& jsonObj)
 {
 #ifdef MONITOR_USE_JSON
     return getFanDefs(jsonObj);
@@ -334,7 +335,7 @@
     }
 }
 
-void System::setFaultConfig(const json& jsonObj)
+void System::setFaultConfig([[maybe_unused]] const json& jsonObj)
 {
 #ifdef MONITOR_USE_JSON
     std::shared_ptr<PowerInterfaceBase> powerInterface =
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 0ff1828..be56c69 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -70,11 +70,11 @@
     }
 }
 
-TachSensor::TachSensor(Mode mode, sdbusplus::bus::bus& bus, Fan& fan,
-                       const std::string& id, bool hasTarget, size_t funcDelay,
-                       const std::string& interface, double factor,
-                       int64_t offset, size_t method, size_t threshold,
-                       bool ignoreAboveMax, size_t timeout,
+TachSensor::TachSensor([[maybe_unused]] Mode mode, sdbusplus::bus::bus& bus,
+                       Fan& fan, const std::string& id, bool hasTarget,
+                       size_t funcDelay, const std::string& interface,
+                       double factor, int64_t offset, size_t method,
+                       size_t threshold, bool ignoreAboveMax, size_t timeout,
                        const std::optional<size_t>& errorDelay,
                        size_t countInterval, const sdeventplus::Event& event) :
     _bus(bus),
diff --git a/presence/fallback.cpp b/presence/fallback.cpp
index 4a025a7..36824fc 100644
--- a/presence/fallback.cpp
+++ b/presence/fallback.cpp
@@ -31,7 +31,7 @@
 namespace presence
 {
 
-void Fallback::stateChanged(bool present, PresenceSensor& sensor)
+void Fallback::stateChanged(bool present, PresenceSensor& /*sensor*/)
 {
     if (!present)
     {
diff --git a/presence/fallback.hpp b/presence/fallback.hpp
index bd9d1a5..d6bad02 100644
--- a/presence/fallback.hpp
+++ b/presence/fallback.hpp
@@ -58,7 +58,7 @@
      *             to the active sensor.
      * @param[in] sensor - The sensor that changed state.
      */
-    void stateChanged(bool present, PresenceSensor& sensor) override;
+    void stateChanged(bool present, PresenceSensor& /*sensor*/) override;
 
     /**
      * @brief monitor
diff --git a/presence/gpio.hpp b/presence/gpio.hpp
index 317e264..fc650ca 100644
--- a/presence/gpio.hpp
+++ b/presence/gpio.hpp
@@ -159,7 +159,7 @@
      *
      * @param[in] fanInventoryPath - The fan inventory D-Bus object path.
      */
-    void logConflict(const std::string& fanInventoryPath) const override
+    void logConflict(const std::string& /*fanInventoryPath*/) const override
     {}
 
   private:
diff --git a/presence/json_parser.cpp b/presence/json_parser.cpp
index e09317b..7858c4f 100644
--- a/presence/json_parser.cpp
+++ b/presence/json_parser.cpp
@@ -61,8 +61,7 @@
 
     if (!_loaded)
     {
-        process(
-            config::load(config::getConfFile(_bus, confAppName, confFileName)));
+        process(config::load(config::getConfFile(confAppName, confFileName)));
 
         _loaded = true;
 
@@ -78,8 +77,8 @@
     return _policies;
 }
 
-void JsonConfig::sighupHandler(sdeventplus::source::Signal& sigSrc,
-                               const struct signalfd_siginfo* sigInfo)
+void JsonConfig::sighupHandler(sdeventplus::source::Signal& /*sigSrc*/,
+                               const struct signalfd_siginfo* /*sigInfo*/)
 {
     try
     {
@@ -88,8 +87,7 @@
         _reporter.reset();
 
         // Load and process the json configuration
-        process(
-            config::load(config::getConfFile(_bus, confAppName, confFileName)));
+        process(config::load(config::getConfFile(confAppName, confFileName)));
 
         for (auto& p : _policies)
         {
diff --git a/presence/json_parser.hpp b/presence/json_parser.hpp
index dfd2ce2..216c235 100644
--- a/presence/json_parser.hpp
+++ b/presence/json_parser.hpp
@@ -71,8 +71,8 @@
      * @param[in] sigSrc - sd_event_source signal wrapper
      * @param[in] sigInfo - signal info on signal fd
      */
-    void sighupHandler(sdeventplus::source::Signal& sigSrc,
-                       const struct signalfd_siginfo* sigInfo);
+    void sighupHandler(sdeventplus::source::Signal& /*sigSrc*/,
+                       const struct signalfd_siginfo* /*sigInfo*/);
 
     /**
      * @brief Parses and populates the fan presence policies from
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index 909fbc3..0f5b0be 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -401,6 +401,22 @@
         return getPropertyVariant<Variant>(getBus(), path, interface, property);
     }
 
+    /** @brief Invoke a method and return without checking for error. */
+    template <typename... Args>
+    static auto callMethodAndReturn(sdbusplus::bus::bus& bus,
+                                    const std::string& busName,
+                                    const std::string& path,
+                                    const std::string& interface,
+                                    const std::string& method, Args&&... args)
+    {
+        auto reqMsg = bus.new_method_call(busName.c_str(), path.c_str(),
+                                          interface.c_str(), method.c_str());
+        reqMsg.append(std::forward<Args>(args)...);
+        auto respMsg = bus.call(reqMsg);
+
+        return respMsg;
+    }
+
     /** @brief Get a property without mapper lookup. */
     template <typename Property>
     static auto getProperty(sdbusplus::bus::bus& bus,
@@ -573,22 +589,6 @@
         return lookupCallMethodAndRead<Ret>(getBus(), path, interface, method,
                                             std::forward<Args>(args)...);
     }
-
-    /** @brief Invoke a method and return without checking for error. */
-    template <typename... Args>
-    static auto callMethodAndReturn(sdbusplus::bus::bus& bus,
-                                    const std::string& busName,
-                                    const std::string& path,
-                                    const std::string& interface,
-                                    const std::string& method, Args&&... args)
-    {
-        auto reqMsg = bus.new_method_call(busName.c_str(), path.c_str(),
-                                          interface.c_str(), method.c_str());
-        reqMsg.append(std::forward<Args>(args)...);
-        auto respMsg = bus.call(reqMsg);
-
-        return respMsg;
-    }
 };
 
 } // namespace util
diff --git a/sensor-monitor/shutdown_alarm_monitor.cpp b/sensor-monitor/shutdown_alarm_monitor.cpp
index 419bdec..77281b6 100644
--- a/sensor-monitor/shutdown_alarm_monitor.cpp
+++ b/sensor-monitor/shutdown_alarm_monitor.cpp
@@ -130,11 +130,14 @@
     {
         auto paths = SDBusPlus::getSubTreePathsRaw(bus, "/", interface, 0);
 
+        auto shutdownType2 = shutdownType;
+
         std::for_each(
-            paths.begin(), paths.end(), [this, shutdownType](const auto& path) {
-                alarms.emplace(AlarmKey{path, shutdownType, AlarmType::high},
+            paths.begin(), paths.end(),
+            [this, shutdownType2](const auto& path) {
+                alarms.emplace(AlarmKey{path, shutdownType2, AlarmType::high},
                                nullptr);
-                alarms.emplace(AlarmKey{path, shutdownType, AlarmType::low},
+                alarms.emplace(AlarmKey{path, shutdownType2, AlarmType::low},
                                nullptr);
             });
     }