Revert "bmcweb: Fix a bunch of warnings"

This reverts commit 6ea007a2faec52ad62680015d2a3f00371a1e351.

Reason for revert: Reports of bmcweb seg faults.

Change-Id: I408f1bb29c2f8e427a6621cdaac8c31b847ebf06
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3bedfe7..1300c23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,7 +60,7 @@
 
 set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
+set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall")
 
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
diff --git a/crow/include/crow/http_connection.h b/crow/include/crow/http_connection.h
index d7598bd..c02f4ec 100644
--- a/crow/include/crow/http_connection.h
+++ b/crow/include/crow/http_connection.h
@@ -345,7 +345,7 @@
             };
 
             ctx = detail::Context<Middlewares...>();
-            req->middlewareContext = static_cast<void*>(&ctx);
+            req->middlewareContext = (void*)&ctx;
             req->ioService = &adaptor.get_executor().context();
             detail::middlewareCallHelper<
                 0, decltype(ctx), decltype(*middlewares), Middlewares...>(
@@ -388,13 +388,14 @@
             needToCallAfterHandlers = false;
 
             // call all afterHandler of middlewares
-            detail::afterHandlersCallHelper<
-                static_cast<int>(sizeof...(Middlewares) - 1), decltype(ctx),
-                decltype(*middlewares)>(*middlewares, ctx, *req, res);
+            detail::afterHandlersCallHelper<((int)sizeof...(Middlewares) - 1),
+                                            decltype(ctx),
+                                            decltype(*middlewares)>(
+                *middlewares, ctx, *req, res);
         }
 
         // auto self = this->shared_from_this();
