Enable init checker

clang-tidy added cppcoreguidelines-init-variables as a check, which is
something we already enforce to some extent, but getting CI to enforce
it will help reviews move faster.

Tested: Code compiles.  Noop changes.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I7e10950de617b1d3262265572b1703f2e60b69d0
diff --git a/.clang-tidy b/.clang-tidy
index 6704aff..6f3c69d 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -201,6 +201,7 @@
 clang-analyzer-valist.ValistBase,
 clang-analyzer-webkit.NoUncountedMemberChecker,
 clang-analyzer-webkit.RefCntblBaseVirtualDtor,
+cppcoreguidelines-init-variables,
 misc-misplaced-const,
 #misc-no-recursion,
 misc-redundant-expression,
diff --git a/http/routing.hpp b/http/routing.hpp
index c8946e4..06f2a09 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -805,7 +805,7 @@
             char c = reqUrl[pos];
             if ((c >= '0' && c <= '9') || c == '+' || c == '-')
             {
-                char* eptr;
+                char* eptr = nullptr;
                 errno = 0;
                 long long int value =
                     std::strtoll(reqUrl.data() + pos, &eptr, 10);
@@ -828,7 +828,7 @@
             char c = reqUrl[pos];
             if ((c >= '0' && c <= '9') || c == '+')
             {
-                char* eptr;
+                char* eptr = nullptr;
                 errno = 0;
                 unsigned long long int value =
                     std::strtoull(reqUrl.data() + pos, &eptr, 10);
@@ -851,7 +851,7 @@
             char c = reqUrl[pos];
             if ((c >= '0' && c <= '9') || c == '+' || c == '-' || c == '.')
             {
-                char* eptr;
+                char* eptr = nullptr;
                 errno = 0;
                 double value = std::strtod(reqUrl.data() + pos, &eptr);
                 if (errno != ERANGE && eptr != reqUrl.data() + pos)
diff --git a/http/utility.hpp b/http/utility.hpp
index 374caea..74a35da 100644
--- a/http/utility.hpp
+++ b/http/utility.hpp
@@ -425,7 +425,7 @@
     size_t i = 0;
     while (i < size)
     {
-        size_t keyIndex;
+        size_t keyIndex = 0;
 
         keyIndex = static_cast<size_t>(data[i] & 0xFC) >> 2;
         *it++ = key[keyIndex];
@@ -513,10 +513,10 @@
 
     for (size_t i = 0; i < inputLength; i++)
     {
-        char base64code0;
-        char base64code1;
+        char base64code0 = 0;
+        char base64code1 = 0;
         char base64code2 = 0; // initialized to 0 to suppress warnings
-        char base64code3;
+        char base64code3 = 0;
 
         base64code0 = getCodeValue(input[i]);
         if (base64code0 == nop)
diff --git a/include/async_resolve.hpp b/include/async_resolve.hpp
index 105616d..563d816 100644
--- a/include/async_resolve.hpp
+++ b/include/async_resolve.hpp
@@ -73,7 +73,7 @@
                         handler(ec, endpointList);
                         return;
                     }
-                    uint16_t portNum;
+                    uint16_t portNum = 0;
                     auto it = std::from_chars(
                         port.data(), port.data() + port.size(), portNum);
                     if (it.ec != std::errc())
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index 800ee48..fb8b396 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -39,7 +39,7 @@
 
 class Lock
 {
-    uint32_t transactionId;
+    uint32_t transactionId = 0;
     boost::container::flat_map<uint32_t, LockRequests> lockTable;
 
   protected:
@@ -429,7 +429,7 @@
 inline Rc Lock::isConflictWithTable(const LockRequests& refLockRequestStructure)
 {
 
-    uint32_t transactionId;
+    uint32_t transactionId = 0;
 
     if (lockTable.empty())
     {
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index 59d4111..57c9d83 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -418,7 +418,7 @@
     for (auto& element : body)
     {
         std::string lockType;
-        uint64_t resourceId;
+        uint64_t resourceId = 0;
 
         SegmentFlags segInfo;
         std::vector<nlohmann::json> segmentFlags;
@@ -439,7 +439,7 @@
         for (auto& e : segmentFlags)
         {
             std::string lockFlags;
-            uint32_t segmentLength;
+            uint32_t segmentLength = 0;
 
             if (!redfish::json_util::readJson(e, asyncResp->res, "LockFlag",
                                               lockFlags, "SegmentLength",
diff --git a/include/json_html_serializer.hpp b/include/json_html_serializer.hpp
index be9efc4..3efc224 100644
--- a/include/json_html_serializer.hpp
+++ b/include/json_html_serializer.hpp
@@ -327,9 +327,9 @@
 
     const bool isNegative = std::is_same<NumberType, int64_t>::value &&
                             !(number >= 0); // see issue #755
-    uint64_t absValue;
+    uint64_t absValue = 0;
 
-    unsigned int nChars;
+    unsigned int nChars = 0;
 
     if (isNegative)
     {
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 7f16ea8..0b54c65 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -1104,7 +1104,7 @@
 inline int readVariantFromMessage(sdbusplus::message::message& m,
                                   nlohmann::json& data)
 {
-    const char* containerType;
+    const char* containerType = nullptr;
     int r = sd_bus_message_peek_type(m.get(), nullptr, &containerType);
     if (r < 0)
     {
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index abb1c94..eb59bee 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -256,8 +256,7 @@
     {
         std::cerr << "Generating x509 Certificate\n";
         // Use this code to directly generate a certificate
-        X509* x509;
-        x509 = X509_new();
+        X509* x509 = X509_new();
         if (x509 != nullptr)
         {
             // get a random number from the RNG for the certificate serial
@@ -280,8 +279,7 @@
             X509_set_pubkey(x509, pPrivKey);
 
             // get the subject name
-            X509_NAME* name;
-            name = X509_get_subject_name(x509);
+            X509_NAME* name = X509_get_subject_name(x509);
 
             X509_NAME_add_entry_by_txt(
                 name, "C", MBSTRING_ASC,
diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp
index 0df6416..cef8aa5 100644
--- a/redfish-core/include/utils/time_utils.hpp
+++ b/redfish-core/include/utils/time_utils.hpp
@@ -43,7 +43,7 @@
         return false;
     }
 
-    const char* end;
+    const char* end = nullptr;
     std::chrono::milliseconds::rep ticks = 0;
     if constexpr (std::is_same_v<FromTime, std::chrono::milliseconds>)
     {
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 8735178..ee8d2cd 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -635,9 +635,9 @@
         *bits = 0;
     }
 
-    char* endPtr;
+    char* endPtr = nullptr;
     long previousValue = 255;
-    bool firstZeroInByteHit;
+    bool firstZeroInByteHit = false;
     for (const std::string& byte : bytesInMask)
     {
         if (byte.empty())
@@ -1581,8 +1581,8 @@
                 return;
             }
 
-            const std::string* addr;
-            uint8_t prefix;
+            const std::string* addr = nullptr;
+            uint8_t prefix = 0;
 
             // Find the address and prefixLength values. Any values that are
             // not explicitly provided are assumed to be unmodified from the
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 3a955cb..ad5c5e3 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -1092,8 +1092,8 @@
             std::vector<double> outputs;
             for (auto& step : *steps)
             {
-                double target;
-                double out;
+                double target = 0.0;
+                double out = 0.0;
 
                 if (!redfish::json_util::readJson(step, response->res, "Target",
                                                   target, "Output", out))
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index ae02189..cfa2bf5 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -62,7 +62,7 @@
     const crow::Request&, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
     const std::string& registry)
 {
-    const message_registries::Header* header;
+    const message_registries::Header* header = nullptr;
     std::string dmtf = "DMTF ";
     const char* url = nullptr;
 
@@ -127,7 +127,7 @@
     const std::string& registry, const std::string& registryMatch)
 
 {
-    const message_registries::Header* header;
+    const message_registries::Header* header = nullptr;
     std::vector<const message_registries::MessageEntry*> registryEntries;
     if (registry == "Base")
     {
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 6d10bb7..99dfc81 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2758,10 +2758,10 @@
     BMCWEB_LOG_INFO << "setSensorsOverride for subNode"
                     << sensorAsyncResp->chassisSubNode << "\n";
 
-    const char* propertyValueName;
+    const char* propertyValueName = nullptr;
     std::unordered_map<std::string, std::pair<double, std::string>> overrideMap;
     std::string memberId;
-    double value;
+    double value = 0.0;
     for (auto& collectionItems : allCollections)
     {
         if (collectionItems.first == "Temperatures")
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 2605c3f..e7f4f02 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -1728,7 +1728,7 @@
     BMCWEB_LOG_DEBUG << "Set Automatic Retry.";
 
     // OpenBMC only supports "Disabled" and "RetryAttempts".
-    bool autoRebootEnabled;
+    bool autoRebootEnabled = false;
 
     if (automaticRetryConfig == "Disabled")
     {
@@ -2765,7 +2765,7 @@
 
             // Get the command and host vs. chassis
             std::string command;
-            bool hostCommand;
+            bool hostCommand = true;
             if ((resetType == "On") || (resetType == "ForceOn"))
             {
                 command = "xyz.openbmc_project.State.Host.Transition.On";