Use hidl_pointer<native_handle_t> in MQDescriptor
Bug: 33467211
Test: Built and ran 32-bit FMQ unit tests
To fix issues with passing handles between 32 bit processes
over hwbinder, use a hidl_pointer<native_handle_t> instead.
Change-Id: Id039c9577a661e0268c8effe493d5f7cebdb510d
diff --git a/base/include/hidl/MQDescriptor.h b/base/include/hidl/MQDescriptor.h
index 8292035..ebd0911 100644
--- a/base/include/hidl/MQDescriptor.h
+++ b/base/include/hidl/MQDescriptor.h
@@ -100,7 +100,7 @@
enum GrantorType : int { READPTRPOS = 0, WRITEPTRPOS, DATAPTRPOS };
private:
::android::hardware::hidl_vec<GrantorDescriptor> mGrantors;
- ::native_handle_t *mHandle;
+ ::android::hardware::details::hidl_pointer<native_handle_t> mHandle;
uint32_t mQuantum;
uint32_t mFlags;
};
@@ -175,11 +175,10 @@
other.mHandle->numFds, other.mHandle->numInts);
for (int i = 0; i < other.mHandle->numFds; ++i) {
- const_cast<native_handle_t *>(mHandle)->data[i] =
- dup(other.mHandle->data[i]);
+ mHandle->data[i] = dup(other.mHandle->data[i]);
}
- memcpy(&const_cast<native_handle_t *>(mHandle)->data[other.mHandle->numFds],
+ memcpy(&mHandle->data[other.mHandle->numFds],
&other.mHandle->data[other.mHandle->numFds],
other.mHandle->numInts * sizeof(int));
}
@@ -188,8 +187,8 @@
template<MQFlavor flavor>
MQDescriptor<flavor>::~MQDescriptor() {
if (mHandle != nullptr) {
- native_handle_close(const_cast<native_handle_t *>(mHandle));
- native_handle_delete(const_cast<native_handle_t *>(mHandle));
+ native_handle_close(mHandle);
+ native_handle_delete(mHandle);
}
}