netipmid: apply clang-format rules

Lots of whitespace change. Let clang-format do its job and keep the code
looking nice.

Change-Id: Idfcad1a99cab8170d55a06163de8ad3f420b68b7
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp
index 3351da7..7ec4db9 100644
--- a/sd_event_loop.cpp
+++ b/sd_event_loop.cpp
@@ -1,11 +1,14 @@
+#include "sd_event_loop.hpp"
+
+#include "main.hpp"
+#include "message_handler.hpp"
+
 #include <netinet/in.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <systemd/sd-daemon.h>
+
 #include <phosphor-logging/log.hpp>
-#include "main.hpp"
-#include "message_handler.hpp"
-#include "sd_event_loop.hpp"
 
 namespace eventloop
 {
@@ -26,7 +29,6 @@
         // Initialize the Message Handler with the socket channel
         message::Handler msgHandler(channelPtr);
 
-
         std::unique_ptr<message::Message> inMessage;
 
         // Read the incoming IPMI packet
@@ -65,7 +67,7 @@
         if (ioctl(fd, FIONREAD, &readSize) < 0)
         {
             log<level::ERR>("ioctl failed for FIONREAD:",
-                    entry("ERRNO=%d", errno));
+                            entry("ERRNO=%d", errno));
             return 0;
         }
 
@@ -88,7 +90,7 @@
         else if (readDataLen < 0) // Error
         {
             log<level::ERR>("Reading from host console socket failed:",
-                    entry("ERRNO=%d", errno));
+                            entry("ERRNO=%d", errno));
         }
     }
     catch (std::exception& e)
@@ -100,7 +102,7 @@
 }
 
 static int charAccTimerHandler(sd_event_source* s, uint64_t usec,
-                               void *userdata)
+                               void* userdata)
 {
     // The instance is hardcoded to 1, in the case of supporting multiple
     // payload instances we would need to populate it from userdata
@@ -110,10 +112,10 @@
 
     try
     {
-        if(bufferSize > 0)
+        if (bufferSize > 0)
         {
-            auto& context = std::get<sol::Manager&>(singletonPool).getContext
-                    (instance);
+            auto& context =
+                std::get<sol::Manager&>(singletonPool).getContext(instance);
 
             rc = context.sendOutboundPayload();
 
@@ -123,8 +125,8 @@
             }
         }
 
-        std::get<eventloop::EventLoop&>(singletonPool).switchTimer(
-                instance, Timers::ACCUMULATE, true);
+        std::get<eventloop::EventLoop&>(singletonPool)
+            .switchTimer(instance, Timers::ACCUMULATE, true);
     }
     catch (std::exception& e)
     {
@@ -134,8 +136,7 @@
     return 0;
 }
 
-static int retryTimerHandler(sd_event_source* s, uint64_t usec,
-                             void *userdata)
+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
@@ -143,24 +144,24 @@
 
     try
     {
-        auto& context = std::get<sol::Manager&>(singletonPool).getContext
-                (instance);
+        auto& context =
+            std::get<sol::Manager&>(singletonPool).getContext(instance);
 
         if (context.retryCounter)
         {
             --context.retryCounter;
-            std::get<eventloop::EventLoop&>(singletonPool).switchTimer
-                    (instance, Timers::RETRY, true);
+            std::get<eventloop::EventLoop&>(singletonPool)
+                .switchTimer(instance, Timers::RETRY, true);
             context.resendPayload(sol::Context::noClear);
         }
         else
         {
             context.retryCounter = context.maxRetryCount;
             context.resendPayload(sol::Context::clear);
-            std::get<eventloop::EventLoop&>(singletonPool).switchTimer
-                    (instance, Timers::RETRY, false);
-            std::get<eventloop::EventLoop&>(singletonPool).switchTimer
-                    (instance, Timers::ACCUMULATE, true);
+            std::get<eventloop::EventLoop&>(singletonPool)
+                .switchTimer(instance, Timers::RETRY, false);
+            std::get<eventloop::EventLoop&>(singletonPool)
+                .switchTimer(instance, Timers::ACCUMULATE, true);
         }
     }
     catch (std::exception& e)
