summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy1
-rw-r--r--http/http_client.hpp2
-rw-r--r--include/dbus_monitor.hpp2
-rw-r--r--include/dbus_utility.hpp2
-rw-r--r--include/ibm/locks.hpp2
-rw-r--r--include/nbd_proxy.hpp2
-rw-r--r--include/openbmc_dbus_rest.hpp10
-rw-r--r--include/webassets.hpp3
-rw-r--r--redfish-core/include/event_service_manager.hpp12
-rw-r--r--redfish-core/include/utils/fw_utils.hpp2
-rw-r--r--redfish-core/lib/account_service.hpp8
-rw-r--r--redfish-core/lib/certificate_service.hpp6
-rw-r--r--redfish-core/lib/chassis.hpp6
-rw-r--r--redfish-core/lib/ethernet.hpp2
-rw-r--r--redfish-core/lib/event_service.hpp2
-rw-r--r--redfish-core/lib/hypervisor_system.hpp2
-rw-r--r--redfish-core/lib/log_services.hpp6
-rw-r--r--redfish-core/lib/managers.hpp6
-rw-r--r--redfish-core/lib/network_protocol.hpp4
-rw-r--r--redfish-core/lib/pcie.hpp6
-rw-r--r--redfish-core/lib/redfish_util.hpp4
-rw-r--r--redfish-core/lib/sensors.hpp8
-rw-r--r--redfish-core/lib/storage.hpp2
-rw-r--r--redfish-core/lib/systems.hpp10
-rw-r--r--redfish-core/lib/update_service.hpp2
-rw-r--r--redfish-core/lib/virtual_media.hpp2
26 files changed, 57 insertions, 57 deletions
diff --git a/.clang-tidy b/.clang-tidy
index eedc6d8ca4..516ffefadf 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -269,6 +269,7 @@ performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
readability-braces-around-statements,
readability-const-return-type,
+readability-container-size-empty,
readability-delete-null-pointer,
readability-deleted-default,
readability-else-after-return,
diff --git a/http/http_client.hpp b/http/http_client.hpp
index 6aad0da77f..41c09a942a 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -93,7 +93,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient>
const boost::beast::error_code ec,
const std::vector<boost::asio::ip::tcp::endpoint>&
endpointList) {
- if (ec || (endpointList.size() == 0))
+ if (ec || (endpointList.empty()))
{
BMCWEB_LOG_ERROR << "Resolve failed: " << ec.message();
self->state = ConnState::resolveFailed;
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index c8e46b79c9..9bc79ad962 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -200,7 +200,7 @@ inline void requestRoutes(App& app)
"member='PropertiesChanged'");
// If interfaces weren't specified, add a single match for all
// interfaces
- if (thisSession.interfaces.size() == 0)
+ if (thisSession.interfaces.empty())
{
BMCWEB_LOG_DEBUG << "Creating match "
<< propertiesMatchString;
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index 75bda0832f..0ea4887393 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -122,7 +122,7 @@ inline void checkDbusPathExists(const std::string& path, Callback&& callback)
[callback{std::forward<Callback>(callback)}](
const boost::system::error_code ec,
const GetObjectType& objectNames) {
- callback(!ec && objectNames.size() != 0);
+ callback(!ec && !objectNames.empty());
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index 5a86d09dec..45525bffa2 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -299,7 +299,7 @@ inline void Lock::releaseLock(const std::string& sessionId)
auto it = lockTable.begin();
while (it != lockTable.end())
{
- if (it->second.size() != 0)
+ if (!it->second.empty())
{
// Check if session id of this entry matches with session id
// given
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index ed5265d555..3f97f8ccde 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -193,7 +193,7 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
return;
}
- if (ws2uxBuf.size() == 0)
+ if (ws2uxBuf.empty())
{
BMCWEB_LOG_ERROR << "No data to write to UNIX socket";
return;
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index abcec1a982..9233a278f8 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -1562,7 +1562,7 @@ inline void handleAction(const crow::Request& req,
const boost::system::error_code ec,
const std::vector<std::pair<std::string, std::vector<std::string>>>&
interfaceNames) {
- if (ec || interfaceNames.size() <= 0)
+ if (ec || interfaceNames.empty())
{
BMCWEB_LOG_ERROR << "Can't find object";
setErrorResponse(transaction->res,
@@ -1596,7 +1596,7 @@ inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const boost::system::error_code ec,
const std::vector<std::pair<std::string, std::vector<std::string>>>&
interfaceNames) {
- if (ec || interfaceNames.size() <= 0)
+ if (ec || interfaceNames.empty())
{
BMCWEB_LOG_ERROR << "Can't find object";
setErrorResponse(asyncResp->res,
@@ -1701,7 +1701,7 @@ inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
crow::connections::systemBus->async_method_call(
[asyncResp, path, propertyName](const boost::system::error_code ec,
const GetObjectType& objectNames) {
- if (ec || objectNames.size() <= 0)
+ if (ec || objectNames.empty())
{
setErrorResponse(asyncResp->res,
boost::beast::http::status::not_found,
@@ -1718,7 +1718,7 @@ inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::vector<std::string>& interfaceNames =
connection.second;
- if (interfaceNames.size() <= 0)
+ if (interfaceNames.empty())
{
setErrorResponse(asyncResp->res,
boost::beast::http::status::not_found,
@@ -1875,7 +1875,7 @@ inline void handlePut(const crow::Request& req,
crow::connections::systemBus->async_method_call(
[transaction](const boost::system::error_code ec2,
const GetObjectType& objectNames) {
- if (!ec2 && objectNames.size() <= 0)
+ if (!ec2 && objectNames.empty())
{
setErrorResponse(transaction->asyncResp->res,
boost::beast::http::status::not_found,
diff --git a/include/webassets.hpp b/include/webassets.hpp
index f92214fcde..8f41f2f4a8 100644
--- a/include/webassets.hpp
+++ b/include/webassets.hpp
@@ -102,8 +102,7 @@ inline void requestRoutes(App& app)
if (boost::starts_with(webpath.filename().string(), "index."))
{
webpath = webpath.parent_path();
- if (webpath.string().size() == 0 ||
- webpath.string().back() != '/')
+ if (webpath.string().empty() || webpath.string().back() != '/')
{
// insert the non-directory version of this path
webroutes::routes.insert(webpath);
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index ee402b61ee..b8a916c10f 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -183,7 +183,7 @@ inline int getEventLogParams(const std::string& logEntry,
boost::split(logEntryFields, entry, boost::is_any_of(","),
boost::token_compress_on);
// We need at least a MessageId to be valid
- if (logEntryFields.size() < 1)
+ if (logEntryFields.empty())
{
return -EINVAL;
}
@@ -451,7 +451,7 @@ class Subscription : public persistent_data::UserSubscription
// If registryPrefixes list is empty, don't filter events
// send everything.
- if (registryPrefixes.size())
+ if (!registryPrefixes.empty())
{
auto obj = std::find(registryPrefixes.begin(),
registryPrefixes.end(), registryName);
@@ -463,7 +463,7 @@ class Subscription : public persistent_data::UserSubscription
// If registryMsgIds list is empty, don't filter events
// send everything.
- if (registryMsgIds.size())
+ if (!registryMsgIds.empty())
{
auto obj = std::find(registryMsgIds.begin(),
registryMsgIds.end(), messageKey);
@@ -484,7 +484,7 @@ class Subscription : public persistent_data::UserSubscription
}
}
- if (logEntryArray.size() < 1)
+ if (logEntryArray.empty())
{
BMCWEB_LOG_DEBUG << "No log entries available to be transferred.";
return;
@@ -506,7 +506,7 @@ class Subscription : public persistent_data::UserSubscription
std::string mrdUri = telemetry::metricReportDefinitionUri + ("/" + id);
// Empty list means no filter. Send everything.
- if (metricReportDefinitions.size())
+ if (!metricReportDefinitions.empty())
{
if (std::find(metricReportDefinitions.begin(),
metricReportDefinitions.end(),
@@ -1008,7 +1008,7 @@ class EventServiceManager
// Search the resourceTypes list for the subscription.
// If resourceTypes list is empty, don't filter events
// send everything.
- if (entry->resourceTypes.size())
+ if (!entry->resourceTypes.empty())
{
for (const auto& resource : entry->resourceTypes)
{
diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp
index 5477575bc7..027c85154a 100644
--- a/redfish-core/include/utils/fw_utils.hpp
+++ b/redfish-core/include/utils/fw_utils.hpp
@@ -55,7 +55,7 @@ inline void
return;
}
- if (functionalFw.size() == 0)
+ if (functionalFw.empty())
{
// Could keep going and try to populate SoftwareImages but
// something is seriously wrong, so just fail
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 53d644d5f2..0bf03cc51c 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -88,7 +88,7 @@ inline std::string getRoleIdFromPrivilege(std::string_view role)
{
return "Operator";
}
- if ((role == "") || (role == "priv-noaccess"))
+ if (role.empty() || (role == "priv-noaccess"))
{
return "NoAccess";
}
@@ -108,7 +108,7 @@ inline std::string getPrivilegeFromRoleId(std::string_view role)
{
return "priv-operator";
}
- if ((role == "NoAccess") || (role == ""))
+ if ((role == "NoAccess") || (role.empty()))
{
return "priv-noaccess";
}
@@ -1029,7 +1029,7 @@ inline void handleLDAPPatch(nlohmann::json& input,
}
if (serviceAddressList)
{
- if ((*serviceAddressList).size() == 0)
+ if (serviceAddressList->empty())
{
messages::propertyValueNotInList(asyncResp->res, "[]",
"ServiceAddress");
@@ -1038,7 +1038,7 @@ inline void handleLDAPPatch(nlohmann::json& input,
}
if (baseDNList)
{
- if ((*baseDNList).size() == 0)
+ if (baseDNList->empty())
{
messages::propertyValueNotInList(asyncResp->res, "[]",
"BaseDistinguishedNames");
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index fa9cc2fda8..34f6770da5 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -293,7 +293,7 @@ inline void requestRoutesCertificateActionGenerateCSR(App& app)
// password, which will likely cause bmcweb to crash on startup
// if this is not set on a post so not allowing the user to set
// value
- if (*optChallengePassword != "")
+ if (!optChallengePassword->empty())
{
messages::actionParameterNotSupported(
asyncResp->res, "GenerateCSR", "ChallengePassword");
@@ -355,7 +355,7 @@ inline void requestRoutesCertificateActionGenerateCSR(App& app)
certURI,
"/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"))
{
- if (optKeyUsage->size() == 0)
+ if (optKeyUsage->empty())
{
optKeyUsage->push_back("ServerAuthentication");
}
@@ -379,7 +379,7 @@ inline void requestRoutesCertificateActionGenerateCSR(App& app)
certURI,
"/redfish/v1/AccountService/LDAP/Certificates"))
{
- if (optKeyUsage->size() == 0)
+ if (optKeyUsage->empty())
{
optKeyUsage->push_back("ClientAuthentication");
}
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 8eb982198a..7b673806f0 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -270,7 +270,7 @@ inline void requestRoutesChassis(App& app)
health->populate();
- if (connectionNames.size() < 1)
+ if (connectionNames.empty())
{
BMCWEB_LOG_ERROR << "Got 0 Connection names";
continue;
@@ -375,7 +375,7 @@ inline void requestRoutesChassis(App& app)
// so skip if it is empty
if (propertyName == "SparePartNumber")
{
- if (*value == "")
+ if (value->empty())
{
continue;
}
@@ -514,7 +514,7 @@ inline void requestRoutesChassis(App& app)
continue;
}
- if (connectionNames.size() < 1)
+ if (connectionNames.empty())
{
BMCWEB_LOG_ERROR << "Got 0 Connection names";
continue;
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 0561c6758e..7c2da78843 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -2130,7 +2130,7 @@ inline void requestEthernetInterfacesRoutes(App& app)
const EthernetInterfaceData& ethData,
const boost::container::flat_set<IPv4AddressData>&,
const boost::container::flat_set<IPv6AddressData>&) {
- if (success && ethData.vlan_id.size() != 0)
+ if (success && !ethData.vlan_id.empty())
{
parseInterfaceData(asyncResp->res.jsonValue,
parentIfaceId, ifaceId, ethData);
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 8c748f9206..115bfee164 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -232,7 +232,7 @@ inline void requestRoutesEventDestinationCollection(App& app)
if (regPrefixes && msgIds)
{
- if (regPrefixes->size() && msgIds->size())
+ if (!regPrefixes->empty() && !msgIds->empty())
{
messages::mutualExclusiveProperties(
asyncResp->res, "RegistryPrefixes", "MessageIds");
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index db9b5aaa7b..76032b3fe7 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -120,7 +120,7 @@ inline void
return;
}
- if (objInfo.size() == 0)
+ if (objInfo.empty())
{
// As noted above, this is an optional interface so just return
// if there is no instance found
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 3877541338..41438cb796 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1115,7 +1115,7 @@ static int fillEventLogEntryJson(const std::string& logEntryID,
boost::split(logEntryFields, entry, boost::is_any_of(","),
boost::token_compress_on);
// We need at least a MessageId to be valid
- if (logEntryFields.size() < 1)
+ if (logEntryFields.empty())
{
return 1;
}
@@ -1971,12 +1971,12 @@ inline void requestRoutesSystemHostLoggerCollection(App& app)
}
// If vector is empty, that means skip value larger than total
// log count
- if (logEntries.size() == 0)
+ if (logEntries.empty())
{
asyncResp->res.jsonValue["Members@odata.count"] = logCount;
return;
}
- if (logEntries.size() > 0)
+ if (!logEntries.empty())
{
for (size_t i = 0; i < logEntries.size(); i++)
{
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index d4505444b2..9a805f0036 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -807,7 +807,7 @@ inline CreatePIDRet createPidInterface(
}
}
- if (profile.size() &&
+ if (!profile.empty() &&
(type == "PidControllers" || type == "FanControllers" ||
type == "StepwiseControllers"))
{
@@ -1821,7 +1821,7 @@ inline void
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find image!";
messages::internalError(aResp->res);
@@ -2099,7 +2099,7 @@ inline void requestRoutesManager(App& app)
<< "D-Bus response error on GetSubTree " << ec;
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find bmc D-Bus object!";
return;
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 61c3c68a07..7b665eb1eb 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -141,10 +141,10 @@ inline void getNetworkData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
return;
}
asyncResp->res.jsonValue["NTP"]["NTPServers"] = ntpServers;
- if (hostName.empty() == false)
+ if (!hostName.empty())
{
std::string fqdn = hostName;
- if (domainNames.empty() == false)
+ if (!domainNames.empty())
{
fqdn += ".";
fqdn += domainNames[0];
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index 78fa66924e..10655bf986 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -217,7 +217,7 @@ inline void requestRoutesSystemPCIeDevice(App& app)
messages::internalError(asyncResp->res);
return;
}
- if (*generationInUse == "")
+ if (generationInUse->empty())
{
// unknown, no need to handle
return;
@@ -303,7 +303,7 @@ inline void requestRoutesSystemPCIeFunctionCollection(App& app)
"DeviceId";
std::string* property = std::get_if<std::string>(
&pcieDevProperties[devIDProperty]);
- if (property && !property->empty())
+ if (property != nullptr && !property->empty())
{
pcieFunctionList.push_back(
{{"@odata.id",
@@ -365,7 +365,7 @@ inline void requestRoutesSystemPCIeFunction(App& app)
"Function" + function + "DeviceId";
if (std::string* property = std::get_if<std::string>(
&pcieDevProperties[devIDProperty]);
- property && property->empty())
+ property != nullptr && property->empty())
{
messages::resourceNotFound(asyncResp->res,
"PCIeFunction", function);
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 881bf1ab7d..a51aafd998 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -62,7 +62,7 @@ void getMainChassisId(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
BMCWEB_LOG_ERROR << ec;
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find chassis!";
return;
@@ -183,7 +183,7 @@ void getPortNumber(const std::string& socketPath, CallbackFunc&& callback)
callback(ec, 0);
return;
}
- if (resp.size() < 1)
+ if (resp.empty())
{
// Network Protocol Listen Response Elements is empty
boost::system::error_code ec1 =
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index a3f1c23814..121223efc6 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -1277,9 +1277,9 @@ inline void populateFanRedundancy(
}
size_t minNumNeeded =
- collection->size() > 0
- ? collection->size() - *allowedFailures
- : 0;
+ collection->empty()
+ ? 0
+ : collection->size() - *allowedFailures;
nlohmann::json& jResp =
sensorsAsyncResp->asyncResp->res
.jsonValue["Redundancy"];
@@ -2245,7 +2245,7 @@ void getPowerSupplyAttributes(
<< "getPowerSupplyAttributes respHandler DBus error " << ec;
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find Power Supply Attributes!";
callback(inventoryItems);
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index f5e75e5269..3e6f422243 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -113,7 +113,7 @@ inline void requestRoutesStorage(App& app)
[asyncResp,
health](const boost::system::error_code ec,
const crow::openbmc_mapper::GetSubTreeType& subtree) {
- if (ec || !subtree.size())
+ if (ec || subtree.empty())
{
// doesn't have to be there
return;
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index e7f4f02ca3..604f551074 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -267,7 +267,7 @@ inline void
const std::vector<
std::pair<std::string, std::vector<std::string>>>&
connectionNames = object.second;
- if (connectionNames.size() < 1)
+ if (connectionNames.empty())
{
continue;
}
@@ -311,7 +311,7 @@ inline void
<< properties.size()
<< " Dimm properties.";
- if (properties.size() > 0)
+ if (!properties.empty())
{
for (const std::pair<
std::string,
@@ -1241,7 +1241,7 @@ inline void getTrustedModuleRequiredToBoot(
// error occurs
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
// As noted above, this is an optional interface so just return
// if there is no instance found
@@ -1332,7 +1332,7 @@ inline void setTrustedModuleRequiredToBoot(
messages::internalError(aResp->res);
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
messages::propertyValueNotInList(aResp->res, "ComputerSystem",
"TrustedModuleRequiredToBoot");
@@ -1661,7 +1661,7 @@ inline void setAssetTag(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
messages::internalError(aResp->res);
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find system D-Bus object!";
messages::internalError(aResp->res);
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index f820e61e76..3137ab316e 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -824,7 +824,7 @@ inline void requestRoutesSoftwareInventory(App& app)
continue;
}
- if (obj.second.size() < 1)
+ if (obj.second.empty())
{
continue;
}
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index f617f4a98f..9333f6168f 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -87,7 +87,7 @@ inline void
{
const std::string* imageUrlValue =
std::get_if<std::string>(&value);
- if (imageUrlValue && !imageUrlValue->empty())
+ if (imageUrlValue != nullptr && !imageUrlValue->empty())
{
std::filesystem::path filePath = *imageUrlValue;
if (!filePath.has_filename())