summaryrefslogtreecommitdiff
path: root/base/HidlSupport.cpp
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2019-04-26 14:51:24 -0700
committerSteven Moreland <smoreland@google.com>2019-09-06 16:55:04 -0700
commitf0dd160cbe7c80204a2e361896f677a2bd12863f (patch)
treeb20f1fe0f84780a1f6534d8ae0357a1879b3484e /base/HidlSupport.cpp
parent48b66ef08b74440b1ca5da79d9ea9c6727a6d499 (diff)
downloadlibhidl-f0dd160cbe7c80204a2e361896f677a2bd12863f.tar.gz
Tests & stronger guarantees for hidl_* pads.
- Test that pads are zero (for future proofing, also ran tests on original implementation and bugfix). - Use -Wpadded so that compiler guarantees there aren't padding bits hiding elsewhere (there aren't) Bug: 131356202 Test: libhidl_test (without fixes, with fixes, and with this CL) Change-Id: Ib52a16015b0393c104cd984376328cb0da888b03 Merged-In: Ib52a16015b0393c104cd984376328cb0da888b03
Diffstat (limited to 'base/HidlSupport.cpp')
-rw-r--r--base/HidlSupport.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index f97f216..af805b9 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -35,10 +35,8 @@ bool debuggable() {
}
} // namespace details
-hidl_handle::hidl_handle() {
- memset(this, 0, sizeof(*this));
- // mHandle = nullptr;
- // mOwnsHandle = false;
+hidl_handle::hidl_handle() : mHandle(nullptr), mOwnsHandle(false) {
+ memset(mPad, 0, sizeof(mPad));
}
hidl_handle::~hidl_handle() {
@@ -138,11 +136,8 @@ void hidl_handle::freeHandle() {
static const char *const kEmptyString = "";
-hidl_string::hidl_string() {
- memset(this, 0, sizeof(*this));
- // mSize is zero
- // mOwnsBuffer is false
- mBuffer = kEmptyString;
+hidl_string::hidl_string() : mBuffer(kEmptyString), mSize(0), mOwnsBuffer(false) {
+ memset(mPad, 0, sizeof(mPad));
}
hidl_string::~hidl_string() {