gcc13 : fix argument format issues
gcc13 based build failed with below errors.
error: static assertion failed: Cannot format an argument.
To make type T formattable provide a formatter<T> specialization:
https://fmt.dev/latest/api.html#udt
Problem reported during enum type input is similar to
https://github.com/fmtlib/fmt/issues/391
Fix is to static_cast the "enum" type to "underlying_type" in
fmt::format function.
Problem related file descriptor input is to static_cast enum
to "underlying_type".
Change-Id: I587e4abfb4e188d40a0e4bfbdd57e6da6a77616d
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/host-transport-extensions/pldm/common/pldm_utils.cpp b/host-transport-extensions/pldm/common/pldm_utils.cpp
index 1348886..7876462 100644
--- a/host-transport-extensions/pldm/common/pldm_utils.cpp
+++ b/host-transport-extensions/pldm/common/pldm_utils.cpp
@@ -28,7 +28,11 @@
{
auto e = errno;
log<level::ERR>(
- fmt::format("pldm_open failed, errno({}), FD({})", e, fd).c_str());
+ fmt::format(
+ "pldm_open failed, errno({}), FD({})", e,
+ static_cast<
+ std::underlying_type<pldm_requester_error_codes>::type>(fd))
+ .c_str());
elog<NotAllowed>(Reason("Required host dump action via pldm is not "
"allowed due to pldm_open failed"));
}
diff --git a/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp b/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
index 1c9d703..606bd94 100644
--- a/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
+++ b/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
@@ -177,10 +177,14 @@
if (retCode != PLDM_SUCCESS)
{
log<level::ERR>(
- fmt::format("Failed to encode pldm FileAck to delete host "
- "dump,SRC_DUMP_ID({}), "
- "PLDM_FILE_IO_TYPE({}),PLDM_RETURN_CODE({})",
- dumpId, pldmDumpType, retCode)
+ fmt::format(
+ "Failed to encode pldm FileAck to delete host "
+ "dump,SRC_DUMP_ID({}), "
+ "PLDM_FILE_IO_TYPE({}),PLDM_RETURN_CODE({})",
+ dumpId,
+ static_cast<std::underlying_type<pldm_fileio_file_type>::type>(
+ pldmDumpType),
+ retCode)
.c_str());
elog<NotAllowed>(Reason("Host dump deletion via pldm is not "
"allowed due to encode fileack failed"));
@@ -194,11 +198,14 @@
{
auto errorNumber = errno;
log<level::ERR>(
- fmt::format("Failed to send pldm FileAck to delete host dump, "
- "SRC_DUMP_ID({}), PLDM_FILE_IO_TYPE({}), "
- "PLDM_RETURN_CODE({}), ERRNO({}), ERRMSG({})",
- dumpId, pldmDumpType, retCode, errorNumber,
- strerror(errorNumber))
+ fmt::format(
+ "Failed to send pldm FileAck to delete host dump, "
+ "SRC_DUMP_ID({}), PLDM_FILE_IO_TYPE({}), "
+ "PLDM_RETURN_CODE({}), ERRNO({}), ERRMSG({})",
+ dumpId,
+ static_cast<std::underlying_type<pldm_fileio_file_type>::type>(
+ pldmDumpType),
+ retCode, errorNumber, strerror(errorNumber))
.c_str());
elog<NotAllowed>(Reason("Host dump deletion via pldm is not "
"allowed due to fileack send failed"));