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_numeric_effecter.hpp b/libpldmresponder/platform_numeric_effecter.hpp
index a38863b..a3fab47 100644
--- a/libpldmresponder/platform_numeric_effecter.hpp
+++ b/libpldmresponder/platform_numeric_effecter.hpp
@@ -275,7 +275,7 @@
auto pdrRecord = numericEffecterPDRs.getFirstRecord(pdrEntry);
while (pdrRecord)
{
- pdr = reinterpret_cast<pldm_numeric_effecter_value_pdr*>(pdrEntry.data);
+ pdr = new (pdrEntry.data) pldm_numeric_effecter_value_pdr;
if (pdr->effecter_id != effecterId)
{
pdr = nullptr;
@@ -512,7 +512,7 @@
while (pdrRecord)
{
- pdr = reinterpret_cast<pldm_numeric_effecter_value_pdr*>(pdrEntry.data);
+ pdr = new (pdrEntry.data) pldm_numeric_effecter_value_pdr;
if (pdr->effecter_id != effecterId)
{
pdr = nullptr;