Consistently name AsyncResp variables
In about half of our code, AsyncResp objects take the name asyncResp,
and in the other half they take the name aResp. While the difference
between them is negligeble and arbitrary, having two naming conventions
makes it more difficult to do automated changes over time via grep.
This commit was generated automtatically with the command:
git grep -l 'aResp' | xargs sed -i 's|aResp|asyncResp|g'
Tested: Code compiles.
Change-Id: Id363437b6a78f51e91cbf60aa0a0c2286f36a037
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index 1f554cc..328cc09 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -152,7 +152,7 @@
return "";
}
-inline void dimmPropToHex(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+inline void dimmPropToHex(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const char* key, const uint16_t* value,
const nlohmann::json::json_pointer& jsonPtr)
{
@@ -160,11 +160,11 @@
{
return;
}
- aResp->res.jsonValue[jsonPtr][key] = "0x" + intToHexString(*value, 4);
+ asyncResp->res.jsonValue[jsonPtr][key] = "0x" + intToHexString(*value, 4);
}
inline void getPersistentMemoryProperties(
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const dbus::utility::DBusPropertiesMap& properties,
const nlohmann::json::json_pointer& jsonPtr)
{
@@ -221,108 +221,111 @@
if (!success)
{
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
return;
}
- dimmPropToHex(aResp, "ModuleManufacturerID", moduleManufacturerID, jsonPtr);
- dimmPropToHex(aResp, "ModuleProductID", moduleProductID, jsonPtr);
- dimmPropToHex(aResp, "MemorySubsystemControllerManufacturerID",
+ dimmPropToHex(asyncResp, "ModuleManufacturerID", moduleManufacturerID,
+ jsonPtr);
+ dimmPropToHex(asyncResp, "ModuleProductID", moduleProductID, jsonPtr);
+ dimmPropToHex(asyncResp, "MemorySubsystemControllerManufacturerID",
subsystemVendorID, jsonPtr);
- dimmPropToHex(aResp, "MemorySubsystemControllerProductID",
+ dimmPropToHex(asyncResp, "MemorySubsystemControllerProductID",
subsystemDeviceID, jsonPtr);
if (volatileRegionSizeLimitInKiB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["VolatileRegionSizeLimitMiB"] =
+ asyncResp->res.jsonValue[jsonPtr]["VolatileRegionSizeLimitMiB"] =
(*volatileRegionSizeLimitInKiB) >> 10;
}
if (pmRegionSizeLimitInKiB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["PersistentRegionSizeLimitMiB"] =
+ asyncResp->res.jsonValue[jsonPtr]["PersistentRegionSizeLimitMiB"] =
(*pmRegionSizeLimitInKiB) >> 10;
}
if (volatileSizeInKiB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["VolatileSizeMiB"] =
+ asyncResp->res.jsonValue[jsonPtr]["VolatileSizeMiB"] =
(*volatileSizeInKiB) >> 10;
}
if (pmSizeInKiB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["NonVolatileSizeMiB"] = (*pmSizeInKiB) >>
- 10;
+ asyncResp->res.jsonValue[jsonPtr]["NonVolatileSizeMiB"] =
+ (*pmSizeInKiB) >> 10;
}
if (cacheSizeInKB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["CacheSizeMiB"] = (*cacheSizeInKB >> 10);
+ asyncResp->res.jsonValue[jsonPtr]["CacheSizeMiB"] =
+ (*cacheSizeInKB >> 10);
}
if (voltaileRegionMaxSizeInKib != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["VolatileRegionSizeMaxMiB"] =
+ asyncResp->res.jsonValue[jsonPtr]["VolatileRegionSizeMaxMiB"] =
(*voltaileRegionMaxSizeInKib) >> 10;
}
if (pmRegionMaxSizeInKiB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["PersistentRegionSizeMaxMiB"] =
+ asyncResp->res.jsonValue[jsonPtr]["PersistentRegionSizeMaxMiB"] =
(*pmRegionMaxSizeInKiB) >> 10;
}
if (allocationIncrementInKiB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["AllocationIncrementMiB"] =
+ asyncResp->res.jsonValue[jsonPtr]["AllocationIncrementMiB"] =
(*allocationIncrementInKiB) >> 10;
}
if (allocationAlignmentInKiB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["AllocationAlignmentMiB"] =
+ asyncResp->res.jsonValue[jsonPtr]["AllocationAlignmentMiB"] =
(*allocationAlignmentInKiB) >> 10;
}
if (volatileRegionNumberLimit != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["VolatileRegionNumberLimit"] =
+ asyncResp->res.jsonValue[jsonPtr]["VolatileRegionNumberLimit"] =
*volatileRegionNumberLimit;
}
if (pmRegionNumberLimit != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["PersistentRegionNumberLimit"] =
+ asyncResp->res.jsonValue[jsonPtr]["PersistentRegionNumberLimit"] =
*pmRegionNumberLimit;
}
if (spareDeviceCount != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["SpareDeviceCount"] = *spareDeviceCount;
+ asyncResp->res.jsonValue[jsonPtr]["SpareDeviceCount"] =
+ *spareDeviceCount;
}
if (isSpareDeviceInUse != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["IsSpareDeviceEnabled"] =
+ asyncResp->res.jsonValue[jsonPtr]["IsSpareDeviceEnabled"] =
*isSpareDeviceInUse;
}
if (isRankSpareEnabled != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["IsRankSpareEnabled"] =
+ asyncResp->res.jsonValue[jsonPtr]["IsRankSpareEnabled"] =
*isRankSpareEnabled;
}
if (maxAveragePowerLimitmW != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["MaxTDPMilliWatts"] =
+ asyncResp->res.jsonValue[jsonPtr]["MaxTDPMilliWatts"] =
*maxAveragePowerLimitmW;
}
if (configurationLocked != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["ConfigurationLocked"] =
+ asyncResp->res.jsonValue[jsonPtr]["ConfigurationLocked"] =
*configurationLocked;
}
@@ -335,8 +338,8 @@
{
if (allowedMemoryModes->ends_with(v))
{
- aResp->res.jsonValue[jsonPtr]["OperatingMemoryModes"].push_back(
- v);
+ asyncResp->res.jsonValue[jsonPtr]["OperatingMemoryModes"]
+ .push_back(v);
break;
}
}
@@ -351,7 +354,7 @@
{
if (memoryMedia->ends_with(v))
{
- aResp->res.jsonValue[jsonPtr]["MemoryMedia"].push_back(v);
+ asyncResp->res.jsonValue[jsonPtr]["MemoryMedia"].push_back(v);
break;
}
}
@@ -359,46 +362,46 @@
if (configurationLockCapable != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["ConfigurationLockCapable"] =
+ asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
+ ["ConfigurationLockCapable"] =
*configurationLockCapable;
}
if (dataLockCapable != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["DataLockCapable"] = *dataLockCapable;
+ asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
+ ["DataLockCapable"] = *dataLockCapable;
}
if (passphraseCapable != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["PassphraseCapable"] = *passphraseCapable;
+ asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
+ ["PassphraseCapable"] = *passphraseCapable;
}
if (maxPassphraseCount != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["MaxPassphraseCount"] = *maxPassphraseCount;
+ asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
+ ["MaxPassphraseCount"] = *maxPassphraseCount;
}
if (passphraseLockLimit != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["PassphraseLockLimit"] = *passphraseLockLimit;
+ asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
+ ["PassphraseLockLimit"] = *passphraseLockLimit;
}
}
inline void
assembleDimmProperties(std::string_view dimmId,
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const dbus::utility::DBusPropertiesMap& properties,
const nlohmann::json::json_pointer& jsonPtr)
{
- aResp->res.jsonValue[jsonPtr]["Id"] = dimmId;
- aResp->res.jsonValue[jsonPtr]["Name"] = "DIMM Slot";
- aResp->res.jsonValue[jsonPtr]["Status"]["State"] = "Enabled";
- aResp->res.jsonValue[jsonPtr]["Status"]["Health"] = "OK";
+ asyncResp->res.jsonValue[jsonPtr]["Id"] = dimmId;
+ asyncResp->res.jsonValue[jsonPtr]["Name"] = "DIMM Slot";
+ asyncResp->res.jsonValue[jsonPtr]["Status"]["State"] = "Enabled";
+ asyncResp->res.jsonValue[jsonPtr]["Status"]["Health"] = "OK";
const uint16_t* memoryDataWidth = nullptr;
const size_t* memorySizeInKB = nullptr;
@@ -437,49 +440,50 @@
if (!success)
{
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
return;
}
if (memoryDataWidth != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["DataWidthBits"] = *memoryDataWidth;
+ asyncResp->res.jsonValue[jsonPtr]["DataWidthBits"] = *memoryDataWidth;
}
if (memorySizeInKB != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["CapacityMiB"] = (*memorySizeInKB >> 10);
+ asyncResp->res.jsonValue[jsonPtr]["CapacityMiB"] =
+ (*memorySizeInKB >> 10);
}
if (partNumber != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["PartNumber"] = *partNumber;
+ asyncResp->res.jsonValue[jsonPtr]["PartNumber"] = *partNumber;
}
if (serialNumber != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["SerialNumber"] = *serialNumber;
+ asyncResp->res.jsonValue[jsonPtr]["SerialNumber"] = *serialNumber;
}
if (manufacturer != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["Manufacturer"] = *manufacturer;
+ asyncResp->res.jsonValue[jsonPtr]["Manufacturer"] = *manufacturer;
}
if (revisionCode != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["FirmwareRevision"] =
+ asyncResp->res.jsonValue[jsonPtr]["FirmwareRevision"] =
std::to_string(*revisionCode);
}
if (present != nullptr && !*present)
{
- aResp->res.jsonValue[jsonPtr]["Status"]["State"] = "Absent";
+ asyncResp->res.jsonValue[jsonPtr]["Status"]["State"] = "Absent";
}
if (memoryTotalWidth != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["BusWidthBits"] = *memoryTotalWidth;
+ asyncResp->res.jsonValue[jsonPtr]["BusWidthBits"] = *memoryTotalWidth;
}
if (ecc != nullptr)
@@ -491,7 +495,7 @@
{
if (ecc->ends_with(v))
{
- aResp->res.jsonValue[jsonPtr]["ErrorCorrection"] = v;
+ asyncResp->res.jsonValue[jsonPtr]["ErrorCorrection"] = v;
break;
}
}
@@ -508,7 +512,7 @@
{
if (formFactor->ends_with(v))
{
- aResp->res.jsonValue[jsonPtr]["BaseModuleType"] = v;
+ asyncResp->res.jsonValue[jsonPtr]["BaseModuleType"] = v;
break;
}
}
@@ -517,7 +521,7 @@
if (allowedSpeedsMT != nullptr)
{
nlohmann::json& jValue =
- aResp->res.jsonValue[jsonPtr]["AllowedSpeedsMHz"];
+ asyncResp->res.jsonValue[jsonPtr]["AllowedSpeedsMHz"];
jValue = nlohmann::json::array();
for (uint16_t subVal : *allowedSpeedsMT)
{
@@ -527,13 +531,13 @@
if (memoryAttributes != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["RankCount"] =
+ asyncResp->res.jsonValue[jsonPtr]["RankCount"] =
static_cast<uint64_t>(*memoryAttributes);
}
if (memoryConfiguredSpeedInMhz != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["OperatingSpeedMhz"] =
+ asyncResp->res.jsonValue[jsonPtr]["OperatingSpeedMhz"] =
*memoryConfiguredSpeedInMhz;
}
@@ -545,67 +549,68 @@
// so just leave off
if (!memoryDeviceType.empty())
{
- aResp->res.jsonValue[jsonPtr]["MemoryDeviceType"] =
+ asyncResp->res.jsonValue[jsonPtr]["MemoryDeviceType"] =
memoryDeviceType;
}
if (memoryType->find("DDR") != std::string::npos)
{
- aResp->res.jsonValue[jsonPtr]["MemoryType"] = "DRAM";
+ asyncResp->res.jsonValue[jsonPtr]["MemoryType"] = "DRAM";
}
else if (memoryType->ends_with("Logical"))
{
- aResp->res.jsonValue[jsonPtr]["MemoryType"] = "IntelOptane";
+ asyncResp->res.jsonValue[jsonPtr]["MemoryType"] = "IntelOptane";
}
}
if (channel != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Channel"] = *channel;
+ asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Channel"] =
+ *channel;
}
if (memoryController != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["MemoryLocation"]["MemoryController"] =
- *memoryController;
+ asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]
+ ["MemoryController"] = *memoryController;
}
if (slot != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Slot"] = *slot;
+ asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Slot"] = *slot;
}
if (socket != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Socket"] = *socket;
+ asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Socket"] = *socket;
}
if (sparePartNumber != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["SparePartNumber"] = *sparePartNumber;
+ asyncResp->res.jsonValue[jsonPtr]["SparePartNumber"] = *sparePartNumber;
}
if (model != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["Model"] = *model;
+ asyncResp->res.jsonValue[jsonPtr]["Model"] = *model;
}
if (locationCode != nullptr)
{
- aResp->res.jsonValue[jsonPtr]["Location"]["PartLocation"]
- ["ServiceLabel"] = *locationCode;
+ asyncResp->res.jsonValue[jsonPtr]["Location"]["PartLocation"]
+ ["ServiceLabel"] = *locationCode;
}
- getPersistentMemoryProperties(aResp, properties, jsonPtr);
+ getPersistentMemoryProperties(asyncResp, properties, jsonPtr);
}
-inline void getDimmDataByService(std::shared_ptr<bmcweb::AsyncResp> aResp,
+inline void getDimmDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
const std::string& dimmId,
const std::string& service,
const std::string& objPath)
{
if constexpr (bmcwebEnableHealthPopulate)
{
- auto health = std::make_shared<HealthPopulate>(aResp);
+ auto health = std::make_shared<HealthPopulate>(asyncResp);
health->selfPath = objPath;
health->populate();
}
@@ -613,21 +618,21 @@
BMCWEB_LOG_DEBUG << "Get available system components.";
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, service, objPath, "",
- [dimmId, aResp{std::move(aResp)}](
+ [dimmId, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error";
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
return;
}
- assembleDimmProperties(dimmId, aResp, properties, ""_json_pointer);
+ assembleDimmProperties(dimmId, asyncResp, properties, ""_json_pointer);
});
}
inline void assembleDimmPartitionData(
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const dbus::utility::DBusPropertiesMap& properties,
const nlohmann::json::json_pointer& regionPtr)
{
@@ -645,7 +650,7 @@
if (!success)
{
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
return;
}
@@ -676,34 +681,34 @@
partition["SizeMiB"] = (*sizeInKiB >> 10);
}
- aResp->res.jsonValue[regionPtr].emplace_back(std::move(partition));
+ asyncResp->res.jsonValue[regionPtr].emplace_back(std::move(partition));
}
-inline void getDimmPartitionData(std::shared_ptr<bmcweb::AsyncResp> aResp,
+inline void getDimmPartitionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
const std::string& service,
const std::string& path)
{
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, service, path,
"xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition",
- [aResp{std::move(aResp)}](
+ [asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error";
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
return;
}
nlohmann::json::json_pointer regionPtr = "/Regions"_json_pointer;
- assembleDimmPartitionData(aResp, properties, regionPtr);
+ assembleDimmPartitionData(asyncResp, properties, regionPtr);
}
);
}
-inline void getDimmData(std::shared_ptr<bmcweb::AsyncResp> aResp,
+inline void getDimmData(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
const std::string& dimmId)
{
BMCWEB_LOG_DEBUG << "Get available system dimm resources.";
@@ -712,13 +717,13 @@
"xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition"};
dbus::utility::getSubTree(
"/xyz/openbmc_project/inventory", 0, dimmInterfaces,
- [dimmId, aResp{std::move(aResp)}](
+ [dimmId, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error";
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
return;
}
@@ -734,7 +739,8 @@
"xyz.openbmc_project.Inventory.Item.Dimm" &&
path.filename() == dimmId)
{
- getDimmDataByService(aResp, dimmId, service, rawPath);
+ getDimmDataByService(asyncResp, dimmId, service,
+ rawPath);
found = true;
}
@@ -747,7 +753,7 @@
"xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition" &&
path.parent_path().filename() == dimmId)
{
- getDimmPartitionData(aResp, service, rawPath);
+ getDimmPartitionData(asyncResp, service, rawPath);
}
}
}
@@ -755,12 +761,12 @@
// Object not found
if (!found)
{
- messages::resourceNotFound(aResp->res, "Memory", dimmId);
+ messages::resourceNotFound(asyncResp->res, "Memory", dimmId);
return;
}
// Set @odata only if object is found
- aResp->res.jsonValue["@odata.type"] = "#Memory.v1_11_0.Memory";
- aResp->res.jsonValue["@odata.id"] =
+ asyncResp->res.jsonValue["@odata.type"] = "#Memory.v1_11_0.Memory";
+ asyncResp->res.jsonValue["@odata.id"] =
boost::urls::format("/redfish/v1/Systems/system/Memory/{}", dimmId);
return;
});