pldmtool: Fix containedEntity parsing
Commit "pldmtool : Migrate to placement_new from reinterpret casting"
(5c3f0d1b09bfbd206c33841b83938ef5f057a655) has broken a parsing of
containedEntities from the Entity Association PDR.
Currently the first element of the children array is initialized from
the default constructor instead of using data from a pointer.
Correct statement syntax to fix the issue.
Tested:
Output from the "pldmtool platform GetPDR -v -a -m <MCTP_EID>"
Before:
<...>
pldmtool: Tx: 81 02 51 4c 04 00 00 00 00 00 00 01 ff ff 00 00
pldmtool: Rx: 01 02 51 00 4d 04 00 00 00 00 00 00 05 1a 00 4c 04 00 00
01 0f 00 00 10 00 64 00 00 44 00 01 00 00 00 01 90 00 01 00 64 00
{
<...>
"PDRType": "Entity Association PDR",
<...>
"containedEntityCount": 1,
"containedEntityType[1]": "[Physical] Unspecified",
"containedEntityInstanceNumber[1]": 0,
"containedEntityContainerID[1]": 0
}
<...>
After:
<...>
pldmtool: Tx: 81 02 51 4c 04 00 00 00 00 00 00 01 ff ff 00 00
pldmtool: Rx: 01 02 51 00 4d 04 00 00 00 00 00 00 05 1a 00 4c 04 00 00
01 0f 00 00 10 00 64 00 00 44 00 01 00 00 00 01 90 00 01 00 64 00
{
<...>
"PDRType": "Entity Association PDR",
<...>
"containedEntityCount": 1,
"containedEntityType[1]": "[Physical] Network Controller",
"containedEntityInstanceNumber[1]": 1,
"containedEntityContainerID[1]": 100
}
<...>
Change-Id: I938c0ad8a2a42ddb0d43b20b2419a3075b3f30f2
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
diff --git a/pldmtool/pldm_platform_cmd.cpp b/pldmtool/pldm_platform_cmd.cpp
index 0198dc1..bc90641 100644
--- a/pldmtool/pldm_platform_cmd.cpp
+++ b/pldmtool/pldm_platform_cmd.cpp
@@ -965,7 +965,7 @@
output["containedEntityCount"] =
static_cast<unsigned>(pdr->num_children);
- pldm_entity* child = new (&pdr->children[0]) pldm_entity();
+ pldm_entity* child = new (&pdr->children[0]) pldm_entity;
for (int i = 0; i < pdr->num_children; ++i)
{
output.emplace("containedEntityType[" + std::to_string(i + 1) + "]",