@@ -216,7 +217,7 @@
         goto finish;
     }
 
-    //Create our own socket if SysD did not supply one.
+    // Create our own socket if SysD did not supply one.
     listen_fd = sd_listen_fds(0);
     if (listen_fd == 1)
     {
@@ -241,7 +242,7 @@
         address.sin_addr.s_addr = INADDR_ANY;
         address.sin_port = htons(IPMI_STD_PORT);
 
-        if (bind(fd, (struct sockaddr *)&address, sizeof(address)) < 0)
+        if (bind(fd, (struct sockaddr*)&address, sizeof(address)) < 0)
         {
             r = -errno;
             log<level::ERR>("Unable to bind socket");
@@ -264,13 +265,13 @@
 
     if (fd >= 0)
     {
-        (void) close(fd);
+        (void)close(fd);
     }
 
     if (r < 0)
     {
         log<level::ERR>("Event Loop Failure:",
-                entry("FAILURE=%s", strerror(-r)));
+                        entry("FAILURE=%s", strerror(-r)));
     }
 
     return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
@@ -280,7 +281,7 @@
 {
     int rc = 0;
 
-    if((fd() == -1) || hostConsole.get())
+    if ((fd() == -1) || hostConsole.get())
     {
         throw std::runtime_error("Console descriptor already added");
     }
@@ -288,15 +289,15 @@
     sd_event_source* source = nullptr;
 
     // Add the fd to the event loop for EPOLLIN
-    rc = sd_event_add_io(
-            event, &source, fd(), EPOLLIN, consoleInputHandler, nullptr);
+    rc = sd_event_add_io(event, &source, fd(), EPOLLIN, consoleInputHandler,
+                         nullptr);
     if (rc < 0)
     {
         throw std::runtime_error("Failed to add socket descriptor");
     }
 
     hostConsole.reset(source);
-    source=nullptr;
+    source = nullptr;
 }
 
 void EventLoop::stopHostConsole()
@@ -310,7 +311,7 @@
         if (rc < 0)
         {
             log<level::ERR>("Failed to disable the host console socket",
-                    entry("RC=%d", rc));
+                            entry("RC=%d", rc));
         }
 
         hostConsole.reset();
@@ -331,37 +332,28 @@
     if (rc < 0)
     {
         log<level::ERR>("Failed to get the current timestamp",
-                entry("RC=%d", rc));
+                        entry("RC=%d", rc));
         throw std::runtime_error("Failed to get current timestamp");
     }
 
     // Create character accumulate timer
-    rc = sd_event_add_time(event,
-                           &accTimerSource,
-                           CLOCK_MONOTONIC,
-                           currentTime + accumulateInterval.count(),
-                           0,
-                           charAccTimerHandler,
-                           static_cast<void *>(&instance));
+    rc = sd_event_add_time(event, &accTimerSource, CLOCK_MONOTONIC,
+                           currentTime + accumulateInterval.count(), 0,
+                           charAccTimerHandler, static_cast<void*>(&instance));
     if (rc < 0)
     {
         log<level::ERR>("Failed to setup the accumulate timer",
-                entry("RC=%d", rc));
+                        entry("RC=%d", rc));
         throw std::runtime_error("Failed to setup accumulate timer");
     }
 
     // Create retry interval timer and add to the event loop
-    rc = sd_event_add_time(event,
-                           &retryTimerSource,
-                           CLOCK_MONOTONIC,
-                           currentTime + retryInterval.count(),
-                           0,
-                           retryTimerHandler,
-                           static_cast<void *>(&instance));
+    rc = sd_event_add_time(event, &retryTimerSource, CLOCK_MONOTONIC,
+                           currentTime + retryInterval.count(), 0,
+                           retryTimerHandler, static_cast<void*>(&instance));
     if (rc < 0)
     {
-        log<level::ERR>("Failed to setup the retry timer",
-                entry("RC=%d", rc));
+        log<level::ERR>("Failed to setup the retry timer", entry("RC=%d", rc));
         throw std::runtime_error("Failed to setup retry timer");
     }
 
