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>
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 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 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::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",