-        res.completeRequestHandler = [] {};
+        res.completeRequestHandler = res.completeRequestHandler = [] {};
 
         if (!adaptor.lowest_layer().is_open())
         {
diff --git a/crow/include/crow/http_request.h b/crow/include/crow/http_request.h
index fa12c26..0ba0266 100644
--- a/crow/include/crow/http_request.h
+++ b/crow/include/crow/http_request.h
@@ -27,7 +27,7 @@
     {
     }
 
-    boost::beast::http::verb method() const
+    const boost::beast::http::verb method() const
     {
         return req.method();
     }
diff --git a/crow/include/crow/http_server.h b/crow/include/crow/http_server.h
index eace64f..75b49a4 100644
--- a/crow/include/crow/http_server.h
+++ b/crow/include/crow/http_server.h
@@ -121,17 +121,17 @@
         boost::asio::deadline_timer timer(*ioService);
         timer.expires_from_now(boost::posix_time::seconds(1));
 
-        std::function<void(const boost::system::error_code& ec)> fHandler;
-        fHandler = [&](const boost::system::error_code& ec) {
+        std::function<void(const boost::system::error_code& ec)> handler;
+        handler = [&](const boost::system::error_code& ec) {
             if (ec)
             {
                 return;
             }
             timerQueue.process();
             timer.expires_from_now(boost::posix_time::seconds(1));
-            timer.async_wait(fHandler);
+            timer.async_wait(handler);
         };
-        timer.async_wait(fHandler);
+        timer.async_wait(handler);
 
         if (tickFunction && tickInterval.count() > 0)
         {
diff --git a/crow/include/crow/logging.h b/crow/include/crow/logging.h
index 0d24940..9da47b7 100644
--- a/crow/include/crow/logging.h
+++ b/crow/include/crow/logging.h
@@ -30,7 +30,6 @@
 {
   public:
     virtual void log(std::string message, LogLevel level) = 0;
-    virtual ~ILogHandler(){};
 };
 
 class CerrLogHandler : public ILogHandler
diff --git a/crow/include/crow/query_string.h b/crow/include/crow/query_string.h
index b38d0ed..553960e 100644
--- a/crow/include/crow/query_string.h
+++ b/crow/include/crow/query_string.h
@@ -19,16 +19,16 @@
  *  Also decodes the value portion of the k/v pair *in-place*.  In a future
  *  enhancement it will also have a compile-time option of sorting qs_kv
  *  alphabetically by key.  */
-size_t qsParse(char* qs, char* qs_kv[], size_t qs_kv_size);
+int qsParse(char* qs, char* qs_kv[], int qs_kv_size);
 
 /*  Used by qs_parse to decode the value portion of a k/v pair  */
-size_t qsDecode(char* qs);
+int qsDecode(char* qs);
 
 /*  Looks up the value according to the key on a pre-processed query string
  *  A future enhancement will be a compile-time option to look up the key
  *  in a pre-sorted qs_kv array via a binary search.  */
 // char * qs_k2v(const char * key, char * qs_kv[], int qs_kv_size);
-char* qsK2v(const char* key, char* const* qs_kv, size_t qs_kv_size, size_t nth);
+char* qsK2v(const char* key, char* const* qs_kv, int qs_kv_size, int nth);
 
 /*  Non-destructive lookup of value, based on key.  User provides the
  *  destinaton string and length.  */
@@ -127,9 +127,9 @@
     }
 }
 
-inline size_t qsParse(char* qs, char* qs_kv[], size_t qs_kv_size)
+inline int qsParse(char* qs, char* qs_kv[], int qs_kv_size)
 {
-    size_t i, j;
+    int i, j;
     char* substrPtr;
 
     for (i = 0; i < qs_kv_size; i++)
@@ -184,9 +184,9 @@
     return i;
 }
 
-inline size_t qsDecode(char* qs)
+inline int qsDecode(char* qs)
 {
-    size_t i = 0, j = 0;
+    int i = 0, j = 0;
 
     while (BMCWEB_QS_ISQSCHR(qs[j]))
     {
@@ -217,10 +217,10 @@
     return i;
 }
 
-inline char* qsK2v(const char* key, char* const* qs_kv, size_t qs_kv_size,
-                   size_t nth = 0)
+inline char* qsK2v(const char* key, char* const* qs_kv, int qs_kv_size,
+                   int nth = 0)
 {
-    size_t i;
+    int i;
     size_t keyLen, skip;
 
     keyLen = strlen(key);
@@ -353,8 +353,7 @@
 
         keyValuePairs.resize(maxKeyValuePairsCount);
 
-        size_t count =
-            qsParse(&url[0], &keyValuePairs[0], maxKeyValuePairsCount);
+        int count = qsParse(&url[0], &keyValuePairs[0], maxKeyValuePairsCount);
         keyValuePairs.resize(count);
     }
 
@@ -392,7 +391,7 @@
         std::string plus = name + "[]";
         char* element = nullptr;
 
-        size_t count = 0;
+        int count = 0;
         while (1)
         {
             element = qsK2v(plus.c_str(), keyValuePairs.data(),
diff --git a/crow/include/crow/routing.h b/crow/include/crow/routing.h
index d7e3fd3..746e115 100644
--- a/crow/include/crow/routing.h
+++ b/crow/include/crow/routing.h
@@ -63,8 +63,7 @@
     }
 
   protected:
-    uint32_t methodsBitfield{
-        1 << static_cast<int>(boost::beast::http::verb::get)};
+    uint32_t methodsBitfield{1 << (int)boost::beast::http::verb::get};
 
     std::string rule;
     std::string nameStr;
@@ -363,33 +362,29 @@
     using self_t = T;
     WebSocketRule& websocket()
     {
-        self_t* s = static_cast<self_t*>(this);
-        auto p = new WebSocketRule(s->rule);
-        s->ruleToUpgrade.reset(p);
+        auto p = new WebSocketRule(((self_t*)this)->rule);
+        ((self_t*)this)->ruleToUpgrade.reset(p);
         return *p;
     }
 
     self_t& name(std::string name) noexcept
     {
-        self_t* s = static_cast<self_t*>(this);
-        s->nameStr = std::move(name);
-        return *s;
+        ((self_t*)this)->nameStr = std::move(name);
+        return (self_t&)*this;
     }
 
     self_t& methods(boost::beast::http::verb method)
     {
-        self_t* s = static_cast<self_t*>(this);
-        s->methodsBitfield = 1 << static_cast<int>(method);
-        return *s;
+        ((self_t*)this)->methodsBitfield = 1 << (int)method;
+        return (self_t&)*this;
     }
 
     template <typename... MethodArgs>
     self_t& methods(boost::beast::http::verb method, MethodArgs... args_method)
     {
-        self_t* s = static_cast<self_t*>(this);
         methods(args_method...);
-        s->methodsBitfield |= 1 << static_cast<int>(method);
-        return *s;
+        ((self_t*)this)->methodsBitfield |= 1 << (int)method;
+        return (self_t&)*this;
     }
 };
 
@@ -586,7 +581,7 @@
     struct Node
     {
         unsigned ruleIndex{};
-        std::array<unsigned, static_cast<int>(ParamType::MAX)> paramChildrens{};
+        std::array<unsigned, (int)ParamType::MAX> paramChildrens{};
         boost::container::flat_map<std::string, unsigned> children;
 
         bool isSimpleNode() const
@@ -680,15 +675,14 @@
                     route_indexes.push_back(child->ruleIndex);
                 }
                 findRouteIndexes(req_url, route_indexes, child,
-                                 pos + static_cast<unsigned>(fragment.size()));
+                                 pos + fragment.size());
             }
             else
             {
                 if (req_url.compare(pos, fragment.size(), fragment) == 0)
                 {
-                    findRouteIndexes(
-                        req_url, route_indexes, child,
-                        pos + static_cast<unsigned>(fragment.size()));
+                    findRouteIndexes(req_url, route_indexes, child,
+                                     pos + fragment.size());
                 }
             }
         }
