Fix cppcheck warnings
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I18be21d5141630a1da3d5e54740b54a9a06496d9
diff --git a/inc/button_factory.hpp b/inc/button_factory.hpp
index 0d427f7..fc75f4f 100644
--- a/inc/button_factory.hpp
+++ b/inc/button_factory.hpp
@@ -46,7 +46,7 @@
* @brief this method returns the button interface object
* corresponding to the button formfactor name provided
*/
- std::unique_ptr<ButtonIface> createInstance(std::string name,
+ std::unique_ptr<ButtonIface> createInstance(const std::string& name,
sdbusplus::bus::bus& bus,
EventPtr& event,
buttonConfig& buttonCfg)
diff --git a/inc/button_handler.hpp b/inc/button_handler.hpp
index b3c65f5..baa7400 100644
--- a/inc/button_handler.hpp
+++ b/inc/button_handler.hpp
@@ -39,7 +39,7 @@
*
* @param[in] bus - sdbusplus connection object
*/
- Handler(sdbusplus::bus::bus& bus);
+ explicit Handler(sdbusplus::bus::bus& bus);
private:
/**
diff --git a/inc/button_interface.hpp b/inc/button_interface.hpp
index 0a0181b..9d85e8e 100644
--- a/inc/button_interface.hpp
+++ b/inc/button_interface.hpp
@@ -108,8 +108,8 @@
}
}
- buttonConfig config;
sdbusplus::bus::bus& bus;
EventPtr& event;
+ buttonConfig config;
sd_event_io_handler_t callbackHandler;
};
diff --git a/inc/common.hpp b/inc/common.hpp
index 82746ee..1b4911f 100644
--- a/inc/common.hpp
+++ b/inc/common.hpp
@@ -24,7 +24,7 @@
{
void operator()(sd_event* event) const
{
- event = sd_event_unref(event);
+ sd_event_unref(event);
}
};
using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
diff --git a/src/button_handler.cpp b/src/button_handler.cpp
index a819183..764c807 100644
--- a/src/button_handler.cpp
+++ b/src/button_handler.cpp
@@ -277,7 +277,7 @@
method.append(dbusIfaceName, transitionName, transition);
bus.call(method);
}
-void Handler::powerPressed(sdbusplus::message::message& msg)
+void Handler::powerPressed(sdbusplus::message::message& /* msg */)
{
try
{
@@ -289,7 +289,7 @@
entry("ERROR=%s", e.what()));
}
}
-void Handler::longPowerPressed(sdbusplus::message::message& msg)
+void Handler::longPowerPressed(sdbusplus::message::message& /* msg */)
{
try
{
@@ -302,7 +302,7 @@
}
}
-void Handler::resetPressed(sdbusplus::message::message& msg)
+void Handler::resetPressed(sdbusplus::message::message& /* msg */)
{
try
{
@@ -315,7 +315,7 @@
}
}
-void Handler::idPressed(sdbusplus::message::message& msg)
+void Handler::idPressed(sdbusplus::message::message& /* msg */)
{
std::string groupPath{ledGroupBasePath};
groupPath += ID_LED_GROUP;
diff --git a/src/button_handler_main.cpp b/src/button_handler_main.cpp
index e9fcc27..e71f8e4 100644
--- a/src/button_handler_main.cpp
+++ b/src/button_handler_main.cpp
@@ -1,6 +1,6 @@
#include "button_handler.hpp"
-int main(int argc, char* argv[])
+int main(void)
{
auto bus = sdbusplus::bus::new_default();
diff --git a/src/gpio.cpp b/src/gpio.cpp
index 86d4cec..52ffed6 100644
--- a/src/gpio.cpp
+++ b/src/gpio.cpp
@@ -203,14 +203,15 @@
}
else if ((gpioDirection == "both"))
{
- // Before set gpio configure as an interrupt pin, need to set direction
- // as 'in' or edge can't set as 'rising', 'falling' and 'both'
- const char* in_direction = "in";
devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/direction";
stream.open(devPath, std::fstream::out);
try
{
+ // Before set gpio configure as an interrupt pin, need to set
+ // direction as 'in' or edge can't set as 'rising', 'falling' and
+ // 'both'
+ const char* in_direction = "in";
stream << in_direction;
stream.close();
}
diff --git a/src/hostSelector_switch.cpp b/src/hostSelector_switch.cpp
index c3ad83f..dbdd836 100644
--- a/src/hostSelector_switch.cpp
+++ b/src/hostSelector_switch.cpp
@@ -37,7 +37,7 @@
void HostSelector::setInitialHostSelectorValue()
{
char buf;
- for (int index = 0; index < gpioLineCount; index++)
+ for (size_t index = 0; index < gpioLineCount; index++)
{
auto result = ::lseek(config.gpios[index].fd, 0, SEEK_SET);
@@ -94,7 +94,8 @@
* init() function can be created to override the default event handling
*/
-void HostSelector::handleEvent(sd_event_source* es, int fd, uint32_t revents)
+void HostSelector::handleEvent(sd_event_source* /* es */, int fd,
+ uint32_t /* revents */)
{
int n = -1;
char buf = '0';
diff --git a/src/id_button.cpp b/src/id_button.cpp
index 71e8539..99fd27f 100644
--- a/src/id_button.cpp
+++ b/src/id_button.cpp
@@ -24,7 +24,8 @@
pressed();
}
-void IDButton::handleEvent(sd_event_source* es, int fd, uint32_t revents)
+void IDButton::handleEvent(sd_event_source* /* es */, int fd,
+ uint32_t /* revents */)
{
int n = -1;
char buf = '0';
diff --git a/src/main.cpp b/src/main.cpp
index 624c9e7..5288635 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -26,7 +26,7 @@
using namespace phosphor::logging;
nlohmann::json gpioDefs;
-int main(int argc, char* argv[])
+int main(void)
{
int ret = 0;
diff --git a/src/power_button.cpp b/src/power_button.cpp
index 2446d7b..b6a89b9 100644
--- a/src/power_button.cpp
+++ b/src/power_button.cpp
@@ -39,7 +39,8 @@
return pressedTime;
}
-void PowerButton::handleEvent(sd_event_source* es, int fd, uint32_t revents)
+void PowerButton::handleEvent(sd_event_source* /* es */, int fd,
+ uint32_t /* revents */)
{
int n = -1;
char buf = '0';
diff --git a/src/reset_button.cpp b/src/reset_button.cpp
index c3e467e..03430f9 100644
--- a/src/reset_button.cpp
+++ b/src/reset_button.cpp
@@ -26,7 +26,8 @@
pressed();
}
-void ResetButton::handleEvent(sd_event_source* es, int fd, uint32_t revents)
+void ResetButton::handleEvent(sd_event_source* /* es */, int fd,
+ uint32_t /* revents */)
{
int n = -1;
char buf = '0';