pldmtool : 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: Iaebfaa78c4d3c0c3658dbf9f2f6eaa932b061e83
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/pldmtool/pldm_fru_cmd.cpp b/pldmtool/pldm_fru_cmd.cpp
index aeb6f09..5b9fc58 100644
--- a/pldmtool/pldm_fru_cmd.cpp
+++ b/pldmtool/pldm_fru_cmd.cpp
@@ -42,7 +42,7 @@
     std::pair<int, std::vector<uint8_t>> createRequestMsg() override
     {
         std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr));
-        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
+        auto request = new (requestMsg.data()) pldm_msg;
 
         auto rc = encode_get_fru_record_table_metadata_req(
             instanceId, request, PLDM_GET_FRU_RECORD_TABLE_METADATA_REQ_BYTES);
@@ -361,8 +361,7 @@
 
         std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) + payloadLength,
                                         0);
-        auto reqMsg = reinterpret_cast<pldm_msg*>(requestMsg.data());
-
+        auto reqMsg = new (requestMsg.data()) pldm_msg;
         auto rc = encode_get_fru_record_by_option_req(
             instanceId, 0 /* DataTransferHandle */, 0 /* FRUTableHandle */,
             recordSetIdentifier, recordType, fieldType, PLDM_GET_FIRSTPART,
@@ -414,7 +413,7 @@
     {
         std::vector<uint8_t> requestMsg(
             sizeof(pldm_msg_hdr) + PLDM_GET_FRU_RECORD_TABLE_REQ_BYTES);
-        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
+        auto request = new (requestMsg.data()) pldm_msg;
 
         auto rc = encode_get_fru_record_table_req(
             instanceId, 0, PLDM_GET_FIRSTPART, request,