Bluetooth: GATT: Fix bug in bt_gatt_attr_next unable for static handles

Fix bug in bt_gatt_attr_next when given an attribute that has static
allocation. The handle is then 0 and the function would always return
the attribute with handle 1.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2019-10-14 10:06:20 +02:00 committed by Carles Cufí
commit 8ff183eb6c

View file

@ -1306,9 +1306,9 @@ static u8_t find_next(const struct bt_gatt_attr *attr, void *user_data)
struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr)
{
struct bt_gatt_attr *next = NULL;
u16_t handle = attr->handle ? : find_static_attr(attr);
bt_gatt_foreach_attr(attr->handle + 1, attr->handle + 1, find_next,
&next);
bt_gatt_foreach_attr(handle + 1, handle + 1, find_next, &next);
return next;
}