summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2021-01-21 23:01:06 +0000
committerSteven Moreland <smoreland@google.com>2021-01-22 00:43:06 +0000
commitac842581b195db5861c5a3c9e5d55a067564a64c (patch)
tree651571d70c9fceb9fd53df1632bf4ffca5b8ac6a /base
parent57341bb19f7782cefb3f762bad6601fbd635df5e (diff)
downloadlibhidl-ac842581b195db5861c5a3c9e5d55a067564a64c.tar.gz
HidlInstrumentor - fix w/ Wpadded
For reasons unrelated to HidlInstrumentor, -Wpadded is enabled in libhidl_test for this class. However, due to (a bug in?) -Wpadded not looking into protected fields, this error is only caught in certain versions of clang or in clang tidy. Bug: 178056347 Test: static_asserting size of this struct (it's unfortunately exported and used by HIDL generated libs which freeze the ABI), and manually checking offsets of these fields. This was also verified locally by temporarily opening up visibility, such that compiling libhidl_test checks for padding here. Change-Id: I7e883f74b2ecba1bb5100723e114bd48245c6b7a
Diffstat (limited to 'base')
-rw-r--r--base/include/hidl/HidlInternal.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/base/include/hidl/HidlInternal.h b/base/include/hidl/HidlInternal.h
index 3cd246a..3d1a444 100644
--- a/base/include/hidl/HidlInternal.h
+++ b/base/include/hidl/HidlInternal.h
@@ -201,7 +201,10 @@ struct HidlInstrumentor {
// A list of registered instrumentation callbacks.
std::vector<InstrumentationCallback> mInstrumentationCallbacks;
// Flag whether to enable instrumentation.
- bool mEnableInstrumentation;
+ union {
+ bool mEnableInstrumentation;
+ void* mReserved0;
+ };
// Prefix to lookup the instrumentation libraries.
std::string mInstrumentationLibPackage;
// Used for dlsym to load the profiling method for given interface.
@@ -209,6 +212,12 @@ struct HidlInstrumentor {
};
+#ifdef __LP64__
+static_assert(sizeof(HidlInstrumentor) == 88, "HidlInstrumentor size frozen by prebuilts");
+#else
+static_assert(sizeof(HidlInstrumentor) == 44, "HidlInstrumentor size frozen by prebuilts");
+#endif
+
} // namespace details
} // namespace hardware
} // namespace android