@@ -719,7 +713,7 @@
                 }
             };
 
-        if (node->paramChildrens[static_cast<int>(ParamType::INT)])
+        if (node->paramChildrens[(int)ParamType::INT])
         {
             char c = req_url[pos];
             if ((c >= '0' && c <= '9') || c == '+' || c == '-')
@@ -731,18 +725,17 @@
                 if (errno != ERANGE && eptr != req_url.data() + pos)
                 {
                     params->intParams.push_back(value);
-                    auto ret = find(
-                        req_url,
-                        &nodes[node->paramChildrens[static_cast<int>(
-                            ParamType::INT)]],
-                        static_cast<unsigned>(eptr - req_url.data()), params);
+                    auto ret =
+                        find(req_url,
+                             &nodes[node->paramChildrens[(int)ParamType::INT]],
+                             eptr - req_url.data(), params);
                     updateFound(ret);
                     params->intParams.pop_back();
                 }
             }
         }
 
-        if (node->paramChildrens[static_cast<int>(ParamType::UINT)])
+        if (node->paramChildrens[(int)ParamType::UINT])
         {
             char c = req_url[pos];
             if ((c >= '0' && c <= '9') || c == '+')
@@ -754,18 +747,17 @@
                 if (errno != ERANGE && eptr != req_url.data() + pos)
                 {
                     params->uintParams.push_back(value);
-                    auto ret = find(
-                        req_url,
-                        &nodes[node->paramChildrens[static_cast<int>(
-                            ParamType::UINT)]],
-                        static_cast<unsigned>(eptr - req_url.data()), params);
+                    auto ret =
+                        find(req_url,
+                             &nodes[node->paramChildrens[(int)ParamType::UINT]],
+                             eptr - req_url.data(), params);
                     updateFound(ret);
                     params->uintParams.pop_back();
                 }
             }
         }
 
-        if (node->paramChildrens[static_cast<int>(ParamType::DOUBLE)])
+        if (node->paramChildrens[(int)ParamType::DOUBLE])
         {
             char c = req_url[pos];
             if ((c >= '0' && c <= '9') || c == '+' || c == '-' || c == '.')
@@ -778,18 +770,17 @@
                     params->doubleParams.push_back(value);
                     auto ret = find(
                         req_url,
-                        &nodes[node->paramChildrens[static_cast<int>(
-                            ParamType::DOUBLE)]],
-                        static_cast<unsigned>(eptr - req_url.data()), params);
+                        &nodes[node->paramChildrens[(int)ParamType::DOUBLE]],
+                        eptr - req_url.data(), params);
                     updateFound(ret);
                     params->doubleParams.pop_back();
                 }
             }
         }
 
