fix(core): Fix memory copy bug for GATT
With newlib_libc enabled, a warning was printed for this memcpy. uuid is a `bt_uuid_128`, while BT_UUID_GATT_CCC is only `bt_uuid_16`. Fixes #808. Full warning: [53/272] Building C object CMakeFiles/app.dir/src/split/bluetooth/central.c.obj In file included from /home/okke/.local/zephyr-sdk-0.11.2/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/string.h:180, from /home/okke/dev/zmk/zephyr/include/bluetooth/bluetooth.h:21, from ../../src/split/bluetooth/central.c:9: ../../src/split/bluetooth/central.c: In function 'split_central_discovery_func': ../../src/split/bluetooth/central.c:130:9: warning: '__builtin_memcpy' forming offset [5, 17] is out of the bounds [0, 4] of object '({anonymous})' with type 'struct bt_uuid_16[1]' [-Warray-bounds] 130 | memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(uuid)); | ^~~~~~ /home/okke/dev/zmk/zephyr/include/bluetooth/uuid.h:72:45: note: '({anonymous})' declared here 72 | ((struct bt_uuid *) ((struct bt_uuid_16[]) {BT_UUID_INIT_16(value)})) | ^ /home/okke/dev/zmk/zephyr/include/bluetooth/uuid.h:372:2: note: in expansion of macro 'BT_UUID_DECLARE_16' 372 | BT_UUID_DECLARE_16(BT_UUID_GATT_CCC_VAL) | ^~~~~~~~~~~~~~~~~~ ../../src/split/bluetooth/central.c:130:23: note: in expansion of macro 'BT_UUID_GATT_CCC' 130 | memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(uuid));
This commit is contained in:
parent
8196b1d46b
commit
18ef73e949
1 changed files with 1 additions and 1 deletions
|
@ -127,7 +127,7 @@ static uint8_t split_central_discovery_func(struct bt_conn *conn, const struct b
|
||||||
}
|
}
|
||||||
} else if (!bt_uuid_cmp(discover_params.uuid,
|
} else if (!bt_uuid_cmp(discover_params.uuid,
|
||||||
BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID))) {
|
BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID))) {
|
||||||
memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(uuid));
|
memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(struct bt_uuid_16));
|
||||||
discover_params.uuid = &uuid.uuid;
|
discover_params.uuid = &uuid.uuid;
|
||||||
discover_params.start_handle = attr->handle + 2;
|
discover_params.start_handle = attr->handle + 2;
|
||||||
discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR;
|
discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR;
|
||||||
|
|
Loading…
Add table
Reference in a new issue