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/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,