Fix static analysis & cppcheck issues

This commit fixes:
1. warning: Value stored to 'event' is never read [deadcode.DeadStores]
2. style: Consider using std::transform algorithm instead of a raw loop. [useStlAlgorithm]
3. style: Variable 'usTimeOffset' is assigned a value that is never used. [unreadVariable]

Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: Ia0c8235195aa7eceda8bd8f36cd11fcb72781d1b
diff --git a/inc/post_code.hpp b/inc/post_code.hpp
index 498a0d8..be800f2 100644
--- a/inc/post_code.hpp
+++ b/inc/post_code.hpp
@@ -72,7 +72,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/post_code.cpp b/src/post_code.cpp
index 4b14ca1..3633ea2 100644
--- a/src/post_code.cpp
+++ b/src/post_code.cpp
@@ -39,8 +39,9 @@
     std::vector<postcode_t> codesVec;
     if (1 == index && !postCodes.empty())
     {
-        for (auto& code : postCodes)
-            codesVec.push_back(code.second);
+        std::transform(postCodes.begin(), postCodes.end(),
+                       std::back_inserter(codesVec),
+                       [](const auto& kv) { return kv.second; });
     }
     else
     {
@@ -49,8 +50,8 @@
         decltype(postCodes) codes;
         deserializePostCodes(
             fs::path(strPostCodeListPath + std::to_string(bootNum)), codes);
-        for (std::pair<uint64_t, postcode_t> code : codes)
-            codesVec.push_back(code.second);
+        std::transform(codes.begin(), codes.end(), std::back_inserter(codesVec),
+                       [](const auto& kv) { return kv.second; });
     }
     return codesVec;
 }
@@ -72,7 +73,6 @@
 
 void PostCode::savePostCodes(postcode_t code)
 {
-    uint64_t usTimeOffset = 0;
     // steady_clock is a monotonic clock that is guaranteed to never be adjusted
     auto postCodeTimeSteady = std::chrono::steady_clock::now();
     uint64_t tsUS = std::chrono::duration_cast<std::chrono::microseconds>(
@@ -88,9 +88,10 @@
     else
     {
         // calculating tsUS so it is monotonic within the same boot
-        usTimeOffset = std::chrono::duration_cast<std::chrono::microseconds>(
-                           postCodeTimeSteady - firstPostCodeTimeSteady)
-                           .count();
+        uint64_t usTimeOffset =
+            std::chrono::duration_cast<std::chrono::microseconds>(
+                postCodeTimeSteady - firstPostCodeTimeSteady)
+                .count();
         tsUS = usTimeOffset + firstPostCodeUsSinceEpoch;
     }