Skip to content

Commit ba80bc7

Browse files
theob-profabiobaltieri
authored andcommitted
Tests: Bluetooth: Fix conn_stress compilation warn
On newer GCC version warnings were emitted because of a `memcpy`. The size parameter was larger than the source's size because it was using the size of the destination, which was a `bt_uuid_128` when the source is a `bt_uuid_16`. Fix the issue by creating a new variable for CCC UUID in both the central and peripheral code. The variable need to be static because the discover parameters must remain valid until the start of the discover attribute callback. Signed-off-by: Théo Battrel <[email protected]>
1 parent c771a66 commit ba80bc7

File tree

2 files changed

+8
-4
lines changed
  • tests/bsim/bluetooth/host/misc/conn_stress

2 files changed

+8
-4
lines changed

tests/bsim/bluetooth/host/misc/conn_stress/central/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ static struct conn_info conn_infos[CONFIG_BT_MAX_CONN] = {0};
9696
static uint32_t conn_interval_max, notification_size;
9797
static uint8_t vnd_value[CHARACTERISTIC_DATA_MAX_LEN];
9898

99+
static const struct bt_uuid_16 ccc_uuid = BT_UUID_INIT_16(BT_UUID_GATT_CCC_VAL);
100+
99101
void clear_info(struct conn_info *info)
100102
{
101103
/* clear everything except the address + sub params + uuid (lifetime > connection) */
@@ -250,8 +252,8 @@ static uint8_t discover_func(struct bt_conn *conn, const struct bt_gatt_attr *at
250252

251253
} else if (conn_info_ref->discover_params.type == BT_GATT_DISCOVER_CHARACTERISTIC) {
252254
LOG_DBG("Service Characteristic Found");
253-
memcpy(&conn_info_ref->uuid, BT_UUID_GATT_CCC, sizeof(conn_info_ref->uuid));
254-
conn_info_ref->discover_params.uuid = &conn_info_ref->uuid.uuid;
255+
256+
conn_info_ref->discover_params.uuid = &ccc_uuid.uuid;
255257
conn_info_ref->discover_params.start_handle = attr->handle + 2;
256258
conn_info_ref->discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR;
257259
conn_info_ref->subscribe_params.value_handle = bt_gatt_attr_value_handle(attr);

tests/bsim/bluetooth/host/misc/conn_stress/peripheral/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ static struct bt_uuid_128 uuid = BT_UUID_INIT_128(0);
9494
static struct bt_gatt_discover_params discover_params;
9595
static struct bt_gatt_subscribe_params subscribe_params;
9696

97+
static const struct bt_uuid_16 ccc_uuid = BT_UUID_INIT_16(BT_UUID_GATT_CCC_VAL);
98+
9799
static void vnd_ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
98100
{
99101
central_subscription = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0;
@@ -277,8 +279,8 @@ static uint8_t discover_func(struct bt_conn *conn, const struct bt_gatt_attr *at
277279

278280
} else if (discover_params.type == BT_GATT_DISCOVER_CHARACTERISTIC) {
279281
LOG_DBG("Service Characteristic Found");
280-
memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(uuid));
281-
params->uuid = &uuid.uuid;
282+
283+
params->uuid = &ccc_uuid.uuid;
282284
params->start_handle = attr->handle + 2;
283285
params->type = BT_GATT_DISCOVER_DESCRIPTOR;
284286
subscribe_params.value_handle = bt_gatt_attr_value_handle(attr);

0 commit comments

Comments
 (0)