Fix wrapPassthrough casts to the wrong type.
wrapPassthrough should cast to IType *, not
IBase *, for the incoming pointer.
Also, use static_cast instead of reinterpret_cast
everywhere.
Bug: 37542631
Bug: 36225019
Test: hidl_test
Change-Id: If17d6bdba4f27d402723ec5838d5f546d72fe311
diff --git a/generateCpp.cpp b/generateCpp.cpp
index c686be2..44c785b 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -634,7 +634,9 @@
out << wrappedName
<< " = "
<< iface.fqName().cppName()
- << "::castFrom(::android::hardware::details::wrapPassthrough("
+ << "::castFrom(::android::hardware::details::wrapPassthrough<"
+ << iface.fqName().cppName()
+ << ">("
<< name << "));\n";
out.sIf(wrappedName + " == nullptr", [&] {
// Fatal error. Happens when the BsFoo class is not found in the binary
@@ -1087,7 +1089,7 @@
out.indent([&] {
out << "return new "
<< iface->getStubName()
- << "(reinterpret_cast<"
+ << "(static_cast<"
<< iface->localName()
<< " *>(iIntf));\n";
});
@@ -1103,7 +1105,7 @@
out.indent([&] {
out << "return new "
<< iface->getPassthroughName()
- << "(reinterpret_cast<"
+ << "(static_cast<"
<< iface->localName()
<< " *>(iIntf));\n";
});