-        if (node->paramChildrens[static_cast<int>(ParamType::STRING)])
+        if (node->paramChildrens[(int)ParamType::STRING])
         {
-            unsigned epos = pos;
+            size_t epos = pos;
             for (; epos < req_url.size(); epos++)
             {
                 if (req_url[epos] == '/')
@@ -800,27 +791,26 @@
             {
                 params->stringParams.emplace_back(
                     req_url.substr(pos, epos - pos));
-                auto ret = find(req_url,
-                                &nodes[node->paramChildrens[static_cast<int>(
-                                    ParamType::STRING)]],
-                                epos, params);
+                auto ret =
+                    find(req_url,
+                         &nodes[node->paramChildrens[(int)ParamType::STRING]],
+                         epos, params);
                 updateFound(ret);
                 params->stringParams.pop_back();
             }
         }
 
-        if (node->paramChildrens[static_cast<int>(ParamType::PATH)])
+        if (node->paramChildrens[(int)ParamType::PATH])
         {
-            unsigned epos = static_cast<unsigned>(req_url.size());
+            size_t epos = req_url.size();
 
             if (epos != pos)
             {
                 params->stringParams.emplace_back(
                     req_url.substr(pos, epos - pos));
-                auto ret = find(req_url,
-                                &nodes[node->paramChildrens[static_cast<int>(
-                                    ParamType::PATH)]],
-                                epos, params);
+                auto ret = find(
+                    req_url, &nodes[node->paramChildrens[(int)ParamType::PATH]],
+                    epos, params);
                 updateFound(ret);
                 params->stringParams.pop_back();
             }
@@ -833,9 +823,7 @@
 
             if (req_url.compare(pos, fragment.size(), fragment) == 0)
             {
-                auto ret =
-                    find(req_url, child,
-                         pos + static_cast<unsigned>(fragment.size()), params);
+                auto ret = find(req_url, child, pos + fragment.size(), params);
                 updateFound(ret);
             }
         }
@@ -870,16 +858,12 @@
                 {
                     if (url.compare(i, x.name.size(), x.name) == 0)
                     {
-                        if (!nodes[idx]
-                                 .paramChildrens[static_cast<size_t>(x.type)])
+                        if (!nodes[idx].paramChildrens[(int)x.type])
                         {
                             auto newNodeIdx = newNode();
-                            nodes[idx]
-                                .paramChildrens[static_cast<size_t>(x.type)] =
-                                newNodeIdx;
+                            nodes[idx].paramChildrens[(int)x.type] = newNodeIdx;
                         }
-                        idx = nodes[idx]
-                                  .paramChildrens[static_cast<size_t>(x.type)];
+                        idx = nodes[idx].paramChildrens[(int)x.type];
                         i += x.name.size();
                         break;
                     }
@@ -904,15 +888,15 @@
     }
 
   private:
-    void debugNodePrint(Node* n, unsigned level)
+    void debugNodePrint(Node* n, int level)
     {
-        for (size_t i = 0; i < static_cast<size_t>(ParamType::MAX); i++)
+        for (int i = 0; i < (int)ParamType::MAX; i++)
         {
             if (n->paramChildrens[i])
             {
                 BMCWEB_LOG_DEBUG << std::string(
                     2 * level, ' ') /*<< "("<<n->paramChildrens[i]<<") "*/;
-                switch (static_cast<ParamType>(i))
+                switch ((ParamType)i)
                 {
                     case ParamType::INT:
                         BMCWEB_LOG_DEBUG << "<int>";
@@ -966,7 +950,7 @@
     unsigned newNode()
     {
         nodes.resize(nodes.size() + 1);
-        return static_cast<unsigned>(nodes.size() - 1);
+        return nodes.size() - 1;
     }
 
     std::vector<Node> nodes;
@@ -1007,14 +991,13 @@
                                std::unique_ptr<BaseRule> ruleObject)
     {
         rules.emplace_back(std::move(ruleObject));
-        trie.add(rule, static_cast<unsigned>(rules.size() - 1));
+        trie.add(rule, rules.size() - 1);
 
         // directory case:
         //   request to `/about' url matches `/about/' rule
         if (rule.size() > 2 && rule.back() == '/')
         {
-            trie.add(rule.substr(0, rule.size() - 1),
-                     static_cast<unsigned>(rules.size() - 1));
+            trie.add(rule.substr(0, rule.size() - 1), rules.size() - 1);
         }
     }
 
@@ -1073,12 +1056,12 @@
             return;
         }
 
-        if ((rules[ruleIndex]->getMethods() &
-             (1 << static_cast<uint32_t>(req.method()))) == 0)
+        if ((rules[ruleIndex]->getMethods() & (1 << (uint32_t)req.method())) ==
+            0)
         {
             BMCWEB_LOG_DEBUG << "Rule found but method mismatch: " << req.url
                              << " with " << req.methodString() << "("
-                             << static_cast<uint32_t>(req.method()) << ") / "
+                             << (uint32_t)req.method() << ") / "
                              << rules[ruleIndex]->getMethods();
             res = Response(boost::beast::http::status::not_found);
             res.end();
@@ -1086,7 +1069,7 @@
         }
 
         BMCWEB_LOG_DEBUG << "Matched rule (upgrade) '" << rules[ruleIndex]->rule
-                         << "' " << static_cast<uint32_t>(req.method()) << " / "
+                         << "' " << (uint32_t)req.method() << " / "
                          << rules[ruleIndex]->getMethods();
 
         // any uncaught exceptions become 500s
@@ -1151,12 +1134,12 @@
             return;
         }
 
-        if ((rules[ruleIndex]->getMethods() &
-             (1 << static_cast<uint32_t>(req.method()))) == 0)
+        if ((rules[ruleIndex]->getMethods() & (1 << (uint32_t)req.method())) ==
+            0)
         {
             BMCWEB_LOG_DEBUG << "Rule found but method mismatch: " << req.url
                              << " with " << req.methodString() << "("
-                             << static_cast<uint32_t>(req.method()) << ") / "
+                             << (uint32_t)req.method() << ") / "
                              << rules[ruleIndex]->getMethods();
             res = Response(boost::beast::http::status::not_found);
             res.end();
@@ -1164,7 +1147,7 @@
         }
 
         BMCWEB_LOG_DEBUG << "Matched rule '" << rules[ruleIndex]->rule << "' "
-                         << static_cast<uint32_t>(req.method()) << " / "
+                         << (uint32_t)req.method() << " / "
                          << rules[ruleIndex]->getMethods();
 
         // any uncaught exceptions become 500s
diff --git a/crow/include/crow/timer_queue.h b/crow/include/crow/timer_queue.h
index 556fdb3..bf1e084 100644
--- a/crow/include/crow/timer_queue.h
+++ b/crow/include/crow/timer_queue.h
@@ -22,11 +22,10 @@
 
     void cancel(int k)
     {
-        int index = k - step;
-
-        if (index < static_cast<int>(dq.size()))
+        unsigned int index = static_cast<unsigned int>(k - step);
+        if (index < dq.size())
         {
-            dq[static_cast<size_t>(index)].second = nullptr;
+            dq[index].second = nullptr;
         }
     }
 
@@ -34,7 +33,7 @@
     {
         dq.push_back(
             std::make_pair(std::chrono::steady_clock::now(), std::move(f)));
-        int ret = step + static_cast<int>(dq.size()) - 1;
+        int ret = step + dq.size() - 1;
 
         BMCWEB_LOG_DEBUG << "timer add inside: " << this << ' ' << ret;
         return ret;
diff --git a/crow/include/crow/utility.h b/crow/include/crow/utility.h
index 5c7a7f6..a07c041 100644
--- a/crow/include/crow/utility.h
+++ b/crow/include/crow/utility.h
@@ -524,7 +524,7 @@
 };
 
 inline static std::string base64encode(
-    const uint8_t* data, size_t size,
+    const char* data, size_t size,
     const char* key =
         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
 {
@@ -533,36 +533,36 @@
     auto it = ret.begin();
     while (size >= 3)
     {
-        *it++ = key[(*data & 0xFC) >> 2];
-        uint8_t h = static_cast<uint8_t>((*data++ & 0x03) << 4);
-        *it++ = key[h | ((*data & 0xF0) >> 4)];
-        h = static_cast<uint8_t>((*data++ & 0x0F) << 2);
-        *it++ = key[h | ((*data & 0xC0) >> 6)];
-        *it++ = key[*data++ & 0x3F];
+        *it++ = key[(((unsigned char)*data) & 0xFC) >> 2];
+        unsigned char h = (((unsigned char)*data++) & 0x03) << 4;
+        *it++ = key[h | ((((unsigned char)*data) & 0xF0) >> 4)];
+        h = (((unsigned char)*data++) & 0x0F) << 2;
+        *it++ = key[h | ((((unsigned char)*data) & 0xC0) >> 6)];
+        *it++ = key[((unsigned char)*data++) & 0x3F];
 
         size -= 3;
     }
     if (size == 1)
     {
-        *it++ = key[(*data & 0xFC) >> 2];
-        uint8_t h = static_cast<uint8_t>((*data++ & 0x03) << 4);
+        *it++ = key[(((unsigned char)*data) & 0xFC) >> 2];
+        unsigned char h = (((unsigned char)*data++) & 0x03) << 4;
         *it++ = key[h];
         *it++ = '=';
         *it++ = '=';
     }
     else if (size == 2)
     {
-        *it++ = key[(*data & 0xFC) >> 2];
-        uint8_t h = static_cast<uint8_t>((*data++ & 0x03) << 4);
-        *it++ = key[h | ((*data & 0xF0) >> 4)];
-        h = static_cast<uint8_t>((*data++ & 0x0F) << 2);
+        *it++ = key[(((unsigned char)*data) & 0xFC) >> 2];
+        unsigned char h = (((unsigned char)*data++) & 0x03) << 4;
+        *it++ = key[h | ((((unsigned char)*data) & 0xF0) >> 4)];
+        h = (((unsigned char)*data++) & 0x0F) << 2;
         *it++ = key[h];
         *it++ = '=';
     }
     return ret;
 }
 
-inline static std::string base64encodeUrlsafe(const uint8_t* data, size_t size)
+inline static std::string base64encodeUrlsafe(const char* data, size_t size)
 {
     return base64encode(
         data, size,
@@ -669,14 +669,10 @@
 
 inline void escapeHtml(std::string& data)
 {
-    if (data.empty())
-    {
-        return;
-    }
     std::string buffer;
-    // less than 10% of characters should be larger, so reserve a buffer of the
+    // less than 5% of characters should be larger, so reserve a buffer of the
     // right size
-    buffer.reserve(data.size() * 11 / 10);
+    buffer.reserve(data.size() * 1.05);
     for (size_t pos = 0; pos != data.size(); ++pos)
     {
         switch (data[pos])
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index cddafc8..1b82697 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -150,7 +150,7 @@
             nlohmann::json::iterator paths = j.find("paths");
             if (paths != j.end())
             {
-                size_t interfaceCount = thisSession.interfaces.size();
+                int interfaceCount = thisSession.interfaces.size();
                 if (interfaceCount == 0)
                 {
                     interfaceCount = 1;
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index 947bc86..e45bb9a 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -48,8 +48,8 @@
                                  std::string& result)
 {
     int count = 0;
-    std::string::const_iterator first = path.begin();
-    std::string::const_iterator last = path.end();
+    auto first = path.begin();
+    auto last = path.end();
     for (auto it = path.begin(); it < path.end(); it++)
     {
         // skip first character as it's either a leading slash or the first
@@ -80,8 +80,7 @@
     {
         first++;
     }
-    result = path.substr(static_cast<size_t>(first - path.begin()),
-                         static_cast<size_t>(last - first));
+    result = path.substr(first - path.begin(), last - first);
     return true;
 }
 
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index e596920..ab35bb2 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -570,9 +570,8 @@
             {
                 return -1;
             }
-            r = sd_bus_message_append_basic(
-                m, argCode[0],
-                reinterpret_cast<const void *>(stringValue->c_str()));
+            r = sd_bus_message_append_basic(m, argCode[0],
+                                            (void *)stringValue->c_str());
             if (r < 0)
             {
                 return r;
@@ -738,13 +737,13 @@
             }
 
             nlohmann::json::const_iterator it = j->begin();
-            for (const std::string &argCode2 : dbusArgSplit(arg_type))
+            for (const std::string &argCode : dbusArgSplit(arg_type))
             {
                 if (it == j->end())
                 {
                     return -1;
                 }
-                r = convertJsonToDbus(m, argCode2, *it);
+                r = convertJsonToDbus(m, argCode, *it);
                 if (r < 0)
                 {
                     return r;
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index 1469aef..f211a29 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -25,7 +25,7 @@
     std::strcpy(pass, appPass);
 
     *resp = reinterpret_cast<pam_response*>(
-        calloc(static_cast<size_t>(numMsg), sizeof(struct pam_response)));
+        calloc(numMsg, sizeof(struct pam_response)));
 
     if (resp == nullptr)
     {
diff --git a/include/persistent_data_middleware.hpp b/include/persistent_data_middleware.hpp
index 4cd75e8..b384f02 100644
--- a/include/persistent_data_middleware.hpp
+++ b/include/persistent_data_middleware.hpp
@@ -24,7 +24,7 @@
 {
     // todo(ed) should read this from a fixed location somewhere, not CWD
     static constexpr const char* filename = "bmcweb_persistent_data.json";
-    uint64_t jsonRevision = 1;
+    int jsonRevision = 1;
 
   public:
     struct Context
@@ -58,7 +58,7 @@
     void readData()
     {
         std::ifstream persistentFile(filename);
-        uint64_t fileRevision = 0;
+        int fileRevision = 0;
         if (persistentFile.is_open())
         {
             // call with exceptions disabled
diff --git a/include/sessions.hpp b/include/sessions.hpp
index d55b199..6bc1c99 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -119,22 +119,22 @@
         // https://www.owasp.org/index.php/Session_Management_Cheat_Sheet#Session_ID_Entropy
         std::string sessionToken;
         sessionToken.resize(20, '0');
-        std::uniform_int_distribution<size_t> dist(0, alphanum.size() - 1);
-        for (size_t i = 0; i < sessionToken.size(); ++i)
+        std::uniform_int_distribution<int> dist(0, alphanum.size() - 1);
+        for (int i = 0; i < sessionToken.size(); ++i)
         {
             sessionToken[i] = alphanum[dist(rd)];
         }
         // Only need csrf tokens for cookie based auth, token doesn't matter
         std::string csrfToken;
         csrfToken.resize(20, '0');
-        for (size_t i = 0; i < csrfToken.size(); ++i)
+        for (int i = 0; i < csrfToken.size(); ++i)
         {
             csrfToken[i] = alphanum[dist(rd)];
         }
 
         std::string uniqueId;
         uniqueId.resize(10, '0');
-        for (size_t i = 0; i < uniqueId.size(); ++i)
+        for (int i = 0; i < uniqueId.size(); ++i)
         {
             uniqueId[i] = alphanum[dist(rd)];
         }
@@ -205,7 +205,7 @@
     {
         return needWrite;
     }
-    long getTimeoutInSeconds() const
+    int getTimeoutInSeconds() const
     {
         return std::chrono::seconds(timeoutInMinutes).count();
     };
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index 133d40d..34a7c04 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -17,7 +17,9 @@
 namespace ensuressl
 {
 static void initOpenssl();
-static EVP_PKEY *createKey();
+static void cleanupOpenssl();
+static EVP_PKEY *createRsaKey();
+static EVP_PKEY *createEcKey();
 static void handleOpensslError();
 
 inline bool verifyOpensslKeyCert(const std::string &filepath)
@@ -108,7 +110,7 @@
     // EVP_PKEY *pRsaPrivKey = create_rsa_key();
 
     std::cerr << "Generating EC key\n";
-    EVP_PKEY *pRsaPrivKey = createKey();
+    EVP_PKEY *pRsaPrivKey = createEcKey();
     if (pRsaPrivKey != nullptr)
     {
         std::cerr << "Generating x509 Certificate\n";
@@ -175,16 +177,9 @@
 
     // cleanup_openssl();
 }
-EVP_PKEY *createKey()
+
+EVP_PKEY *createRsaKey()
 {
-    EVP_PKEY *pKey = NULL;
-    pKey = EVP_PKEY_new();
-    if (pKey == nullptr)
-    {
-        handleOpensslError();
-        return nullptr;
-    }
-#if BMCWEB_RSA_KEY
     RSA *pRSA = NULL;
 #if OPENSSL_VERSION_NUMBER < 0x00908000L
     pRSA = RSA_generate_key(2048, RSA_3, NULL, NULL);
@@ -192,54 +187,60 @@
     RSA_generate_key_ex(pRSA, 2048, NULL, NULL);
 #endif
 
-    if ((pRSA != nullptr) || EVP_PKEY_assign_RSA(pKey, pRSA) != 1)
+    EVP_PKEY *pKey = EVP_PKEY_new();
+    if ((pRSA != nullptr) && (pKey != nullptr) &&
+        EVP_PKEY_assign_RSA(pKey, pRSA))
+    {
+        /* pKey owns pRSA from now */
+        if (RSA_check_key(pRSA) <= 0)
+        {
+            fprintf(stderr, "RSA_check_key failed.\n");
+            handleOpensslError();
+            EVP_PKEY_free(pKey);
+            pKey = NULL;
+        }
+    }
+    else
     {
         handleOpensslError();
         if (pRSA != nullptr)
         {
             RSA_free(pRSA);
+            pRSA = NULL;
         }
         if (pKey != nullptr)
         {
             EVP_PKEY_free(pKey);
+            pKey = NULL;
         }
-        return nullptr;
     }
+    return pKey;
+}
 
-    /* pKey owns pRSA from now */
-    if (RSA_check_key(pRSA) != 1)
-    {
-        fprintf(stderr, "RSA_check_key failed.\n");
-        handleOpensslError();
-        EVP_PKEY_free(pKey);
-        return nullptr;
-    }
+EVP_PKEY *createEcKey()
+{
+    EVP_PKEY *pKey = NULL;
+    int eccgrp = 0;
+    eccgrp = OBJ_txt2nid("prime256v1");
 
-#else
-    int eccgrp = OBJ_txt2nid("prime256v1");
     EC_KEY *myecc = EC_KEY_new_by_curve_name(eccgrp);
-    if (myecc == nullptr)
+    if (myecc != nullptr)
     {
-        handleOpensslError();
-        return nullptr;
+        EC_KEY_set_asn1_flag(myecc, OPENSSL_EC_NAMED_CURVE);
+        EC_KEY_generate_key(myecc);
+        pKey = EVP_PKEY_new();
+        if (pKey != nullptr)
+        {
+            if (EVP_PKEY_assign_EC_KEY(pKey, myecc))
+            {
+                /* pKey owns pRSA from now */
+                if (EC_KEY_check_key(myecc) <= 0)
+                {
+                    fprintf(stderr, "EC_check_key failed.\n");
+                }
+            }
+        }
     }
-
-    EC_KEY_set_asn1_flag(myecc, OPENSSL_EC_NAMED_CURVE);
-    if (EC_KEY_generate_key(myecc) != 1)
-    {
-        handleOpensslError();
-        EC_KEY_free(myecc);
-        return nullptr;
-    }
-
-    if (EVP_PKEY_assign_EC_KEY(pKey, myecc) != 1)
-    {
-        handleOpensslError();
-        EC_KEY_free(myecc);
-        return nullptr;
-    }
-
-#endif
     return pKey;
 }
 
@@ -252,6 +253,16 @@
 #endif
 }
 
+void cleanupOpenssl()
+{
+    CRYPTO_cleanup_all_ex_data();
+    ERR_free_strings();
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+    ERR_remove_thread_state(0);
+#endif
+    EVP_cleanup();
+}
+
 void handleOpensslError()
 {
     ERR_print_errors_fp(stderr);
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"};