fw-update : Migrate to placement_new from reinterpret casting
reinterpret_cast is prohibited by the C++ core guidelines because
it takes the behavior outside the language definition and gives
problems with type safety. Placement-new on the other-hand allows
to control the object storage while still properly instantiating
an object,keeping the behavior inside the C++ language
specification.
Change-Id: Id5d75d41a83fbbae109506a8059e756596ba1cbc
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/fw-update/inventory_manager.cpp b/fw-update/inventory_manager.cpp
index 021c4ec..98d56d1 100644
--- a/fw-update/inventory_manager.cpp
+++ b/fw-update/inventory_manager.cpp
@@ -542,7 +542,7 @@
auto instanceId = instanceIdDb.next(eid);
Request requestMsg(
sizeof(pldm_msg_hdr) + PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES);
- auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
+ auto request = new (requestMsg.data()) pldm_msg;
auto rc = encode_get_firmware_parameters_req(
instanceId, PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES, request);
if (rc)