Enable readability-implicit-bool-conversion checks
These checks ensure that we're not implicitly converting ints or
pointers into bools, which makes the code easier to read.
Tested:
Ran series through redfish service validator. No changes observed.
UUID failing in Qemu both before and after.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I1ca0be980d136bd4e5474341f4fd62f2f6bbdbae
diff --git a/.clang-tidy b/.clang-tidy
index 0027680..9958891 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -275,6 +275,7 @@
readability-delete-null-pointer,
readability-deleted-default,
readability-else-after-return,
+readability-implicit-bool-conversion,
readability-named-parameter,
readability-redundant-control-flow,
readability-redundant-declaration,
diff --git a/http/routing.hpp b/http/routing.hpp
index 9032b14..8fd4558 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -673,9 +673,10 @@
bool isSimpleNode() const
{
- return !ruleIndex && std::all_of(std::begin(paramChildrens),
- std::end(paramChildrens),
- [](size_t x) { return !x; });
+ return ruleIndex == 0 &&
+ std::all_of(std::begin(paramChildrens),
+ std::end(paramChildrens),
+ [](size_t x) { return x == 0U; });
}
};
@@ -687,7 +688,7 @@
{
for (size_t x : node->paramChildrens)
{
- if (!x)
+ if (x == 0u)
{
continue;
}
@@ -801,14 +802,14 @@
auto updateFound =
[&found, &matchParams](std::pair<unsigned, RoutingParams>& ret) {
- if (ret.first && (!found || found > ret.first))
+ if (ret.first != 0U && (found == 0U || found > ret.first))
{
found = ret.first;
matchParams = std::move(ret.second);
}
};
- if (node->paramChildrens[static_cast<size_t>(ParamType::INT)])
+ if (node->paramChildrens[static_cast<size_t>(ParamType::INT)] != 0U)
{
char c = reqUrl[pos];
if ((c >= '0' && c <= '9') || c == '+' || c == '-')
@@ -831,7 +832,7 @@
}
}
- if (node->paramChildrens[static_cast<size_t>(ParamType::UINT)])
+ if (node->paramChildrens[static_cast<size_t>(ParamType::UINT)] != 0U)
{
char c = reqUrl[pos];
if ((c >= '0' && c <= '9') || c == '+')
@@ -854,7 +855,7 @@
}
}
- if (node->paramChildrens[static_cast<size_t>(ParamType::DOUBLE)])
+ if (node->paramChildrens[static_cast<size_t>(ParamType::DOUBLE)] != 0U)
{
char c = reqUrl[pos];
if ((c >= '0' && c <= '9') || c == '+' || c == '-' || c == '.')
@@ -876,7 +877,7 @@
}
}
- if (node->paramChildrens[static_cast<size_t>(ParamType::STRING)])
+ if (node->paramChildrens[static_cast<size_t>(ParamType::STRING)] != 0U)
{
size_t epos = pos;
for (; epos < reqUrl.size(); epos++)
@@ -901,7 +902,7 @@
}
}
- if (node->paramChildrens[static_cast<size_t>(ParamType::PATH)])
+ if (node->paramChildrens[static_cast<size_t>(ParamType::PATH)] != 0U)
{
size_t epos = reqUrl.size();
@@ -960,7 +961,7 @@
if (url.compare(i, x.second.size(), x.second) == 0)
{
size_t index = static_cast<size_t>(x.first);
- if (!nodes[idx].paramChildrens[index])
+ if (nodes[idx].paramChildrens[index] == 0U)
{
unsigned newNodeIdx = newNode();
nodes[idx].paramChildrens[index] = newNodeIdx;
@@ -976,7 +977,7 @@
else
{
std::string piece(&c, 1);
- if (!nodes[idx].children.count(piece))
+ if (nodes[idx].children.count(piece) == 0U)
{
unsigned newNodeIdx = newNode();
nodes[idx].children.emplace(piece, newNodeIdx);
@@ -984,7 +985,7 @@
idx = nodes[idx].children[piece];
}
}
- if (nodes[idx].ruleIndex)
+ if (nodes[idx].ruleIndex != 0U)
{
throw std::runtime_error("handler already exists for " + url);
}
@@ -996,7 +997,7 @@
{
for (size_t i = 0; i < static_cast<size_t>(ParamType::MAX); i++)
{
- if (n->paramChildrens[i])
+ if (n->paramChildrens[i] != 0U)
{
BMCWEB_LOG_DEBUG << std::string(
2U * level, ' ') /*<< "("<<n->paramChildrens[i]<<") "*/;
@@ -1097,7 +1098,7 @@
for (size_t method = 0, methodBit = 1; method < maxHttpVerbCount;
method++, methodBit <<= 1)
{
- if (ruleObject->methodsBitfield & methodBit)
+ if ((ruleObject->methodsBitfield & methodBit) > 0U)
{
perMethods[method].rules.emplace_back(ruleObject);
perMethods[method].trie.add(
@@ -1153,7 +1154,7 @@
const std::pair<unsigned, RoutingParams>& found = trie.find(req.url);
unsigned ruleIndex = found.first;
- if (!ruleIndex)
+ if (ruleIndex == 0U)
{
BMCWEB_LOG_DEBUG << "Cannot match rules " << req.url;
res.result(boost::beast::http::status::not_found);
@@ -1246,7 +1247,7 @@
unsigned ruleIndex = found.first;
- if (!ruleIndex)
+ if (ruleIndex == 0U)
{
// Check to see if this url exists at any verb
for (const PerMethod& p : perMethods)
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 9bc79ad..8519b5a 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -31,7 +31,7 @@
inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
sd_bus_error* retError)
{
- if (retError == nullptr || sd_bus_error_is_set(retError))
+ if (retError == nullptr || (sd_bus_error_is_set(retError) != 0))
{
BMCWEB_LOG_ERROR << "Got sdbus error on match";
return 0;
diff --git a/include/hostname_monitor.hpp b/include/hostname_monitor.hpp
index 30186b6..73c315f 100644
--- a/include/hostname_monitor.hpp
+++ b/include/hostname_monitor.hpp
@@ -35,7 +35,7 @@
inline int onPropertyUpdate(sd_bus_message* m, void* /* userdata */,
sd_bus_error* retError)
{
- if (retError == nullptr || sd_bus_error_is_set(retError))
+ if (retError == nullptr || (sd_bus_error_is_set(retError) != 0))
{
BMCWEB_LOG_ERROR << "Got sdbus error on match";
return 0;
@@ -101,7 +101,7 @@
ASN1_IA5STRING* asn1 = static_cast<ASN1_IA5STRING*>(
X509_get_ext_d2i(cert, NID_netscape_comment, nullptr, nullptr));
- if (asn1)
+ if (asn1 != nullptr)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
std::string_view comment(reinterpret_cast<const char*>(asn1->data),
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index 740e218..3970992 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -53,7 +53,7 @@
for (const char c : value)
{
// Keep alphanumeric and other accepted characters intact
- if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~')
+ if ((isalnum(c) != 0) || c == '-' || c == '_' || c == '.' || c == '~')
{
escaped << c;
continue;
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index b39bada..7dccbd8 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -279,7 +279,7 @@
{
for (const auto& id : refRids)
{
- if (lockTable.erase(id))
+ if (lockTable.erase(id) != 0U)
{
BMCWEB_LOG_DEBUG << "Removing the locks with transaction ID : "
<< id;
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 6861571..b457935 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -656,16 +656,16 @@
else if (argCode == "b")
{
// lots of ways bool could be represented here. Try them all
- int boolInt = false;
+ int boolInt = 0;
if (intValue != nullptr)
{
if (*intValue == 1)
{
- boolInt = true;
+ boolInt = 1;
}
else if (*intValue == 0)
{
- boolInt = false;
+ boolInt = 0;
}
else
{
@@ -1025,7 +1025,7 @@
while (true)
{
- r = sd_bus_message_at_end(m.get(), false);
+ r = sd_bus_message_at_end(m.get(), 0);
if (r < 0)
{
BMCWEB_LOG_ERROR << "sd_bus_message_at_end failed";
@@ -1483,7 +1483,7 @@
transaction->methodFailed = true;
const sd_bus_error* e = m2.get_error();
- if (e)
+ if (e != nullptr)
{
setErrorResponse(
transaction->res,
@@ -2002,10 +2002,12 @@
boost::beast::http::
status::
forbidden,
- (e) ? e->name
+ (e) != nullptr
+ ? e->name
: ec.category()
.name(),
- (e) ? e->message
+ (e) != nullptr
+ ? e->message
: ec.message());
}
else
diff --git a/include/security_headers.hpp b/include/security_headers.hpp
index 966fbdf..828a44c 100644
--- a/include/security_headers.hpp
+++ b/include/security_headers.hpp
@@ -25,7 +25,7 @@
"mode=block");
res.addHeader("X-Content-Type-Options", "nosniff");
- if (!bmcwebInsecureDisableXssPrevention)
+ if (bmcwebInsecureDisableXssPrevention == 0)
{
res.addHeader("Content-Security-Policy", "default-src 'none'; "
"img-src 'self' data:; "
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index fcb79f2..30145f8 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -40,7 +40,7 @@
{
// Create an empty X509_STORE structure for certificate validation.
X509_STORE* x509Store = X509_STORE_new();
- if (!x509Store)
+ if (x509Store == nullptr)
{
BMCWEB_LOG_ERROR << "Error occurred during X509_STORE_new call";
return false;
@@ -48,7 +48,7 @@
// Load Certificate file into the X509 structure.
X509_STORE_CTX* storeCtx = X509_STORE_CTX_new();
- if (!storeCtx)
+ if (storeCtx == nullptr)
{
BMCWEB_LOG_ERROR << "Error occurred during X509_STORE_CTX_new call";
X509_STORE_free(x509Store);
@@ -147,7 +147,7 @@
EVP_PKEY_CTX* pkeyCtx =
EVP_PKEY_CTX_new_from_pkey(nullptr, pkey, nullptr);
- if (!pkeyCtx)
+ if (pkeyCtx == nullptr)
{
std::cerr << "Unable to allocate pkeyCtx " << ERR_get_error()
<< "\n";
@@ -198,7 +198,7 @@
inline X509* loadCert(const std::string& filePath)
{
BIO* certFileBio = BIO_new_file(filePath.c_str(), "rb");
- if (!certFileBio)
+ if (certFileBio == nullptr)
{
BMCWEB_LOG_ERROR << "Error occured during BIO_new_file call, "
<< "FILE= " << filePath;
@@ -206,7 +206,7 @@
}
X509* cert = X509_new();
- if (!cert)
+ if (cert == nullptr)
{
BMCWEB_LOG_ERROR << "Error occured during X509_new call, "
<< ERR_get_error();
@@ -214,7 +214,7 @@
return nullptr;
}
- if (!PEM_read_bio_X509(certFileBio, &cert, nullptr, nullptr))
+ if (PEM_read_bio_X509(certFileBio, &cert, nullptr, nullptr) == nullptr)
{
BMCWEB_LOG_ERROR << "Error occured during PEM_read_bio_X509 call, "
<< "FILE= " << filePath;
@@ -235,7 +235,7 @@
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
ex = X509V3_EXT_conf_nid(nullptr, &ctx, nid, const_cast<char*>(value));
- if (!ex)
+ if (ex == nullptr)
{
BMCWEB_LOG_ERROR << "Error: In X509V3_EXT_conf_nidn: " << value;
return -1;
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index 2a0353b..6b7d9e7 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -42,7 +42,7 @@
// boost::process::child::terminate uses SIGKILL, need to send SIGTERM
// to allow the proxy to stop nbd-client and the USB device gadget.
int rc = kill(proxy.id(), SIGTERM);
- if (rc)
+ if (rc != 0)
{
return;
}
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 55485c6..051e495 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -95,7 +95,7 @@
std::span<const MessageEntry>::iterator messageIt =
std::find_if(registry.begin(), registry.end(),
[&messageKey](const MessageEntry& messageEntry) {
- return !messageKey.compare(messageEntry.first);
+ return messageKey.compare(messageEntry.first) == 0;
});
if (messageIt != registry.end())
{
@@ -708,7 +708,7 @@
std::string id;
int retry = 3;
- while (retry)
+ while (retry != 0)
{
id = std::to_string(dist(gen));
if (gen.error())
@@ -764,7 +764,7 @@
if (serviceEnabled != cfg.enabled)
{
serviceEnabled = cfg.enabled;
- if (serviceEnabled && noOfMetricReportSubscribers)
+ if (serviceEnabled && noOfMetricReportSubscribers != 0U)
{
registerMetricReportSignal();
}
@@ -827,7 +827,7 @@
if (noOfMetricReportSubscribers != metricReportSubCount)
{
noOfMetricReportSubscribers = metricReportSubCount;
- if (noOfMetricReportSubscribers)
+ if (noOfMetricReportSubscribers != 0U)
{
registerMetricReportSignal();
}
@@ -860,7 +860,7 @@
std::string id;
int retry = 3;
- while (retry)
+ while (retry != 0)
{
id = std::to_string(dist(gen));
if (gen.error())
@@ -989,7 +989,7 @@
void sendEvent(const nlohmann::json& eventMessageIn,
const std::string& origin, const std::string& resType)
{
- if (!serviceEnabled || !noOfEventLogSubscribers)
+ if (!serviceEnabled || (noOfEventLogSubscribers == 0u))
{
BMCWEB_LOG_DEBUG << "EventService disabled or no Subscriptions.";
return;
@@ -1122,7 +1122,7 @@
continue;
}
- if (!serviceEnabled || !noOfEventLogSubscribers)
+ if (!serviceEnabled || noOfEventLogSubscribers == 0)
{
// If Service is not enabled, no need to compute
// the remaining items below.
@@ -1153,7 +1153,7 @@
messageKey, messageArgs);
}
- if (!serviceEnabled || !noOfEventLogSubscribers)
+ if (!serviceEnabled || noOfEventLogSubscribers == 0)
{
BMCWEB_LOG_DEBUG << "EventService disabled or no Subscriptions.";
return;
@@ -1340,7 +1340,7 @@
const telemetry::TimestampReadings* readings =
std::get_if<telemetry::TimestampReadings>(&found->second);
- if (!readings)
+ if (readings == nullptr)
{
BMCWEB_LOG_INFO << "Failed to get Readings from Report properties";
return;
diff --git a/redfish-core/include/gzfile.hpp b/redfish-core/include/gzfile.hpp
index 2001756..567741d 100644
--- a/redfish-core/include/gzfile.hpp
+++ b/redfish-core/include/gzfile.hpp
@@ -13,7 +13,7 @@
std::vector<std::string>& logEntries, size_t& logCount)
{
gzFile logStream = gzopen(filename.c_str(), "r");
- if (!logStream)
+ if (logStream == nullptr)
{
BMCWEB_LOG_ERROR << "Can't open gz file: " << filename << '\n';
return false;
@@ -71,7 +71,7 @@
BMCWEB_LOG_ERROR << "Error occurs during parsing host log.\n";
return false;
}
- } while (!gzeof(logStream));
+ } while (gzeof(logStream) != 1);
return true;
}
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index df7279e..232f51c 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -1142,7 +1142,7 @@
[dbusObjectPath, username, password(std::move(password)),
roleId(std::move(roleId)), enabled, locked,
asyncResp{std::move(asyncResp)}](int rc) {
- if (!rc)
+ if (rc <= 0)
{
messages::resourceNotFound(
asyncResp->res, "#ManagerAccount.v1_4_0.ManagerAccount",
@@ -1727,7 +1727,8 @@
const std::pair<sdbusplus::message::object_path,
dbus::utility::DBusInteracesMap>&
user) {
- return !accountName.compare(user.first.filename());
+ return accountName.compare(user.first.filename()) ==
+ 0;
});
if (userIt == users.end())
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 23e3ead..4adaf0b 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -154,7 +154,7 @@
'e', 'r', 't', 's', '.', 'X',
'X', 'X', 'X', 'X', 'X', '\0'};
char* tempDirectory = mkdtemp(dirTemplate.data());
- if (tempDirectory)
+ if (tempDirectory != nullptr)
{
certDirectory = tempDirectory;
certificateFile = certDirectory / "cert.pem";
@@ -596,7 +596,7 @@
asyncResp->res.jsonValue["CertificateString"] = "";
const std::string* value =
std::get_if<std::string>(&property.second);
- if (value)
+ if (value != nullptr)
{
asyncResp->res.jsonValue["CertificateString"] = *value;
}
@@ -608,7 +608,7 @@
keyUsage = nlohmann::json::array();
const std::vector<std::string>* value =
std::get_if<std::vector<std::string>>(&property.second);
- if (value)
+ if (value != nullptr)
{
for (const std::string& usage : *value)
{
@@ -620,7 +620,7 @@
{
const std::string* value =
std::get_if<std::string>(&property.second);
- if (value)
+ if (value != nullptr)
{
updateCertIssuerOrSubject(
asyncResp->res.jsonValue["Issuer"], *value);
@@ -630,7 +630,7 @@
{
const std::string* value =
std::get_if<std::string>(&property.second);
- if (value)
+ if (value != nullptr)
{
updateCertIssuerOrSubject(
asyncResp->res.jsonValue["Subject"], *value);
@@ -640,7 +640,7 @@
{
const uint64_t* value =
std::get_if<uint64_t>(&property.second);
- if (value)
+ if (value != nullptr)
{
asyncResp->res.jsonValue["ValidNotAfter"] =
crow::utility::getDateTimeUint(*value);
@@ -650,7 +650,7 @@
{
const uint64_t* value =
std::get_if<uint64_t>(&property.second);
- if (value)
+ if (value != nullptr)
{
asyncResp->res.jsonValue["ValidNotBefore"] =
crow::utility::getDateTimeUint(*value);
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 5283fff..9b1aa43 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -685,7 +685,7 @@
// Count bits
for (long bitIdx = 7; bitIdx >= 0; bitIdx--)
{
- if (value & (1L << bitIdx))
+ if ((value & (1L << bitIdx)) != 0)
{
if (firstZeroInByteHit)
{
@@ -2355,7 +2355,7 @@
return;
}
// Need both vlanId and vlanEnable to service this request
- if (!vlanId)
+ if (vlanId == 0u)
{
messages::propertyMissing(asyncResp->res, "VLANId");
}
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 6088758..9ce2f05 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -359,7 +359,7 @@
if (value == nullptr)
{
messages::propertyValueFormatError(
- asyncResp->res, item.value().dump(2, true),
+ asyncResp->res, item.value().dump(2, 1),
"HttpHeaders/" + item.key());
return;
}
@@ -432,7 +432,8 @@
registry.begin(), registry.end(),
[&id](const redfish::message_registries::
MessageEntry& messageEntry) {
- return !id.compare(messageEntry.first);
+ return id.compare(messageEntry.first) ==
+ 0;
}))
{
validId = true;
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 84e6b34..b2c5d4c 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -65,7 +65,7 @@
std::span<const MessageEntry>::iterator messageIt = std::find_if(
registry.begin(), registry.end(),
[&messageKey](const MessageEntry& messageEntry) {
- return !std::strcmp(messageEntry.first, messageKey.c_str());
+ return std::strcmp(messageEntry.first, messageKey.c_str()) == 0;
});
if (messageIt != registry.end())
{
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index c69af7e..549ab2d 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -500,7 +500,7 @@
{
values = ptr;
}
- if (keys && values)
+ if (keys != nullptr && values != nullptr)
{
if (keys->size() != values->size())
{
@@ -913,7 +913,7 @@
return CreatePIDRet::fail;
}
if (chassis.empty() &&
- !findChassis(managedObj, zonesStr[0], chassis))
+ findChassis(managedObj, zonesStr[0], chassis) == nullptr)
{
BMCWEB_LOG_ERROR << "Failed to get chassis from config patch";
messages::invalidObject(response->res, it.key());
@@ -1078,7 +1078,7 @@
return CreatePIDRet::fail;
}
if (chassis.empty() &&
- !findChassis(managedObj, zonesStrs[0], chassis))
+ findChassis(managedObj, zonesStrs[0], chassis) == nullptr)
{
BMCWEB_LOG_ERROR << "Failed to get chassis from config patch";
messages::invalidObject(response->res, it.key());
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index 541e631..4ac4c77 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -66,8 +66,9 @@
interval = std::get_if<uint64_t>(&var);
}
}
- if (!emitsReadingsUpdate || !logToMetricReportsCollection ||
- !readingParams || !reportingType || !interval)
+ if (emitsReadingsUpdate == nullptr ||
+ logToMetricReportsCollection == nullptr || readingParams == nullptr ||
+ reportingType == nullptr || interval == nullptr)
{
BMCWEB_LOG_ERROR << "Property type mismatch or property is missing";
messages::internalError(asyncResp->res);
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index ad3ca8e..48f22b7 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -172,8 +172,8 @@
std::string interfaceChassisName =
chassis.substr(lastPos + 1, len);
- if (!interfaceChassisName.compare(
- sensorAsyncResp->chassisId))
+ if (interfaceChassisName.compare(
+ sensorAsyncResp->chassisId) == 0)
{
found = true;
break;
@@ -231,17 +231,17 @@
dbus::utility::DbusVariantType>&
property : properties)
{
- if (!property.first.compare("Scale"))
+ if (property.first.compare("Scale") == 0)
{
const int64_t* i =
std::get_if<int64_t>(&property.second);
- if (i)
+ if (i != nullptr)
{
scale = *i;
}
}
- else if (!property.first.compare("PowerCap"))
+ else if (property.first.compare("PowerCap") == 0)
{
const double* d =
std::get_if<double>(&property.second);
@@ -250,25 +250,26 @@
const uint32_t* u =
std::get_if<uint32_t>(&property.second);
- if (d)
+ if (d != nullptr)
{
powerCap = *d;
}
- else if (i)
+ else if (i != nullptr)
{
powerCap = static_cast<double>(*i);
}
- else if (u)
+ else if (u != nullptr)
{
powerCap = *u;
}
}
- else if (!property.first.compare("PowerCapEnable"))
+ else if (property.first.compare("PowerCapEnable") ==
+ 0)
{
const bool* b =
std::get_if<bool>(&property.second);
- if (b)
+ if (b != nullptr)
{
enabled = *b;
}
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 4d4b4cc..a53c112 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -965,7 +965,7 @@
std::string sensorNameLower =
boost::algorithm::to_lower_copy(sensorName);
- if (!sensorName.compare("total_power"))
+ if (sensorName.compare("total_power") == 0)
{
sensorJson["@odata.type"] = "#Power.v1_0_0.PowerControl";
// Put multiple "sensors" into a single PowerControl, so have
@@ -2551,7 +2551,7 @@
}
else if (sensorType == "power")
{
- if (!sensorName.compare("total_power"))
+ if (sensorName.compare("total_power") == 0)
{
fieldName = "PowerControl";
}
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index d680537..62bd11b 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -176,7 +176,7 @@
const uint16_t* coreCountVal =
std::get_if<uint16_t>(&property.second);
- if (!coreCountVal)
+ if (coreCountVal == nullptr)
{
messages::internalError(aResp->res);
return;
@@ -1574,7 +1574,8 @@
// Source target specified
BMCWEB_LOG_DEBUG << "Boot source: " << *bootSource;
// Figure out which DBUS interface and property to use
- if (assignBootParameters(aResp, *bootSource, bootSourceStr, bootModeStr))
+ if (assignBootParameters(aResp, *bootSource, bootSourceStr, bootModeStr) !=
+ 0)
{
BMCWEB_LOG_DEBUG
<< "Invalid property value for BootSourceOverrideTarget: "
@@ -2238,7 +2239,7 @@
{
const bool* state = std::get_if<bool>(&property.second);
- if (!state)
+ if (state == nullptr)
{
messages::internalError(aResp->res);
return;
@@ -2250,7 +2251,7 @@
{
const std::string* s =
std::get_if<std::string>(&property.second);
- if (!s)
+ if (s == nullptr)
{
messages::internalError(aResp->res);
return;
@@ -2353,7 +2354,7 @@
if (property.first == "Enabled")
{
const bool* state = std::get_if<bool>(&property.second);
- if (!state)
+ if (state == nullptr)
{
return false;
}
@@ -2362,7 +2363,7 @@
else if (property.first == "EnterUtilizationPercent")
{
const uint8_t* util = std::get_if<uint8_t>(&property.second);
- if (!util)
+ if (util == nullptr)
{
return false;
}
@@ -2373,7 +2374,7 @@
// Convert Dbus time from milliseconds to seconds
const uint64_t* timeMilliseconds =
std::get_if<uint64_t>(&property.second);
- if (!timeMilliseconds)
+ if (timeMilliseconds == nullptr)
{
return false;
}
@@ -2386,7 +2387,7 @@
else if (property.first == "ExitUtilizationPercent")
{
const uint8_t* util = std::get_if<uint8_t>(&property.second);
- if (!util)
+ if (util == nullptr)
{
return false;
}
@@ -2397,7 +2398,7 @@
// Convert Dbus time from milliseconds to seconds
const uint64_t* timeMilliseconds =
std::get_if<uint64_t>(&property.second);
- if (!timeMilliseconds)
+ if (timeMilliseconds == nullptr)
{
return false;
}
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
index 5457530..421985a 100644
--- a/redfish-core/lib/telemetry_service.hpp
+++ b/redfish-core/lib/telemetry_service.hpp
@@ -58,7 +58,7 @@
minInterval = std::get_if<uint64_t>(&var);
}
}
- if (!maxReports || !minInterval)
+ if (maxReports == nullptr || minInterval == nullptr)
{
BMCWEB_LOG_ERROR
<< "Property type mismatch or property is missing";
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index bb0a0e2..cdd5781 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -80,7 +80,7 @@
const std::vector<DiscreteThresholdParams>* discreteParams =
std::get_if<std::vector<DiscreteThresholdParams>>(&thresholdParams);
- if (!discreteParams)
+ if (discreteParams == nullptr)
{
return std::nullopt;
}
@@ -113,7 +113,7 @@
const std::vector<NumericThresholdParams>* numericParams =
std::get_if<std::vector<NumericThresholdParams>>(&thresholdParams);
- if (!numericParams)
+ if (numericParams == nullptr)
{
return std::nullopt;
}
@@ -204,7 +204,8 @@
}
}
- if (!name || !discrete || !sensors || !reports || !actions || !thresholds)
+ if (name == nullptr || discrete == nullptr || sensors == nullptr ||
+ reports == nullptr || actions == nullptr || thresholds == nullptr)
{
BMCWEB_LOG_ERROR
<< "Property type mismatch or property is missing in Trigger: "
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index ab27fc7..9e44e80 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -111,7 +111,7 @@
if (property == "WriteProtected")
{
const bool* writeProtectedValue = std::get_if<bool>(&value);
- if (writeProtectedValue)
+ if (writeProtectedValue != nullptr)
{
aResp->res.jsonValue["WriteProtected"] =
*writeProtectedValue;
@@ -126,7 +126,7 @@
if (property == "Active")
{
const bool* activeValue = std::get_if<bool>(&value);
- if (!activeValue)
+ if (activeValue == nullptr)
{
BMCWEB_LOG_DEBUG << "Value Active not found";
return;
@@ -578,7 +578,7 @@
SecureBuffer pack(FormatterFunc formatter)
{
SecureBuffer packed{new Buffer{}};
- if (formatter)
+ if (formatter != nullptr)
{
formatter(credentials.user(), credentials.password(), *packed);
}
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index b613008..b05161d 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -40,7 +40,7 @@
{
BMCWEB_LOG_INFO << "attempting systemd socket activation";
if (sd_is_socket_inet(SD_LISTEN_FDS_START, AF_UNSPEC, SOCK_STREAM, 1,
- 0))
+ 0) != 0)
{
BMCWEB_LOG_INFO << "Starting webserver on socket handle "
<< SD_LISTEN_FDS_START;
@@ -113,7 +113,7 @@
crow::google_api::requestRoutes(app);
#endif
- if (bmcwebInsecureDisableXssPrevention)
+ if (bmcwebInsecureDisableXssPrevention != 0)
{
cors_preflight::requestRoutes(app);
}
@@ -128,7 +128,7 @@
#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
int rc = redfish::EventServiceManager::startEventLogMonitor(*io);
- if (rc)
+ if (rc != 0)
{
BMCWEB_LOG_ERROR << "Redfish event handler setup failed...";
return rc;