platform-mc : 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: I006bb4a5de9f7d0cef4dbc7507f63e1d6798ddfe
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/platform-mc/sensor_manager.cpp b/platform-mc/sensor_manager.cpp
index d29e552..2f9eaa5 100644
--- a/platform-mc/sensor_manager.cpp
+++ b/platform-mc/sensor_manager.cpp
@@ -281,7 +281,7 @@
auto tid = sensor->tid;
auto sensorId = sensor->sensorId;
Request request(sizeof(pldm_msg_hdr) + PLDM_GET_SENSOR_READING_REQ_BYTES);
- auto requestMsg = reinterpret_cast<pldm_msg*>(request.data());
+ auto requestMsg = new (request.data()) pldm_msg;
auto rc = encode_get_sensor_reading_req(0, sensorId, false, requestMsg);
if (rc)
{