Skip to content

Commit 4fc6f12

Browse files
Thalleykartben
authored andcommitted
Bluetooth: TBS: Fix return value of handle_string_long_read
The function may return a BT_GATT_ERR which is a negative value that cannot be returned as uint8_t. Change the function to use int instead and document the return values. Signed-off-by: Emil Gydesen <[email protected]>
1 parent f53c4db commit 4fc6f12

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

subsys/bluetooth/audio/tbs_client.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,13 @@ static bool can_add_string_to_net_buf(const struct net_buf_simple *buf, size_t l
855855
return buf->len + len + sizeof('\0') <= buf->size;
856856
}
857857

858-
/* Common function to read tbs_client strings which may require long reads */
859-
static uint8_t handle_string_long_read(struct bt_tbs_instance *inst, uint8_t err, const void *data,
860-
uint16_t offset, uint16_t length, bool truncatable)
858+
/**
859+
* Common function to read tbs_client strings which may require long reads
860+
*
861+
* @return BT_GATT_ITER_CONTINUE, BT_GATT_ITER_STOP or a negative value if there's an error
862+
*/
863+
static int handle_string_long_read(struct bt_tbs_instance *inst, uint8_t err, const void *data,
864+
uint16_t offset, uint16_t length, bool truncatable)
861865
{
862866
if (err != 0) {
863867
LOG_DBG("err: %u", err);
@@ -889,7 +893,9 @@ static uint8_t handle_string_long_read(struct bt_tbs_instance *inst, uint8_t err
889893

890894
return BT_GATT_ITER_CONTINUE;
891895
}
892-
}
896+
} /* else we are done reading and since the buffer is always 0-initialized, it will have the
897+
* NULL terminator automatically
898+
*/
893899

894900
return BT_GATT_ITER_STOP;
895901
}

0 commit comments

Comments
 (0)