@@ -370,7 +362,7 @@
     if (rc < 0)
     {
         log<level::ERR>("Failed to enable the accumulate timer",
-                entry("RC=%d", rc));
+                        entry("RC=%d", rc));
         throw std::runtime_error("Failed to enable accumulate timer");
     }
 
@@ -379,7 +371,7 @@
     if (rc < 0)
     {
         log<level::ERR>("Failed to disable the retry timer",
-                entry("RC=%d", rc));
+                        entry("RC=%d", rc));
         throw std::runtime_error("Failed to disable retry timer");
     }
 
@@ -391,8 +383,8 @@
     TimerMap timer;
     timer.emplace(Timers::ACCUMULATE, std::make_tuple(std::move(accEventSource),
                                                       accumulateInterval));
-    timer.emplace(Timers::RETRY, std::make_tuple(std::move(retryEventSource),
-                                                 retryInterval));
+    timer.emplace(Timers::RETRY,
+                  std::make_tuple(std::move(retryEventSource), retryInterval));
     payloadInfo.emplace(instance, std::move(timer));
 }
 
@@ -402,7 +394,7 @@
     if (iter == payloadInfo.end())
     {
         log<level::ERR>("SOL Payload instance not found",
-                entry("PAYLOADINST=%d", payloadInst));
+                        entry("PAYLOADINST=%d", payloadInst));
         throw std::runtime_error("SOL payload instance not found");
     }
 
@@ -410,24 +402,22 @@
 
     /* Destroy the character accumulate timer event source */
     rc = sd_event_source_set_enabled(
-            (std::get<0>(iter->second.at(Timers::ACCUMULATE))).get(),
-            SD_EVENT_OFF);
+        (std::get<0>(iter->second.at(Timers::ACCUMULATE))).get(), SD_EVENT_OFF);
     if (rc < 0)
     {
         log<level::ERR>("Failed to disable the character accumulate timer",
-                entry("RC=%d", rc));
+                        entry("RC=%d", rc));
         payloadInfo.erase(payloadInst);
         throw std::runtime_error("Failed to disable accumulate timer");
     }
 
     /* Destroy the retry interval timer event source */
     rc = sd_event_source_set_enabled(
-            (std::get<0>(iter->second.at(Timers::RETRY))).get(),
-            SD_EVENT_OFF);
+        (std::get<0>(iter->second.at(Timers::RETRY))).get(), SD_EVENT_OFF);
     if (rc < 0)
     {
         log<level::ERR>("Failed to disable the retry timer",
-                entry("RC=%d", rc));
+                        entry("RC=%d", rc));
         payloadInfo.erase(payloadInst);
         throw std::runtime_error("Failed to disable retry timer");
     }
@@ -435,15 +425,13 @@
     payloadInfo.erase(payloadInst);
 }
 
-void EventLoop::switchTimer(uint8_t payloadInst,
-                            Timers type,
-                            bool status)
+void EventLoop::switchTimer(uint8_t payloadInst, Timers type, bool status)
 {
     auto iter = payloadInfo.find(payloadInst);
     if (iter == payloadInfo.end())
     {
         log<level::ERR>("SOL Payload instance not found",
-                entry("PAYLOADINST=%d", payloadInst));
+                        entry("PAYLOADINST=%d", payloadInst));
         throw std::runtime_error("SOL Payload instance not found");
     }
 
@@ -469,7 +457,7 @@
     if (rc < 0)
     {
         log<level::ERR>("Failed to get the current timestamp",
-                entry("RC=%d", rc));
+                        entry("RC=%d", rc));
         throw std::runtime_error("Failed to get current timestamp");
     }
 
@@ -477,14 +465,14 @@
     if (rc < 0)
     {
         log<level::ERR>("sd_event_source_set_time function failed",
-                entry("RC=%d", rc));
+                        entry("RC=%d", rc));
         throw std::runtime_error("sd_event_source_set_time function failed");
     }
 
     rc = sd_event_source_set_enabled(source, SD_EVENT_ONESHOT);
     if (rc < 0)
     {
-        log<level::ERR>("Failed to enable the timer", entry("RC=%d",rc));
+        log<level::ERR>("Failed to enable the timer", entry("RC=%d", rc));
         throw std::runtime_error("Failed to enable timer");
     }
 }