tests: 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: Ifab9ea58b932db11d7af0b9def119bed1bfdc44d
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/libpldmresponder/test/libpldmresponder_bios_enum_attribute_test.cpp b/libpldmresponder/test/libpldmresponder_bios_enum_attribute_test.cpp
index 1521fcb..356ccc6 100644
--- a/libpldmresponder/test/libpldmresponder_bios_enum_attribute_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_bios_enum_attribute_test.cpp
@@ -233,8 +233,6 @@
setDbusProperty(dbusMapping, PropertyValue{bool(true)}))
.Times(1);
enumReadWrite.setAttrValueOnDbus(
- reinterpret_cast<pldm_bios_attr_val_table_entry*>(
- attrValueEntry.data()),
- reinterpret_cast<pldm_bios_attr_table_entry*>(attrEntry.data()),
- biosStringTable);
+ new (attrValueEntry.data()) pldm_bios_attr_val_table_entry,
+ new (attrEntry.data()) pldm_bios_attr_table_entry, biosStringTable);
}