clang-tidy: Enable bugprone-assignment-in-if
Modified code to address issues flagged by this check.
Tested: Build and unit tests passed successfully.
Change-Id: I3b5f7c29fa38fc39da06e27488d70866006695c9
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>
diff --git a/certificate.cpp b/certificate.cpp
index 67c5aad..5e4ef9c 100644
--- a/certificate.cpp
+++ b/certificate.cpp
@@ -510,12 +510,12 @@
issuer(issuerBuffer);
std::vector<std::string> keyUsageList;
- ASN1_BIT_STRING* usage;
// Go through each usage in the bit string and convert to
// corresponding string value
- if ((usage = static_cast<ASN1_BIT_STRING*>(
- X509_get_ext_d2i(&cert, NID_key_usage, nullptr, nullptr))))
+ ASN1_BIT_STRING* usage = static_cast<ASN1_BIT_STRING*>(
+ X509_get_ext_d2i(&cert, NID_key_usage, nullptr, nullptr));
+ if (usage != nullptr)
{
for (auto i = 0; i < usage->length; ++i)
{
@@ -530,9 +530,9 @@
}
}
- EXTENDED_KEY_USAGE* extUsage;
- if ((extUsage = static_cast<EXTENDED_KEY_USAGE*>(
- X509_get_ext_d2i(&cert, NID_ext_key_usage, nullptr, nullptr))))
+ EXTENDED_KEY_USAGE* extUsage = static_cast<EXTENDED_KEY_USAGE*>(
+ X509_get_ext_d2i(&cert, NID_ext_key_usage, nullptr, nullptr));
+ if (extUsage == nullptr)
{
for (int i = 0; i < sk_ASN1_OBJECT_num(extUsage); i++)
{