Skip to content

Commit c9e1725

Browse files
Thalleykartben
authored andcommitted
Bluetooth: GATT: ASSERT instead of LOG_DBG for write length check
In bt_gatt_write_without_response_cb there is a check for write != length. However since the call to bt_att_create_pdu should ensure that this is possible, this should never happen. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent 04a1551 commit c9e1725

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5108,7 +5108,7 @@ int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
51085108
{
51095109
struct net_buf *buf;
51105110
struct bt_att_write_cmd *cmd;
5111-
size_t write;
5111+
__maybe_unused size_t write;
51125112

51135113
__ASSERT(conn, "invalid parameters\n");
51145114
__ASSERT(handle, "invalid parameters\n");
@@ -5139,11 +5139,7 @@ int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
51395139
cmd->handle = sys_cpu_to_le16(handle);
51405140

51415141
write = net_buf_append_bytes(buf, length, data, K_NO_WAIT, NULL, NULL);
5142-
if (write != length) {
5143-
LOG_DBG("Unable to allocate length %u: only %zu written", length, write);
5144-
net_buf_unref(buf);
5145-
return -ENOMEM;
5146-
}
5142+
__ASSERT(write == length, "Unable to allocate length %u: only %zu written", length, write);
51475143

51485144
LOG_DBG("handle 0x%04x length %u", handle, length);
51495145

0 commit comments

Comments
 (0)