summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-26 17:55:08 -0700
committerPatrick Venture <venture@google.com>2018-11-08 17:19:15 +0000
commita65e30df5d348337ae0b6afe3f800473117853dd (patch)
treeb9618fbae91c629f56145c6e49bdaa9b2ac10dfb
parenta34c2ab27d7ee8dfe661e02e7dadc56ff707db80 (diff)
downloadphosphor-net-ipmid-a65e30df5d348337ae0b6afe3f800473117853dd.tar.gz
phosphor-net-ipmid-a65e30df5d348337ae0b6afe3f800473117853dd.zip
style: cppcheck cleanup
[command/guid.cpp:37]: (style) The scope of the variable 'rc' can be reduced. [socket_channel.hpp:44]: (performance) Variable 'timeout' is assigned in constructor body. Consider performing initialization in initialization list. [sd_event_loop.cpp:107]: (style) The scope of the variable 'instance' can be reduced. [sd_event_loop.cpp:108]: (style) The scope of the variable 'rc' can be reduced. [sd_event_loop.cpp:142]: (style) The scope of the variable 'instance' can be reduced. [sd_event_loop.cpp:304]: (style) The scope of the variable 'rc' can be reduced. Change-Id: Id090cb217ea7ed9019f1b8d39ebebd6bb73113b1 Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r--command/guid.cpp3
-rw-r--r--sd_event_loop.cpp22
-rw-r--r--socket_channel.hpp5
3 files changed, 13 insertions, 17 deletions
diff --git a/command/guid.cpp b/command/guid.cpp
index 67b71e2..8cd95a6 100644
--- a/command/guid.cpp
+++ b/command/guid.cpp
@@ -34,13 +34,12 @@ Guid getSystemGUID()
sd_bus_message* reply = nullptr;
sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus* bus = ipmid_get_sd_bus_connection();
- int rc = 0;
char* uuid = nullptr;
char* busname = nullptr;
do
{
- rc = mapper_get_service(bus, guidObjPath, &busname);
+ int rc = mapper_get_service(bus, guidObjPath, &busname);
if (rc < 0)
{
std::cerr << "Failed to get " << guidObjPath
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp
index 7ec4db9..a5fd41d 100644
--- a/sd_event_loop.cpp
+++ b/sd_event_loop.cpp
@@ -104,20 +104,20 @@ static int consoleInputHandler(sd_event_source* es, int fd, uint32_t revents,
static int charAccTimerHandler(sd_event_source* s, uint64_t usec,
void* userdata)
{
- // The instance is hardcoded to 1, in the case of supporting multiple
- // payload instances we would need to populate it from userdata
- uint8_t instance = 1;
- int rc = 0;
auto bufferSize = std::get<sol::Manager&>(singletonPool).dataBuffer.size();
try
{
+ // The instance is hardcoded to 1, in the case of supporting multiple
+ // payload instances we would need to populate it from userdata
+ uint8_t instance = 1;
+
if (bufferSize > 0)
{
auto& context =
std::get<sol::Manager&>(singletonPool).getContext(instance);
- rc = context.sendOutboundPayload();
+ int rc = context.sendOutboundPayload();
if (rc == 0)
{
@@ -138,12 +138,12 @@ static int charAccTimerHandler(sd_event_source* s, uint64_t usec,
static int retryTimerHandler(sd_event_source* s, uint64_t usec, void* userdata)
{
- // The instance is hardcoded to 1, in the case of supporting multiple
- // payload instances we would need to populate it from userdata
- uint8_t instance = 1;
-
try
{
+ // The instance is hardcoded to 1, in the case of supporting multiple
+ // payload instances we would need to populate it from userdata
+ uint8_t instance = 1;
+
auto& context =
std::get<sol::Manager&>(singletonPool).getContext(instance);
@@ -302,12 +302,10 @@ void EventLoop::startHostConsole(const sol::CustomFD& fd)
void EventLoop::stopHostConsole()
{
- int rc = 0;
-
if (hostConsole.get())
{
// Disable the host console payload
- rc = sd_event_source_set_enabled(hostConsole.get(), SD_EVENT_OFF);
+ int rc = sd_event_source_set_enabled(hostConsole.get(), SD_EVENT_OFF);
if (rc < 0)
{
log<level::ERR>("Failed to disable the host console socket",
diff --git a/socket_channel.hpp b/socket_channel.hpp
index 8a2edce..4b10b9a 100644
--- a/socket_channel.hpp
+++ b/socket_channel.hpp
@@ -38,10 +38,9 @@ class Channel
*
* @return None
*/
- Channel(int insockfd, timeval& inTimeout)
+ Channel(int insockfd, timeval& inTimeout) :
+ sockfd(insockfd), timeout(inTimeout)
{
- sockfd = insockfd;
- timeout = inTimeout;
}
/**
OpenPOWER on IntegriCloud