Bluetooth: common: Add build asserts for address struct sizes
In some HCI packed structures we place non-packed structs inside (in particular the address structs). Alignment is not an issue for those because all their members are just byte-aligned, but size is. If the compiler ever packs those it would become a real problem, and so detect this at build time. See the link below for more info: https://stackoverflow.com/a/66389167 Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
da31a33905
commit
301a7103a0
2 changed files with 19 additions and 1 deletions
|
@ -10,6 +10,17 @@
|
|||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <bluetooth/bluetooth.h>
|
||||
|
||||
/*
|
||||
* The unpacked structs below are used inside __packed structures that reflect
|
||||
* what goes on the wire. While alignment is not a problem for those, since all
|
||||
* their members are bytes or byte arrays, the size is. They must not be padded
|
||||
* by the compiler, otherwise the on-wire packet will not map the packed
|
||||
* structure correctly.
|
||||
*/
|
||||
BUILD_ASSERT(sizeof(bt_addr_t) == BT_ADDR_SIZE);
|
||||
BUILD_ASSERT(sizeof(bt_addr_le_t) == BT_ADDR_LE_SIZE);
|
||||
|
||||
#if defined(CONFIG_BT_HCI_HOST)
|
||||
/* The Bluetooth subsystem requires the Tx thread to execute at higher priority
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue