Properly align a packed structure.
Bug: http://b/31532493
Taking the address of a packed structure member only guarantees an
alignment of 1, so any use of that address could be misaligned.
Our latest toolchain will generate an error when these packed members
are accessed in an invalid manner. To remedy this, we can mark the
packed structure as having a stricter alignment (so that we can then
further reason about the packed members). We pick uint32_t because that
is the first field for this structure (and the one that is having its
address taken).
Test: Builds successfully with old and updated toolchain.
Change-Id: If98c05097953fbad8437fb04b0e207a85604ae1d
diff --git a/include/media/hardware/VideoAPI.h b/include/media/hardware/VideoAPI.h
index 3667c4b..a090876 100644
--- a/include/media/hardware/VideoAPI.h
+++ b/include/media/hardware/VideoAPI.h
@@ -110,7 +110,7 @@
// though could verify that nSize is at least the size of the structure at the
// time of implementation. All new fields will be added at the end of the structure
// ensuring backward compatibility.
-struct __attribute__ ((__packed__)) ColorAspects {
+struct __attribute__ ((__packed__, aligned(alignof(uint32_t)))) ColorAspects {
// this is in sync with the range values in graphics.h
enum Range : uint32_t {
RangeUnspecified,