From 442a0686fc0209518809624286e396b5cc11ac38 Mon Sep 17 00:00:00 2001 From: Pisit Sawangvonganan Date: Wed, 21 Aug 2024 04:02:14 +0700 Subject: [PATCH] style: tests: comply with MISRA C:2012 Rule 15.6 Add missing braces to comply with MISRA C:2012 Rule 15.6 and also following Zephyr's style guideline. Signed-off-by: Pisit Sawangvonganan --- tests/arch/common/timing/src/main.c | 3 +- .../edtt/gatt_test_app/src/gatt/service_a_1.c | 18 ++- .../edtt/gatt_test_app/src/gatt/service_a_2.c | 12 +- .../edtt/gatt_test_app/src/gatt/service_a_3.c | 12 +- .../gatt_test_app/src/gatt/service_b_1_1.c | 18 ++- .../gatt_test_app/src/gatt/service_b_1_2.c | 6 +- .../gatt_test_app/src/gatt/service_b_1_3.c | 6 +- .../gatt_test_app/src/gatt/service_b_2_1.c | 9 +- .../gatt_test_app/src/gatt/service_b_2_2.c | 6 +- .../gatt_test_app/src/gatt/service_b_2_3.c | 6 +- .../gatt_test_app/src/gatt/service_b_3_1.c | 6 +- .../gatt_test_app/src/gatt/service_b_3_2.c | 6 +- .../gatt_test_app/src/gatt/service_b_4_1.c | 6 +- .../gatt_test_app/src/gatt/service_b_4_2.c | 6 +- .../gatt_test_app/src/gatt/service_b_4_3.c | 6 +- .../gatt_test_app/src/gatt/service_b_5_1.c | 30 +++-- .../gatt_test_app/src/gatt/service_c_1_1.c | 18 ++- .../gatt_test_app/src/gatt/service_c_1_2.c | 18 ++- .../gatt_test_app/src/gatt/service_c_1_3.c | 18 ++- .../gatt_test_app/src/gatt/service_c_2_1.c | 120 ++++++++++++------ .../gatt_test_app/src/gatt/service_c_2_2.c | 36 ++++-- .../gatt_test_app/src/gatt/service_c_2_3.c | 36 ++++-- .../edtt/gatt_test_app/src/gatt/service_d_1.c | 3 +- .../edtt/gatt_test_app/src/gatt/service_f_1.c | 18 ++- .../bluetooth/ll/edtt/hci_test_app/src/main.c | 5 +- tests/posix/fs/src/test_fs_file.c | 3 +- 26 files changed, 287 insertions(+), 144 deletions(-) diff --git a/tests/arch/common/timing/src/main.c b/tests/arch/common/timing/src/main.c index 83ff500a11436c..7f9f078fa8e6c1 100644 --- a/tests/arch/common/timing/src/main.c +++ b/tests/arch/common/timing/src/main.c @@ -112,8 +112,9 @@ ZTEST(arch_timing, test_arch_timing_smp) k_thread_start(&threads[i]); } - for (i = 0; i < num_threads; i++) + for (i = 0; i < num_threads; i++) { k_thread_join(&threads[i], K_FOREVER); + } } #else ZTEST(arch_timing, test_arch_timing_smp) diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_1.c index db89ef97784551..7dcace35ebf0a0 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_1.c @@ -152,10 +152,12 @@ static ssize_t write_value_v2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_value)) + if (offset >= sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_value)) + } + if (offset + len > sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -182,10 +184,12 @@ static ssize_t write_value_v2_1(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_1_value)) + if (offset >= sizeof(value_v2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_1_value)) + } + if (offset + len > sizeof(value_v2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -211,10 +215,12 @@ static ssize_t write_value_v3(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v3_value)) + if (offset >= sizeof(value_v3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v3_value)) + } + if (offset + len > sizeof(value_v3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_2.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_2.c index 831d3e49bb5cd8..b209eb966e25c3 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_2.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_2.c @@ -111,10 +111,12 @@ static ssize_t write_value_v2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_value)) + if (offset >= sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_value)) + } + if (offset + len > sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -140,10 +142,12 @@ static ssize_t write_value_v3(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v3_value)) + if (offset >= sizeof(value_v3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v3_value)) + } + if (offset + len > sizeof(value_v3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_3.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_3.c index 2fb226df6a91dd..78f8cdcaa6eb21 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_3.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_a_3.c @@ -111,10 +111,12 @@ static ssize_t write_value_v2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_value)) + if (offset >= sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_value)) + } + if (offset + len > sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -140,10 +142,12 @@ static ssize_t write_value_v3(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v3_value)) + if (offset >= sizeof(value_v3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v3_value)) + } + if (offset + len > sizeof(value_v3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_1.c index cc34a404864fee..a64194ae9a27f7 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_1.c @@ -95,10 +95,12 @@ static ssize_t write_value_v4(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v4_value)) + if (offset >= sizeof(value_v4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v4_value)) + } + if (offset + len > sizeof(value_v4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -147,10 +149,12 @@ static ssize_t write_value_v4_1(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v4_1_value)) + if (offset >= sizeof(value_v4_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v4_1_value)) + } + if (offset + len > sizeof(value_v4_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -204,10 +208,12 @@ static ssize_t write_server_cha_con(struct bt_conn *conn, uint16_t *value = attr->user_data; uint16_t server_cha_con_conv = sys_cpu_to_le16(*value); - if (offset >= sizeof(server_cha_con_value)) + if (offset >= sizeof(server_cha_con_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(server_cha_con_value)) + } + if (offset + len > sizeof(server_cha_con_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy((uint8_t *)&server_cha_con_conv + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_2.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_2.c index f73fb657d9ebe0..37948ee0fa1f1b 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_2.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_2.c @@ -69,10 +69,12 @@ static ssize_t write_value_v4(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v4_value)) + if (offset >= sizeof(value_v4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v4_value)) + } + if (offset + len > sizeof(value_v4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_3.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_3.c index 0b397f15e0ab1d..3438cfa1ed032f 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_3.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_1_3.c @@ -69,10 +69,12 @@ static ssize_t write_value_v4(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v4_value)) + if (offset >= sizeof(value_v4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v4_value)) + } + if (offset + len > sizeof(value_v4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_1.c index 5cafbbd59a0ef6..f8f544f2eab6cf 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_1.c @@ -87,12 +87,15 @@ static ssize_t write_value_v5(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v5_value)) + if (offset >= sizeof(value_v5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v5_value)) + } + if (offset + len > sizeof(value_v5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); - if (!bAuthorized) + } + if (!bAuthorized) { return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_2.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_2.c index 7cc44c047db430..ce5868d1d62d63 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_2.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_2.c @@ -86,10 +86,12 @@ static ssize_t write_value_v5(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v5_value)) + if (offset >= sizeof(value_v5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v5_value)) + } + if (offset + len > sizeof(value_v5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_3.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_3.c index bb73a58fa80a0d..57a7f64cf3ec0a 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_3.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_2_3.c @@ -86,10 +86,12 @@ static ssize_t write_value_v5(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v5_value)) + if (offset >= sizeof(value_v5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v5_value)) + } + if (offset + len > sizeof(value_v5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_3_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_3_1.c index d9bbb46d06f1d5..b3b8609d8e9952 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_3_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_3_1.c @@ -70,10 +70,12 @@ static ssize_t write_value_v6(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v6_value)) + if (offset >= sizeof(value_v6_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v6_value)) + } + if (offset + len > sizeof(value_v6_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_3_2.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_3_2.c index 1a57ff7cf00b21..b2455e172f4b4f 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_3_2.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_3_2.c @@ -72,10 +72,12 @@ static ssize_t write_value_v6(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v6_value)) + if (offset >= sizeof(value_v6_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v6_value)) + } + if (offset + len > sizeof(value_v6_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_1.c index 51c3ee4a2e73a2..4694a7eff71a09 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_1.c @@ -47,10 +47,12 @@ static ssize_t write_value_v7(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v7_value)) + if (offset >= sizeof(value_v7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v7_value)) + } + if (offset + len > sizeof(value_v7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_2.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_2.c index 96b7dc4ad9473f..8ce5b32be697ce 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_2.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_2.c @@ -47,10 +47,12 @@ static ssize_t write_value_v7(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v7_value)) + if (offset >= sizeof(value_v7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v7_value)) + } + if (offset + len > sizeof(value_v7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_3.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_3.c index 8e5df398c6d7b6..9cbca7e72f8e6a 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_3.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_4_3.c @@ -47,10 +47,12 @@ static ssize_t write_value_v7(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v7_value)) + if (offset >= sizeof(value_v7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v7_value)) + } + if (offset + len > sizeof(value_v7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_5_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_5_1.c index 2c3334d530aaea..36e82deb955bb6 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_5_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_b_5_1.c @@ -88,10 +88,12 @@ static ssize_t write_value_v8(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v8_value)) + if (offset >= sizeof(value_v8_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v8_value)) + } + if (offset + len > sizeof(value_v8_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -139,10 +141,12 @@ static ssize_t write_des_v8d1(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v8d1_value)) + if (offset >= sizeof(des_v8d1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v8d1_value)) + } + if (offset + len > sizeof(des_v8d1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -167,8 +171,9 @@ static ssize_t read_des_v8d2(struct bt_conn *conn, { const uint8_t *value = attr->user_data; - if (!bAuthorized) + if (!bAuthorized) { return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); + } return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(des_v8d2_value)); @@ -193,12 +198,15 @@ static ssize_t write_des_v8d2(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v8d2_value)) + if (offset >= sizeof(des_v8d2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v8d2_value)) + } + if (offset + len > sizeof(des_v8d2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); - if (!bAuthorized) + } + if (!bAuthorized) { return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); + } memcpy(value + offset, buf, len); @@ -246,10 +254,12 @@ static ssize_t write_des_v8d3(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v8d3_value)) + if (offset >= sizeof(des_v8d3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v8d3_value)) + } + if (offset + len > sizeof(des_v8d3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_1.c index b9668a9fa8e90a..7cee1f9eed7253 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_1.c @@ -93,10 +93,12 @@ static ssize_t write_value_v9__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v9__128_bit_uuid_value)) + if (offset >= sizeof(value_v9__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v9__128_bit_uuid_value)) + } + if (offset + len > sizeof(value_v9__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -147,10 +149,12 @@ static ssize_t write_des_v9d2__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v9d2__128_bit_uuid_value)) + if (offset >= sizeof(des_v9d2__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v9d2__128_bit_uuid_value)) + } + if (offset + len > sizeof(des_v9d2__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -178,10 +182,12 @@ static ssize_t write_des_v9d3__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v9d3__128_bit_uuid_value)) + if (offset >= sizeof(des_v9d3__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v9d3__128_bit_uuid_value)) + } + if (offset + len > sizeof(des_v9d3__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_2.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_2.c index c148ee2a7a540c..dac223b836b2e1 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_2.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_2.c @@ -93,10 +93,12 @@ static ssize_t write_value_v9__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v9__128_bit_uuid_value)) + if (offset >= sizeof(value_v9__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v9__128_bit_uuid_value)) + } + if (offset + len > sizeof(value_v9__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -147,10 +149,12 @@ static ssize_t write_des_v9d2__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v9d2__128_bit_uuid_value)) + if (offset >= sizeof(des_v9d2__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v9d2__128_bit_uuid_value)) + } + if (offset + len > sizeof(des_v9d2__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -178,10 +182,12 @@ static ssize_t write_des_v9d3__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v9d3__128_bit_uuid_value)) + if (offset >= sizeof(des_v9d3__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v9d3__128_bit_uuid_value)) + } + if (offset + len > sizeof(des_v9d3__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_3.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_3.c index 04d8b06c0e51cd..f26feb2692890d 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_3.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_1_3.c @@ -91,10 +91,12 @@ static ssize_t write_value_v9__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v9__128_bit_uuid_value)) + if (offset >= sizeof(value_v9__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v9__128_bit_uuid_value)) + } + if (offset + len > sizeof(value_v9__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -145,10 +147,12 @@ static ssize_t write_des_v9d2__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v9d2__128_bit_uuid_value)) + if (offset >= sizeof(des_v9d2__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v9d2__128_bit_uuid_value)) + } + if (offset + len > sizeof(des_v9d2__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -176,10 +180,12 @@ static ssize_t write_des_v9d3__128_bit_uuid(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(des_v9d3__128_bit_uuid_value)) + if (offset >= sizeof(des_v9d3__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(des_v9d3__128_bit_uuid_value)) + } + if (offset + len > sizeof(des_v9d3__128_bit_uuid_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_1.c index 60af803288eb35..c78ebd53c7d9f2 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_1.c @@ -214,10 +214,12 @@ static ssize_t write_value_v2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_value)) + if (offset >= sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_value)) + } + if (offset + len > sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -266,10 +268,12 @@ static ssize_t write_long_des_v2d1(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d1_value)) + if (offset >= sizeof(long_des_v2d1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d1_value)) + } + if (offset + len > sizeof(long_des_v2d1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -296,10 +300,12 @@ static ssize_t write_value_v2_1(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_1_value)) + if (offset >= sizeof(value_v2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_1_value)) + } + if (offset + len > sizeof(value_v2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -348,10 +354,12 @@ static ssize_t write_long_des_v2d2(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d2_value)) + if (offset >= sizeof(long_des_v2d2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d2_value)) + } + if (offset + len > sizeof(long_des_v2d2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -378,10 +386,12 @@ static ssize_t write_value_v2_2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_2_value)) + if (offset >= sizeof(value_v2_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_2_value)) + } + if (offset + len > sizeof(value_v2_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -430,10 +440,12 @@ static ssize_t write_long_des_v2d3(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d3_value)) + if (offset >= sizeof(long_des_v2d3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d3_value)) + } + if (offset + len > sizeof(long_des_v2d3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -482,10 +494,12 @@ static ssize_t write_value_v2_3(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v2_3_value)) + if (offset >= sizeof(value_v2_3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_3_value)) + } + if (offset + len > sizeof(value_v2_3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -534,10 +548,12 @@ static ssize_t write_long_des_v2d1_1(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d1_1_value)) + if (offset >= sizeof(long_des_v2d1_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d1_1_value)) + } + if (offset + len > sizeof(long_des_v2d1_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -586,10 +602,12 @@ static ssize_t write_value_v2_4(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v2_4_value)) + if (offset >= sizeof(value_v2_4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_4_value)) + } + if (offset + len > sizeof(value_v2_4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -638,10 +656,12 @@ static ssize_t write_long_des_v2d2_1(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d2_1_value)) + if (offset >= sizeof(long_des_v2d2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d2_1_value)) + } + if (offset + len > sizeof(long_des_v2d2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -690,10 +710,12 @@ static ssize_t write_value_v2_5(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v2_5_value)) + if (offset >= sizeof(value_v2_5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_5_value)) + } + if (offset + len > sizeof(value_v2_5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -742,10 +764,12 @@ static ssize_t write_long_des_v2d3_1(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d3_1_value)) + if (offset >= sizeof(long_des_v2d3_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d3_1_value)) + } + if (offset + len > sizeof(long_des_v2d3_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -772,10 +796,12 @@ static ssize_t write_value_v2_6(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_6_value)) + if (offset >= sizeof(value_v2_6_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_6_value)) + } + if (offset + len > sizeof(value_v2_6_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -824,10 +850,12 @@ static ssize_t write_long_des_v2d1_2(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d1_2_value)) + if (offset >= sizeof(long_des_v2d1_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d1_2_value)) + } + if (offset + len > sizeof(long_des_v2d1_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -852,8 +880,9 @@ static ssize_t read_str_auth_value(struct bt_conn *conn, { const char *value = attr->user_data; - if (!bAuthorized) + if (!bAuthorized) { return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); + } return bt_gatt_attr_read(conn, attr, buf, len, offset, value, strlen(value)); } @@ -878,12 +907,15 @@ static ssize_t write_value_v2_7(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_7_value)) + if (offset >= sizeof(value_v2_7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_7_value)) + } + if (offset + len > sizeof(value_v2_7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); - if (!bAuthorized) + } + if (!bAuthorized) { return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); + } memcpy(value + offset, buf, len); @@ -908,8 +940,9 @@ static ssize_t read_long_des_v2d2_2(struct bt_conn *conn, { const uint8_t *value = attr->user_data; - if (!bAuthorized) + if (!bAuthorized) { return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); + } return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(long_des_v2d2_2_value)); @@ -935,12 +968,15 @@ static ssize_t write_long_des_v2d2_2(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d2_2_value)) + if (offset >= sizeof(long_des_v2d2_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d2_2_value)) + } + if (offset + len > sizeof(long_des_v2d2_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); - if (!bAuthorized) + } + if (!bAuthorized) { return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); + } memcpy(value + offset, buf, len); @@ -967,10 +1003,12 @@ static ssize_t write_value_v2_8(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_8_value)) + if (offset >= sizeof(value_v2_8_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_8_value)) + } + if (offset + len > sizeof(value_v2_8_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -1019,10 +1057,12 @@ static ssize_t write_long_des_v2d3_2(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(long_des_v2d3_2_value)) + if (offset >= sizeof(long_des_v2d3_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(long_des_v2d3_2_value)) + } + if (offset + len > sizeof(long_des_v2d3_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_2.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_2.c index f3e1c10aafbf8b..499611483527b4 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_2.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_2.c @@ -128,10 +128,12 @@ static ssize_t write_value_v2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_value)) + if (offset >= sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_value)) + } + if (offset + len > sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -158,10 +160,12 @@ static ssize_t write_value_v2_1(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_1_value)) + if (offset >= sizeof(value_v2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_1_value)) + } + if (offset + len > sizeof(value_v2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -188,10 +192,12 @@ static ssize_t write_value_v2_2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_2_value)) + if (offset >= sizeof(value_v2_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_2_value)) + } + if (offset + len > sizeof(value_v2_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -218,10 +224,12 @@ static ssize_t write_value_v2_3(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_3_value)) + if (offset >= sizeof(value_v2_3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_3_value)) + } + if (offset + len > sizeof(value_v2_3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -248,10 +256,12 @@ static ssize_t write_value_v2_4(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_4_value)) + if (offset >= sizeof(value_v2_4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_4_value)) + } + if (offset + len > sizeof(value_v2_4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -278,10 +288,12 @@ static ssize_t write_value_v2_5(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_5_value)) + if (offset >= sizeof(value_v2_5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_5_value)) + } + if (offset + len > sizeof(value_v2_5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_3.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_3.c index 0040c2e237460d..7aa7bd545c9584 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_3.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_c_2_3.c @@ -128,10 +128,12 @@ static ssize_t write_value_v2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_value)) + if (offset >= sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_value)) + } + if (offset + len > sizeof(value_v2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -158,10 +160,12 @@ static ssize_t write_value_v2_1(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_1_value)) + if (offset >= sizeof(value_v2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_1_value)) + } + if (offset + len > sizeof(value_v2_1_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -188,10 +192,12 @@ static ssize_t write_value_v2_2(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_2_value)) + if (offset >= sizeof(value_v2_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_2_value)) + } + if (offset + len > sizeof(value_v2_2_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -218,10 +224,12 @@ static ssize_t write_value_v2_3(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_3_value)) + if (offset >= sizeof(value_v2_3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_3_value)) + } + if (offset + len > sizeof(value_v2_3_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -248,10 +256,12 @@ static ssize_t write_value_v2_4(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_4_value)) + if (offset >= sizeof(value_v2_4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_4_value)) + } + if (offset + len > sizeof(value_v2_4_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -278,10 +288,12 @@ static ssize_t write_value_v2_5(struct bt_conn *conn, { char *value = attr->user_data; - if (offset >= sizeof(value_v2_5_value)) + if (offset >= sizeof(value_v2_5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v2_5_value)) + } + if (offset + len > sizeof(value_v2_5_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_d_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_d_1.c index 82c9fbeb5bfb29..e8f279e066be66 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_d_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_d_1.c @@ -79,8 +79,9 @@ static ssize_t read_value_v11__128_bit_uuid(struct bt_conn *conn, { const uint8_t *value = attr->user_data; - if (!bAuthorized) + if (!bAuthorized) { return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); + } return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(value_v11__128_bit_uuid_value)); diff --git a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_f_1.c b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_f_1.c index 4bdb61c760a05a..374e639862af77 100644 --- a/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_f_1.c +++ b/tests/bsim/bluetooth/ll/edtt/gatt_test_app/src/gatt/service_f_1.c @@ -149,10 +149,12 @@ static ssize_t write_value_v15(struct bt_conn *conn, { uint8_t *value = attr->user_data; - if (offset >= sizeof(value_v15_value)) + if (offset >= sizeof(value_v15_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v15_value)) + } + if (offset + len > sizeof(value_v15_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy(value + offset, buf, len); @@ -202,10 +204,12 @@ static ssize_t write_value_v6(struct bt_conn *conn, uint16_t *value = attr->user_data; uint16_t value_v6_conv = sys_cpu_to_le16(*value); - if (offset >= sizeof(value_v6_value)) + if (offset >= sizeof(value_v6_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v6_value)) + } + if (offset + len > sizeof(value_v6_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy((uint8_t *)&value_v6_conv + offset, buf, len); @@ -257,10 +261,12 @@ static ssize_t write_value_v7(struct bt_conn *conn, uint32_t *value = attr->user_data; uint32_t value_v7_conv = sys_cpu_to_le32(*value); - if (offset >= sizeof(value_v7_value)) + if (offset >= sizeof(value_v7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); - if (offset + len > sizeof(value_v7_value)) + } + if (offset + len > sizeof(value_v7_value)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); + } memcpy((uint8_t *)&value_v7_conv + offset, buf, len); diff --git a/tests/bsim/bluetooth/ll/edtt/hci_test_app/src/main.c b/tests/bsim/bluetooth/ll/edtt/hci_test_app/src/main.c index 33a9ed27b5d225..3d28b07b571aa6 100644 --- a/tests/bsim/bluetooth/ll/edtt/hci_test_app/src/main.c +++ b/tests/bsim/bluetooth/ll/edtt/hci_test_app/src/main.c @@ -819,10 +819,11 @@ int main(void) edtt_read((uint8_t *)&multiple, sizeof(multiple), EDTTT_BLOCK); - if (multiple) + if (multiple) { get_events(--size); - else + } else { get_event(--size); + } } break; case CMD_LE_FLUSH_DATA_REQ: diff --git a/tests/posix/fs/src/test_fs_file.c b/tests/posix/fs/src/test_fs_file.c index 4a22270ea13ab3..bfe2bc19515edf 100644 --- a/tests/posix/fs/src/test_fs_file.c +++ b/tests/posix/fs/src/test_fs_file.c @@ -165,8 +165,9 @@ static int test_file_fdatasync(void) { int res = 0; - if (file < 0) + if (file < 0) { return res; + } res = fdatasync(file); if (res < 0) {