Skip to content

Commit ea7a185

Browse files
joerchancarlescufi
authored andcommitted
Bluetooth: GATT: Fix taking address of packed member of struct sc_data.
Fix GCC9 warning "warning: taking address of packed member of 'struct sc_data' may result in an unaligned pointer value" Issue is that the on-air structure of sc_data was re-used for the gatt service changed data. Added build assert because data is stored in settings, so the structure should be the same size to be compatible. Signed-off-by: Joakim Andersson <[email protected]>
1 parent eb2c330 commit ea7a185

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,15 @@ struct sc_data {
191191
struct gatt_sc_cfg {
192192
u8_t id;
193193
bt_addr_le_t peer;
194-
struct sc_data data;
194+
struct {
195+
u16_t start;
196+
u16_t end;
197+
} data;
195198
};
196199

197200
#define SC_CFG_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
198201
static struct gatt_sc_cfg sc_cfg[SC_CFG_MAX];
202+
BUILD_ASSERT(sizeof(struct sc_data) == sizeof(sc_cfg[0].data));
199203

200204
static struct gatt_sc_cfg *find_sc_cfg(u8_t id, bt_addr_le_t *addr)
201205
{

0 commit comments

Comments
 (0)