diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp
index 15e1af4..3b20c9f 100644
--- a/redfish-core/include/privileges.hpp
+++ b/redfish-core/include/privileges.hpp
@@ -34,10 +34,10 @@
     "Login", "ConfigureManager", "ConfigureComponents", "ConfigureSelf",
     "ConfigureUsers"};
 
-constexpr const size_t basePrivilegeCount = basePrivileges.size();
+constexpr const int basePrivilegeCount = basePrivileges.size();
 
 /** @brief Max number of privileges per type  */
-constexpr const size_t maxPrivilegeCount = 32;
+constexpr const int maxPrivilegeCount = 32;
 
 /** @brief A vector of all privilege names and their indexes */
 static const std::vector<std::string> privilegeNames{basePrivileges.begin(),
@@ -96,7 +96,7 @@
      */
     bool setSinglePrivilege(const char* privilege)
     {
-        for (size_t searchIndex = 0; searchIndex < privilegeNames.size();
+        for (int searchIndex = 0; searchIndex < privilegeNames.size();
              searchIndex++)
         {
             if (privilege == privilegeNames[searchIndex])
@@ -136,8 +136,8 @@
     {
         std::vector<const std::string*> activePrivileges;
 
-        size_t searchIndex = 0;
-        size_t endIndex = basePrivilegeCount;
+        int searchIndex = 0;
+        int endIndex = basePrivilegeCount;
         if (type == PrivilegeType::OEM)
         {
             searchIndex = basePrivilegeCount - 1;
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index b992018..476e03a 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -302,8 +302,7 @@
                         boost::container::flat_set<IPv4AddressData>::iterator,
                         bool>
                         it = ipv4_config.insert(
-                            {objpath.first.str.substr(ipv4PathStart.size()), "",
-                             "", "", "", "", LinkType::Local});
+                            {objpath.first.str.substr(ipv4PathStart.size())});
                     IPv4AddressData &ipv4_address = *it.first;
                     for (auto &property : interface.second)
                     {
@@ -479,6 +478,45 @@
 }
 
 /**
+ * @brief Changes IPv4 address type property (Address, Gateway)
+ *
+ * @param[in] ifaceId     Id of interface whose IP should be modified
+ * @param[in] ipIdx       Index of IP in input array that should be modified
+ * @param[in] ipHash      DBus Hash id of modified IP
+ * @param[in] name        Name of field in JSON representation
+ * @param[in] newValue    New value that should be written
+ * @param[io] asyncResp   Response object that will be returned to client
+ *
+ * @return true if give IP is valid and has been sent do D-Bus, false
+ * otherwise
+ */
+inline void changeIPv4AddressProperty(
+    const std::string &ifaceId, int ipIdx, const std::string &ipHash,
+    const std::string &name, const std::string &newValue,
+    const std::shared_ptr<AsyncResp> asyncResp)
+{
+    auto callback = [asyncResp, ipIdx, name{std::string(name)},
+                     newValue{std::move(newValue)}](
+                        const boost::system::error_code ec) {
+        if (ec)
+        {
+            messages::internalError(asyncResp->res);
+        }
+        else
+        {
+            asyncResp->res.jsonValue["IPv4Addresses"][ipIdx][name] = newValue;
+        }
+    };
+
+    crow::connections::systemBus->async_method_call(
+        std::move(callback), "xyz.openbmc_project.Network",
+        "/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash,
+        "org.freedesktop.DBus.Properties", "Set",
+        "xyz.openbmc_project.Network.IP", name,
+        std::variant<std::string>(newValue));
+}
+
+/**
  * @brief Changes IPv4 address origin property
  *
  * @param[in] ifaceId       Id of interface whose IP should be modified
@@ -492,7 +530,7 @@
  * @return true if give IP is valid and has been sent do D-Bus, false
  * otherwise
  */
-inline void changeIPv4Origin(const std::string &ifaceId, size_t ipIdx,
+inline void changeIPv4Origin(const std::string &ifaceId, int ipIdx,
                              const std::string &ipHash,
                              const std::string &newValue,
                              const std::string &newValueDbus,
@@ -532,8 +570,7 @@
  *
  * @return None
  */
-inline void changeIPv4SubnetMaskProperty(const std::string &ifaceId,
-                                         size_t ipIdx,
+inline void changeIPv4SubnetMaskProperty(const std::string &ifaceId, int ipIdx,
                                          const std::string &ipHash,
                                          const std::string &newValueStr,
                                          uint8_t &newValue,
@@ -600,8 +637,9 @@
  *
  * @return None
  */
-inline void createIPv4(const std::string &ifaceId, uint8_t subnetMask,
-                       const std::string &gateway, const std::string &address,
+inline void createIPv4(const std::string &ifaceId, unsigned int ipIdx,
+                       uint8_t subnetMask, const std::string &gateway,
+                       const std::string &address,
                        std::shared_ptr<AsyncResp> asyncResp)
 {
     auto createIpHandler = [asyncResp](const boost::system::error_code ec) {
@@ -1061,7 +1099,6 @@
             if (gateway)
             {
                 if (!ipv4VerifyIpAndGetBitcount(*gateway))
-
                 {
                     messages::propertyValueFormatError(asyncResp->res, *gateway,
                                                        pathString + "/Gateway");
@@ -1161,7 +1198,8 @@
                     continue;
                 }
 
-                createIPv4(ifaceId, entryIdx, *gateway, *address, asyncResp);
+                createIPv4(ifaceId, entryIdx, prefixLength, *gateway, *address,
+                           asyncResp);
 
                 nlohmann::json &ipv4AddressJson =
                     asyncResp->res.jsonValue["IPv4Addresses"][entryIdx];
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index b07d6b1..61cbd9e 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -46,8 +46,8 @@
     size_t length = 0;
     int ret = 0;
     // Get the metadata from the requested field of the journal entry
-    ret = sd_journal_get_data(journal, field.data(),
-                              reinterpret_cast<const void **>(&data), &length);
+    ret = sd_journal_get_data(journal, field.data(), (const void **)&data,
+                              &length);
     if (ret < 0)
     {
         return ret;
@@ -70,7 +70,7 @@
     {
         return ret;
     }
-    contents = static_cast<int>(strtol(metadata.data(), nullptr, base));
+    contents = strtol(metadata.data(), nullptr, base);
     return ret;
 }
 
@@ -215,12 +215,12 @@
         {
             index = std::stoul(std::string(indexStr), &pos);
         }
-        catch (std::invalid_argument &)
+        catch (std::invalid_argument)
         {
             messages::resourceMissingAtURI(res, entryID);
             return false;
         }
-        catch (std::out_of_range &)
+        catch (std::out_of_range)
         {
             messages::resourceMissingAtURI(res, entryID);
             return false;
@@ -237,12 +237,12 @@
     {
         timestamp = std::stoull(std::string(tsStr), &pos);
     }
-    catch (std::invalid_argument &)
+    catch (std::invalid_argument)
     {
         messages::resourceMissingAtURI(res, entryID);
         return false;
     }
-    catch (std::out_of_range &)
+    catch (std::out_of_range)
     {
         messages::resourceMissingAtURI(res, entryID);
         return false;
@@ -382,8 +382,8 @@
             {
                 continue;
             }
-            unsigned long argNum = std::strtoul(field.data(), nullptr, 10);
-            if (argNum == 0 || argNum > std::numeric_limits<size_t>::max())
+            int argNum = std::strtoul(field.data(), nullptr, 10);
+            if (argNum == 0)
             {
                 continue;
             }
@@ -392,7 +392,7 @@
             // Make sure we have enough space in messageArgs
             if (argNum > messageArgs.size())
             {
-                messageArgs.resize(static_cast<size_t>(argNum));
+                messageArgs.resize(argNum);
             }
             messageArgs[argNum - 1] = std::string(field);
         }
@@ -482,7 +482,7 @@
         std::unique_ptr<sd_journal, decltype(&sd_journal_close)> journal(
             journalTmp, sd_journal_close);
         journalTmp = nullptr;
-        long entryCount = 0;
+        uint64_t entryCount = 0;
         SD_JOURNAL_FOREACH(journal.get())
         {
             // Look for only journal entries that contain a REDFISH_MESSAGE_ID
@@ -803,7 +803,7 @@
         std::unique_ptr<sd_journal, decltype(&sd_journal_close)> journal(
             journalTmp, sd_journal_close);
         journalTmp = nullptr;
-        long entryCount = 0;
+        uint64_t entryCount = 0;
         SD_JOURNAL_FOREACH(journal.get())
         {
             entryCount++;
@@ -1094,7 +1094,7 @@
             messages::internalError(asyncResp->res);
             return;
         }
-        const int logId = std::atoi(params[0].c_str());
+        const uint8_t logId = std::atoi(params[0].c_str());
         auto getStoredLogCallback = [asyncResp, logId](
                                         const boost::system::error_code ec,
                                         const std::variant<std::string> &resp) {
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 0aa4478..f9c2f38 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -785,10 +785,10 @@
             for (auto& step : *steps)
             {
                 double target;
-                double out;
+                double output;
 
                 if (!redfish::json_util::readJson(step, response->res, "Target",
-                                                  target, "Output", out))
+                                                  target, "Output", output))
                 {
                     BMCWEB_LOG_ERROR << "Line:" << __LINE__
                                      << ", Illegal Property "
@@ -796,7 +796,7 @@
                     return CreatePIDRet::fail;
                 }
                 readings.emplace_back(target);
-                outputs.emplace_back(out);
+                outputs.emplace_back(output);
             }
             output["Reading"] = std::move(readings);
             output["Output"] = std::move(outputs);
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 78f1d8a..b1df101 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -38,8 +38,9 @@
     }
 
   private:
-    std::vector<const char*> typeList = {"/xyz/openbmc_project/sensors/voltage",
-                                         "/xyz/openbmc_project/sensors/power"};
+    std::initializer_list<const char*> typeList = {
+        "/xyz/openbmc_project/sensors/voltage",
+        "/xyz/openbmc_project/sensors/power"};
     void doGet(crow::Response& res, const crow::Request& req,
                const std::vector<std::string>& params) override
     {
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 51895ee..bbed047 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -49,7 +49,7 @@
 {
   public:
     SensorsAsyncResp(crow::Response& response, const std::string& chassisId,
-                     const std::vector<const char*> types,
+                     const std::initializer_list<const char*> types,
                      const std::string& subNode) :
         res(response),
         chassisId(chassisId), types(types), chassisSubNode(subNode)
@@ -539,11 +539,11 @@
         auto interfaceProperties = interfacesDict.find(std::get<0>(p));
         if (interfaceProperties != interfacesDict.end())
         {
-            auto valIt = interfaceProperties->second.find(std::get<1>(p));
-            if (valIt != interfaceProperties->second.end())
+            auto valueIt = interfaceProperties->second.find(std::get<1>(p));
+            if (valueIt != interfaceProperties->second.end())
             {
-                const SensorVariant& valueVariant = valIt->second;
-                nlohmann::json& jValueIt = sensor_json[std::get<2>(p)];
+                const SensorVariant& valueVariant = valueIt->second;
+                nlohmann::json& valueIt = sensor_json[std::get<2>(p)];
                 // Attempt to pull the int64 directly
                 const int64_t* int64Value = std::get_if<int64_t>(&valueVariant);
 
@@ -566,11 +566,11 @@
                 temp = temp * std::pow(10, scaleMultiplier);
                 if (forceToInt)
                 {
-                    jValueIt = static_cast<int64_t>(temp);
+                    valueIt = static_cast<int64_t>(temp);
                 }
                 else
                 {
-                    jValueIt = temp;
+                    valueIt = temp;
                 }
             }
         }
@@ -985,7 +985,7 @@
  */
 void setSensorOverride(crow::Response& res, const crow::Request& req,
                        const std::vector<std::string>& params,
-                       const std::vector<const char*> typeList,
+                       const std::initializer_list<const char*> typeList,
                        const std::string& chassisSubNode)
 {
 
diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp
index 58e7cd4..f266c40 100644
--- a/redfish-core/lib/thermal.hpp
+++ b/redfish-core/lib/thermal.hpp
@@ -37,7 +37,7 @@
     }
 
   private:
-    std::vector<const char*> typeList = {
+    std::initializer_list<const char*> typeList = {
         "/xyz/openbmc_project/sensors/fan_tach",
         "/xyz/openbmc_project/sensors/temperature",
         "/xyz/openbmc_project/sensors/fan_pwm"};
