pldm: Remove unnecessary type casting in logs
This commit removes the unnecessary type casting of values of the
journal logs based on supported types mentioned in LG2 documentation
[1].
Testing: Verified the debug traces to correct.
'''
For Instance:
Earlier -
error(”TYPE = {TYPE} “, “TYPE”, static_cast<unsigned>(PLDM_STATE_EFFECTER_PDR));
Journal trace -
May 27 08:16:51 p10bmc pldmd[931]: TYPE = 11
After Correction -
error(”TYPE = {TYPE}“, “TYPE”, PLDM_STATE_EFFECTER_PDR);
Journal trace -
May 27 08:16:51 p10bmc pldmd[931]: TYPE = Enum(11)
'''
[1]: https://github.com/openbmc/phosphor-logging/blob/master/docs/structured-logging.md#lg2
Change-Id: Ia649ecd4ecbb73c421f7844885f58a6835805719
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index 699e0d5..1d4733d 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -93,7 +93,7 @@
if (!fs::exists(dir))
{
error("System specific bios attribute directory {DIR} does not exit",
- "DIR", dir.string());
+ "DIR", dir);
return;
}
constructAttributes();
@@ -690,14 +690,14 @@
{
error(
"Failed to parse JSON config file at path '{PATH}', error - {ERROR}",
- "PATH", filePath.c_str(), "ERROR", e);
+ "PATH", filePath, "ERROR", e);
}
}
}
catch (const std::exception& e)
{
error("Failed to parse JSON config file '{PATH}', error - {ERROR}",
- "PATH", filePath.c_str(), "ERROR", e);
+ "PATH", filePath, "ERROR", e);
}
}
}
@@ -836,7 +836,7 @@
{
error(
"Invalid index '{INDEX}' encountered for Enum type BIOS attribute",
- "INDEX", (int)value[0]);
+ "INDEX", value[0]);
return PLDM_ERROR_INVALID_DATA;
}
return PLDM_SUCCESS;
@@ -1034,7 +1034,7 @@
{
error(
"Failed to update the attribute value table for attribute handle '{ATTR_HANDLE}' and attribute type '{TYPE}'",
- "ATTR_HANDLE", attrHdl, "TYPE", (uint32_t)attrType);
+ "ATTR_HANDLE", attrHdl, "TYPE", attrType);
return;
}
auto destTable = table::attribute_value::updateTable(
diff --git a/libpldmresponder/event_parser.cpp b/libpldmresponder/event_parser.cpp
index b006d56..5158eda 100644
--- a/libpldmresponder/event_parser.cpp
+++ b/libpldmresponder/event_parser.cpp
@@ -28,7 +28,7 @@
if (!fs::exists(dir) || fs::is_empty(dir))
{
error("Event config directory at '{PATH}' does not exist or empty",
- "PATH", dirPath.c_str());
+ "PATH", dirPath);
return;
}
@@ -40,7 +40,7 @@
if (data.is_discarded())
{
error("Failed to parse event state sensor JSON file at '{PATH}'",
- "PATH", file.path().c_str());
+ "PATH", file.path());
continue;
}
@@ -76,7 +76,7 @@
{
error(
"Invalid dbus config at '{PATH}', interface '{DBUS_INTERFACE}', property name '{PROPERTY_NAME}' and property type '{PROPERTY_TYPE}'",
- "PATH", dbusInfo.objectPath.c_str(), "DBUS_INTERFACE",
+ "PATH", dbusInfo.objectPath, "DBUS_INTERFACE",
dbusInfo.interface, "PROPERTY_NAME", dbusInfo.propertyName,
"PROPERTY_TYPE", dbusInfo.propertyType);
continue;
diff --git a/libpldmresponder/fru_parser.cpp b/libpldmresponder/fru_parser.cpp
index 364a26b..c5ea3ea 100644
--- a/libpldmresponder/fru_parser.cpp
+++ b/libpldmresponder/fru_parser.cpp
@@ -49,7 +49,7 @@
if (data.is_discarded())
{
error("Failed to parse FRU Dbus Lookup Map config file '{PATH}'",
- "PATH", masterJsonPath.c_str());
+ "PATH", masterJsonPath);
std::abort();
}
std::map<Interface, EntityType> defIntfToEntityType;
@@ -118,7 +118,7 @@
if (data.is_discarded())
{
error("Failed to parse FRU config file at '{PATH}'", "PATH",
- file.path().c_str());
+ file.path());
throw InternalFailure();
}
diff --git a/libpldmresponder/pdr_state_effecter.hpp b/libpldmresponder/pdr_state_effecter.hpp
index 4e3031a..42af4ad 100644
--- a/libpldmresponder/pdr_state_effecter.hpp
+++ b/libpldmresponder/pdr_state_effecter.hpp
@@ -44,8 +44,7 @@
{
error(
"Malformed PDR JSON return pdrEntry; no state set info for state effecter pdr '{STATE_EFFECTER_PDR}'",
- "STATE_EFFECTER_PDR",
- static_cast<unsigned>(PLDM_STATE_EFFECTER_PDR));
+ "STATE_EFFECTER_PDR", PLDM_STATE_EFFECTER_PDR);
throw InternalFailure();
}
pdrSize += sizeof(state_effecter_possible_states) -
diff --git a/libpldmresponder/pdr_state_sensor.hpp b/libpldmresponder/pdr_state_sensor.hpp
index dd9a992..58236da 100644
--- a/libpldmresponder/pdr_state_sensor.hpp
+++ b/libpldmresponder/pdr_state_sensor.hpp
@@ -43,8 +43,7 @@
{
error(
"Malformed PDR JSON return pdrEntry; no state set info for state sensor pdr '{STATE_SENSOR_PDR}'",
- "STATE_SENSOR_PDR",
- static_cast<int>(PLDM_STATE_SENSOR_PDR));
+ "STATE_SENSOR_PDR", PLDM_STATE_SENSOR_PDR);
throw InternalFailure();
}
pdrSize += sizeof(state_sensor_possible_states) -
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 42bfc83..7d50b5d 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -951,8 +951,8 @@
{
error(
"The requester sent wrong composite effecter count '{COMPOSITE_EFFECTER_COUNT}' for the effecter ID '{EFFECTERID}'.",
- "COMPOSITE_EFFECTER_COUNT", (uint16_t)compEffecterCnt,
- "EFFECTERID", effecterId);
+ "COMPOSITE_EFFECTER_COUNT", compEffecterCnt, "EFFECTERID",
+ effecterId);
return false;
}
@@ -1013,7 +1013,7 @@
{
error(
"Failed to decode setEventReceiver command, response code '{RC}' and completion code '{CC}'",
- "RC", rc, "CC", (unsigned)completionCode);
+ "RC", rc, "CC", completionCode);
pldm::utils::reportError(
"xyz.openbmc_project.bmc.pldm.InternalFailure");
}
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index ac07767..89eca61 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -362,8 +362,8 @@
{
error(
"The requester sent wrong composite effecter count '{COMPOSITE_EFFECTER_COUNT}' for the effecter ID '{EFFECTERID}'.",
- "COMPOSITE_EFFECTER_COUNT", (unsigned)compEffecterCnt,
- "EFFECTERID", (unsigned)effecterId);
+ "COMPOSITE_EFFECTER_COUNT", compEffecterCnt, "EFFECTERID",
+ effecterId);
return PLDM_ERROR_INVALID_DATA;
}
break;
@@ -393,10 +393,10 @@
{
error(
"Invalid state set value for effecter ID '{EFFECTERID}', effecter state '{EFFECTER_STATE}', composite effecter ID '{COMPOSITE_EFFECTER_ID}' and path '{PATH}'.",
- "EFFECTERID", (unsigned)effecterId, "EFFECTER_STATE",
- (unsigned)stateField[currState].effecter_state,
- "COMPOSITE_EFFECTER_COUNT", (unsigned)currState, "PATH",
- dbusMappings[currState].objectPath.c_str());
+ "EFFECTERID", effecterId, "EFFECTER_STATE",
+ stateField[currState].effecter_state,
+ "COMPOSITE_EFFECTER_COUNT", currState, "PATH",
+ dbusMappings[currState].objectPath);
rc = PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE;
break;
}
@@ -419,7 +419,7 @@
"Failed to set property '{PROPERTY}' of interface '{INTERFACE}' at path '{PATH}', error - {ERROR}",
"PROPERTY", dbusMapping.propertyName, "DBUS_INTF",
dbusMapping.interface, "DBUS_OBJ_PATH",
- dbusMapping.objectPath.c_str(), "ERROR", e);
+ dbusMapping.objectPath, "ERROR", e);
return PLDM_ERROR;
}
}
@@ -436,7 +436,7 @@
{
error(
"The effecter ID '{EFFECTERID}' does not exist, error - {ERROR}.",
- "EFFECTERID", (unsigned)effecterId, "ERROR", e);
+ "EFFECTERID", effecterId, "ERROR", e);
}
return rc;
diff --git a/libpldmresponder/platform_numeric_effecter.hpp b/libpldmresponder/platform_numeric_effecter.hpp
index 1cad4a4..274357c 100644
--- a/libpldmresponder/platform_numeric_effecter.hpp
+++ b/libpldmresponder/platform_numeric_effecter.hpp
@@ -324,8 +324,8 @@
error(
"Failed to set property '{PROPERTY}', interface '{INTERFACE}' and path '{PATH}', error - {ERROR}",
"PROPERTY", dbusMapping.propertyName, "INTERFACE",
- dbusMapping.interface, "PATH", dbusMapping.objectPath.c_str(),
- "ERROR", e);
+ dbusMapping.interface, "PATH", dbusMapping.objectPath, "ERROR",
+ e);
return PLDM_ERROR;
}
}
@@ -559,9 +559,8 @@
"EFFECTERID", effecterId, "ERROR", e);
error(
"Dbus Details path [{PATH}], interface [{INTERFACE}] and property [{PROPERTY}]",
- "PATH", dbusMapping.objectPath.c_str(), "INTERFACE",
- dbusMapping.interface.c_str(), "PROPERTY",
- dbusMapping.propertyName.c_str());
+ "PATH", dbusMapping.objectPath, "INTERFACE", dbusMapping.interface,
+ "PROPERTY", dbusMapping.propertyName);
return PLDM_ERROR;
}
diff --git a/libpldmresponder/platform_state_effecter.hpp b/libpldmresponder/platform_state_effecter.hpp
index a23732b..201b283 100644
--- a/libpldmresponder/platform_state_effecter.hpp
+++ b/libpldmresponder/platform_state_effecter.hpp
@@ -125,7 +125,7 @@
"EFFECTER_ID", effecterId, "EFFECTER_STATE",
stateField[currState].effecter_state,
"COMPOSITE_EFFECTER_ID", currState, "PATH",
- dbusMappings[currState].objectPath.c_str(), "RC", rc);
+ dbusMappings[currState].objectPath, "RC", rc);
break;
}
const DBusMapping& dbusMapping = dbusMappings[currState];
@@ -145,8 +145,8 @@
error(
"Failed to set property '{PROPERTY}', interface '{INTERFACE}' and path '{PATH}', error - '{ERROR}'",
"PROPERTY", dbusMapping.propertyName, "INTERFACE",
- dbusMapping.interface, "PATH",
- dbusMapping.objectPath.c_str(), "ERROR", e);
+ dbusMapping.interface, "PATH", dbusMapping.objectPath,
+ "ERROR", e);
return PLDM_ERROR;
}
}
diff --git a/libpldmresponder/platform_state_sensor.hpp b/libpldmresponder/platform_state_sensor.hpp
index 960f89d..4fab000 100644
--- a/libpldmresponder/platform_state_sensor.hpp
+++ b/libpldmresponder/platform_state_sensor.hpp
@@ -55,7 +55,7 @@
{
error(
"Failed to get state sensor event state from dbus interface '{PATH}', error - {ERROR}.",
- "PATH", dbusMapping.objectPath.c_str(), "ERROR", e);
+ "PATH", dbusMapping.objectPath, "ERROR", e);
}
return PLDM_SENSOR_UNKNOWN;