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/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;
}