Add readability-redundant-* checks
There's a number of redundancies in our code that clang can sanitize
out. Fix the existing problems, and enable the checks.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ie63d7b7f0777b702fbf1b23a24e1bed7b4f5183b
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 8770782..5530e12 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -1191,7 +1191,7 @@
messages::success(asyncResp->res);
return;
},
- "xyz.openbmc_project.User.Manager", dbusObjectPath.c_str(),
+ "xyz.openbmc_project.User.Manager", dbusObjectPath,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.Attributes", "UserEnabled",
dbus::utility::DbusVariantType{*enabled});
@@ -1221,7 +1221,7 @@
}
messages::success(asyncResp->res);
},
- "xyz.openbmc_project.User.Manager", dbusObjectPath.c_str(),
+ "xyz.openbmc_project.User.Manager", dbusObjectPath,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.Attributes", "UserPrivilege",
dbus::utility::DbusVariantType{priv});
@@ -1250,7 +1250,7 @@
messages::success(asyncResp->res);
return;
},
- "xyz.openbmc_project.User.Manager", dbusObjectPath.c_str(),
+ "xyz.openbmc_project.User.Manager", dbusObjectPath,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.Attributes",
"UserLockedForFailedAttempt",
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index f4260a8..5283fff 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -2188,7 +2188,7 @@
}
};
- if (vlanEnable == true)
+ if (vlanEnable)
{
crow::connections::systemBus->async_method_call(
std::move(callback),
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index 588cf13..645e39f 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -541,7 +541,7 @@
// Set the IPv4 address origin to the DHCP / Static as per the new value
// of the DHCPEnabled property
std::string origin;
- if (ipv4DHCPEnabled == false)
+ if (!ipv4DHCPEnabled)
{
origin = "xyz.openbmc_project.Network.IP.AddressOrigin.Static";
}
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index aa4d5ec..84e6b34 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -676,7 +676,7 @@
entryID + "/attachment";
}
}
- if (foundDumpEntry == false)
+ if (!foundDumpEntry)
{
BMCWEB_LOG_ERROR << "Can't find Dump Entry";
messages::internalError(asyncResp->res);
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index 49304e2..f20681b 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -546,7 +546,7 @@
<< "Invalid property type for Dimm Presence";
return;
}
- if (*value == false)
+ if (!*value)
{
aResp->res.jsonValue["Status"]["State"] = "Absent";
}
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 8e07881..b51a901 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -92,7 +92,7 @@
messages::internalError(aResp->res);
return;
}
- if (*cpuPresent == false)
+ if (!*cpuPresent)
{
// Slot is not populated
aResp->res.jsonValue["Status"]["State"] = "Absent";
@@ -106,7 +106,7 @@
messages::internalError(aResp->res);
return;
}
- if (*cpuFunctional == false)
+ if (!*cpuFunctional)
{
aResp->res.jsonValue["Status"]["Health"] = "Critical";
}
@@ -248,7 +248,7 @@
std::get_if<bool>(&property.second);
if (present != nullptr)
{
- if (*present == true)
+ if (*present)
{
slotPresent = true;
totalCores++;
@@ -442,12 +442,12 @@
std::string state = "Enabled";
std::string health = "OK";
- if (accPresent != nullptr && *accPresent == false)
+ if (accPresent != nullptr && !*accPresent)
{
state = "Absent";
}
- if ((accFunctional != nullptr) && (*accFunctional == false))
+ if ((accFunctional != nullptr) && !*accFunctional)
{
if (state == "Enabled")
{
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index c18942f..6c67a33 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -81,7 +81,7 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& roleId) {
nlohmann::json privArray = nlohmann::json::array();
- if (false == getAssignedPrivFromRole(roleId, privArray))
+ if (!getAssignedPrivFromRole(roleId, privArray))
{
messages::resourceNotFound(asyncResp->res, "Role", roleId);
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index f3fa52c..4d4b4cc 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -284,11 +284,7 @@
class InventoryItem
{
public:
- InventoryItem(const std::string& objPath) :
- objectPath(objPath), name(), isPresent(true), isFunctional(true),
- isPowerSupply(false), powerSupplyEfficiencyPercent(-1), manufacturer(),
- model(), partNumber(), serialNumber(), sensors(), ledObjectPath(""),
- ledState(LedState::UNKNOWN)
+ InventoryItem(const std::string& objPath) : objectPath(objPath)
{
// Set inventory item name to last node of object path
sdbusplus::message::object_path path(objectPath);
@@ -301,17 +297,17 @@
std::string objectPath;
std::string name;
- bool isPresent;
- bool isFunctional;
- bool isPowerSupply;
- int powerSupplyEfficiencyPercent;
+ bool isPresent = true;
+ bool isFunctional = true;
+ bool isPowerSupply = false;
+ int powerSupplyEfficiencyPercent = -1;
std::string manufacturer;
std::string model;
std::string partNumber;
std::string serialNumber;
std::set<std::string> sensors;
std::string ledObjectPath;
- LedState ledState;
+ LedState ledState = LedState::UNKNOWN;
};
/**
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 4cc3d8b..d680537 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -55,7 +55,7 @@
aResp->res.jsonValue["MemorySummary"]["Status"]["State"];
if (prevMemSummary == "Disabled")
{
- if (isDimmFunctional == true)
+ if (isDimmFunctional)
{
aResp->res.jsonValue["MemorySummary"]["Status"]["State"] =
"Enabled";
@@ -114,7 +114,7 @@
// Functional.
if (prevProcState == "Disabled")
{
- if (isCpuFunctional == true)
+ if (isCpuFunctional)
{
aResp->res.jsonValue["ProcessorSummary"]["Status"]["State"] =
"Enabled";
@@ -1129,7 +1129,7 @@
}
BMCWEB_LOG_DEBUG << "Auto Reboot: " << autoRebootEnabled;
- if (autoRebootEnabled == true)
+ if (autoRebootEnabled)
{
aResp->res.jsonValue["Boot"]["AutomaticRetryConfig"] =
"RetryAttempts";
@@ -2490,7 +2490,7 @@
return;
}
- if (parseIpsProperties(aResp, properties) == false)
+ if (!parseIpsProperties(aResp, properties))
{
messages::internalError(aResp->res);
return;
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index ba92748..4b18520 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -263,7 +263,7 @@
int timeoutTimeSeconds = 10)
{
// Only allow one FW update at a time
- if (fwUpdateInProgress != false)
+ if (fwUpdateInProgress)
{
if (asyncResp)
{
@@ -819,7 +819,7 @@
std::string, std::vector<std::string>>>>& obj :
subtree)
{
- if (boost::ends_with(obj.first, *swId) != true)
+ if (!boost::ends_with(obj.first, *swId))
{
continue;
}
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index d646698..ab27fc7 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -133,7 +133,7 @@
}
aResp->res.jsonValue["Inserted"] = *activeValue;
- if (*activeValue == true)
+ if (*activeValue)
{
aResp->res.jsonValue["ConnectedVia"] = "Applet";
}
@@ -400,7 +400,7 @@
}
// optional param inserted must be true
- if ((inserted != std::nullopt) && (*inserted != true))
+ if ((inserted != std::nullopt) && !*inserted)
{
BMCWEB_LOG_ERROR
<< "Request action optional parameter Inserted must be true.";
@@ -814,7 +814,7 @@
actionParams.inserted, actionParams.transferMethod,
actionParams.transferProtocolType);
- if (paramsValid == false)
+ if (!paramsValid)
{
return;
}