Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14609584 authored by Stephen Hines's avatar Stephen Hines Committed by Jakub Pawlowski
Browse files

Properly align some packed data structures.

Bug: http://b/31532493

Test: Built with -Waddress-of-packed-member enabled.

These data structures later take the address of their uuid field, which
results in a possibly unaligned access to the underlying data. To
prevent the misalignment, we add a further attribute to ensure that the
base of these packed structures is aligned at least as much as the uuid
data member requires (so we can continue using the address of it for
direct dereferences).

Change-Id: I3ec6945b6ea343bef11326a10343309a863786cf
parent c4767468
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -514,7 +514,7 @@ typedef struct {
  uint16_t e_handle;
  list_t* characteristics; /* list of tBTA_GATTC_CHARACTERISTIC */
  list_t* included_svc;    /* list of tBTA_GATTC_INCLUDED_SVC */
} __attribute__((packed)) tBTA_GATTC_SERVICE;
} __attribute__((packed, aligned(alignof(tBT_UUID)))) tBTA_GATTC_SERVICE;

typedef struct {
  tBT_UUID uuid;
@@ -522,7 +522,7 @@ typedef struct {
  tBTA_GATT_CHAR_PROP properties;
  tBTA_GATTC_SERVICE* service; /* owning service*/
  list_t* descriptors;         /* list of tBTA_GATTC_DESCRIPTOR */
} __attribute__((packed)) tBTA_GATTC_CHARACTERISTIC;
} __attribute__((packed, aligned(alignof(tBT_UUID)))) tBTA_GATTC_CHARACTERISTIC;

typedef struct {
  tBT_UUID uuid;