libpldmresponder : 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: If96afcb2c9dbea8fb6815d74a2181ca9ed04903a
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/libpldmresponder/platform_state_sensor.hpp b/libpldmresponder/platform_state_sensor.hpp
index 003763f..61ac272 100644
--- a/libpldmresponder/platform_state_sensor.hpp
+++ b/libpldmresponder/platform_state_sensor.hpp
@@ -109,7 +109,7 @@
auto pdrRecord = stateSensorPDRs.getFirstRecord(pdrEntry);
while (pdrRecord)
{
- pdr = reinterpret_cast<pldm_state_sensor_pdr*>(pdrEntry.data);
+ pdr = new (pdrEntry.data) pldm_state_sensor_pdr;
assert(pdr != nullptr);
if (pdr->sensor_id != sensorId)
{