diff options
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | http/routing.hpp | 6 | ||||
-rw-r--r-- | http/utility.hpp | 8 | ||||
-rw-r--r-- | include/async_resolve.hpp | 2 | ||||
-rw-r--r-- | include/ibm/locks.hpp | 4 | ||||
-rw-r--r-- | include/ibm/management_console_rest.hpp | 4 | ||||
-rw-r--r-- | include/json_html_serializer.hpp | 4 | ||||
-rw-r--r-- | include/openbmc_dbus_rest.hpp | 2 | ||||
-rw-r--r-- | include/ssl_key_handler.hpp | 6 | ||||
-rw-r--r-- | redfish-core/include/utils/time_utils.hpp | 2 | ||||
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 8 | ||||
-rw-r--r-- | redfish-core/lib/managers.hpp | 4 | ||||
-rw-r--r-- | redfish-core/lib/message_registries.hpp | 4 | ||||
-rw-r--r-- | redfish-core/lib/sensors.hpp | 4 | ||||
-rw-r--r-- | redfish-core/lib/systems.hpp | 4 |
15 files changed, 31 insertions, 32 deletions
diff --git a/.clang-tidy b/.clang-tidy index 6704aff4c5..6f3c69d70a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -201,6 +201,7 @@ clang-analyzer-valist.Unterminated, 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 c8946e4173..06f2a091ba 100644 --- a/http/routing.hpp +++ b/http/routing.hpp @@ -805,7 +805,7 @@ class Trie 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 @@ class Trie 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 @@ class Trie 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 374caeafdd..74a35daed3 100644 --- a/http/utility.hpp +++ b/http/utility.hpp @@ -425,7 +425,7 @@ inline std::string base64encode(const std::string_view data) 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 @@ inline bool base64Decode(const std::string_view input, std::string& output) 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 105616daa6..563d816ce3 100644 --- a/include/async_resolve.hpp +++ b/include/async_resolve.hpp @@ -73,7 +73,7 @@ class Resolver 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 800ee484e8..fb8b396821 100644 --- a/include/ibm/locks.hpp +++ b/include/ibm/locks.hpp @@ -39,7 +39,7 @@ using ListOfSessionIds = std::vector<std::string>; class Lock { - uint32_t transactionId; + uint32_t transactionId = 0; boost::container::flat_map<uint32_t, LockRequests> lockTable; protected: @@ -429,7 +429,7 @@ inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord) 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 59d4111a77..57c9d8328f 100644 --- a/include/ibm/management_console_rest.hpp +++ b/include/ibm/management_console_rest.hpp @@ -418,7 +418,7 @@ inline void 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 @@ inline void 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 be9efc48c7..3efc224444 100644 --- a/include/json_html_serializer.hpp +++ b/include/json_html_serializer.hpp @@ -327,9 +327,9 @@ void dumpInteger(std::string& out, NumberType number) 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 7f16ea8f6a..0b54c6592d 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp @@ -1104,7 +1104,7 @@ inline int readStructFromMessage(const std::string& typeCode, 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 abb1c94917..eb59bee88a 100644 --- a/include/ssl_key_handler.hpp +++ b/include/ssl_key_handler.hpp @@ -256,8 +256,7 @@ inline void generateSslCertificate(const std::string& filepath, { 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 @@ inline void generateSslCertificate(const std::string& filepath, 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 0df641655c..cef8aa5976 100644 --- a/redfish-core/include/utils/time_utils.hpp +++ b/redfish-core/include/utils/time_utils.hpp @@ -43,7 +43,7 @@ bool fromDurationItem(std::string_view& fmt, const char postfix, 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 87351782de..ee8d2cd5b5 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -635,9 +635,9 @@ inline bool ipv4VerifyIpAndGetBitcount(const std::string& ip, *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 @@ inline void handleIPv6StaticAddressesPatch( 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 3a955cb355..ad5c5e3829 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -1092,8 +1092,8 @@ inline CreatePIDRet createPidInterface( 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 ae02189f64..cfa2bf574f 100644 --- a/redfish-core/lib/message_registries.hpp +++ b/redfish-core/lib/message_registries.hpp @@ -62,7 +62,7 @@ inline void handleMessageRoutesMessageRegistryFileGet( 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 @@ inline void handleMessageRegistryGet( 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 6d10bb728a..99dfc8185d 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -2758,10 +2758,10 @@ inline void setSensorsOverride( 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 2605c3f811..e7f4f02ca3 100644 --- a/redfish-core/lib/systems.hpp +++ b/redfish-core/lib/systems.hpp @@ -1728,7 +1728,7 @@ inline void setAutomaticRetry(const std::shared_ptr<bmcweb::AsyncResp>& aResp, BMCWEB_LOG_DEBUG << "Set Automatic Retry."; // OpenBMC only supports "Disabled" and "RetryAttempts". - bool autoRebootEnabled; + bool autoRebootEnabled = false; if (automaticRetryConfig == "Disabled") { @@ -2765,7 +2765,7 @@ inline void requestRoutesSystemActionsReset(App& app) // 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"; |