Bluetooth: host: Don't use struct with zero size
Don't use the ATT structs that has contains only a flexible array member. This is not supported by C99 standard, only through GNU C extension with zero length array. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
7c5ab5873a
commit
b5bf46fe3c
3 changed files with 13 additions and 22 deletions
|
@ -1231,7 +1231,6 @@ struct read_data {
|
||||||
struct bt_att_chan *chan;
|
struct bt_att_chan *chan;
|
||||||
uint16_t offset;
|
uint16_t offset;
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
struct bt_att_read_rsp *rsp;
|
|
||||||
uint8_t err;
|
uint8_t err;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1245,8 +1244,6 @@ static uint8_t read_cb(const struct bt_gatt_attr *attr, uint16_t handle,
|
||||||
|
|
||||||
BT_DBG("handle 0x%04x", handle);
|
BT_DBG("handle 0x%04x", handle);
|
||||||
|
|
||||||
data->rsp = net_buf_add(data->buf, sizeof(*data->rsp));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If any attribute is founded in handle range it means that error
|
* If any attribute is founded in handle range it means that error
|
||||||
* should be changed from pre-set: invalid handle error to no error.
|
* should be changed from pre-set: invalid handle error to no error.
|
||||||
|
@ -1401,8 +1398,6 @@ static uint8_t read_vl_cb(const struct bt_gatt_attr *attr, uint16_t handle,
|
||||||
|
|
||||||
BT_DBG("handle 0x%04x", handle);
|
BT_DBG("handle 0x%04x", handle);
|
||||||
|
|
||||||
data->rsp = net_buf_add(data->buf, sizeof(*data->rsp));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If any attribute is founded in handle range it means that error
|
* If any attribute is founded in handle range it means that error
|
||||||
* should be changed from pre-set: invalid handle error to no error.
|
* should be changed from pre-set: invalid handle error to no error.
|
||||||
|
@ -2316,7 +2311,7 @@ static const struct att_handler {
|
||||||
ATT_RESPONSE,
|
ATT_RESPONSE,
|
||||||
att_handle_find_info_rsp },
|
att_handle_find_info_rsp },
|
||||||
{ BT_ATT_OP_FIND_TYPE_RSP,
|
{ BT_ATT_OP_FIND_TYPE_RSP,
|
||||||
sizeof(struct bt_att_find_type_rsp),
|
sizeof(struct bt_att_handle_group),
|
||||||
ATT_RESPONSE,
|
ATT_RESPONSE,
|
||||||
att_handle_find_type_rsp },
|
att_handle_find_type_rsp },
|
||||||
{ BT_ATT_OP_READ_TYPE_RSP,
|
{ BT_ATT_OP_READ_TYPE_RSP,
|
||||||
|
@ -2324,16 +2319,16 @@ static const struct att_handler {
|
||||||
ATT_RESPONSE,
|
ATT_RESPONSE,
|
||||||
att_handle_read_type_rsp },
|
att_handle_read_type_rsp },
|
||||||
{ BT_ATT_OP_READ_RSP,
|
{ BT_ATT_OP_READ_RSP,
|
||||||
sizeof(struct bt_att_read_rsp),
|
0,
|
||||||
ATT_RESPONSE,
|
ATT_RESPONSE,
|
||||||
att_handle_read_rsp },
|
att_handle_read_rsp },
|
||||||
{ BT_ATT_OP_READ_BLOB_RSP,
|
{ BT_ATT_OP_READ_BLOB_RSP,
|
||||||
sizeof(struct bt_att_read_blob_rsp),
|
0,
|
||||||
ATT_RESPONSE,
|
ATT_RESPONSE,
|
||||||
att_handle_read_blob_rsp },
|
att_handle_read_blob_rsp },
|
||||||
#if defined(CONFIG_BT_GATT_READ_MULTIPLE)
|
#if defined(CONFIG_BT_GATT_READ_MULTIPLE)
|
||||||
{ BT_ATT_OP_READ_MULT_RSP,
|
{ BT_ATT_OP_READ_MULT_RSP,
|
||||||
sizeof(struct bt_att_read_mult_rsp),
|
0,
|
||||||
ATT_RESPONSE,
|
ATT_RESPONSE,
|
||||||
att_handle_read_mult_rsp },
|
att_handle_read_mult_rsp },
|
||||||
#if defined(CONFIG_BT_EATT)
|
#if defined(CONFIG_BT_EATT)
|
||||||
|
|
|
@ -139,7 +139,7 @@ struct bt_att_read_mult_req {
|
||||||
uint16_t handles[0];
|
uint16_t handles[0];
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
/* Read Multiple Respose */
|
/* Read Multiple Response */
|
||||||
#define BT_ATT_OP_READ_MULT_RSP 0x0f
|
#define BT_ATT_OP_READ_MULT_RSP 0x0f
|
||||||
struct bt_att_read_mult_rsp {
|
struct bt_att_read_mult_rsp {
|
||||||
uint8_t value[0];
|
uint8_t value[0];
|
||||||
|
|
|
@ -2747,26 +2747,27 @@ static void gatt_find_type_rsp(struct bt_conn *conn, uint8_t err,
|
||||||
const void *pdu, uint16_t length,
|
const void *pdu, uint16_t length,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
const struct bt_att_find_type_rsp *rsp = pdu;
|
const struct bt_att_handle_group *rsp = pdu;
|
||||||
struct bt_gatt_discover_params *params = user_data;
|
struct bt_gatt_discover_params *params = user_data;
|
||||||
uint8_t i;
|
uint8_t count;
|
||||||
uint16_t end_handle = 0U, start_handle;
|
uint16_t end_handle = 0U, start_handle;
|
||||||
|
|
||||||
BT_DBG("err 0x%02x", err);
|
BT_DBG("err 0x%02x", err);
|
||||||
|
|
||||||
if (err) {
|
if (err || (length % sizeof(struct bt_att_handle_group) != 0)) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count = length / sizeof(struct bt_att_handle_group);
|
||||||
|
|
||||||
/* Parse attributes found */
|
/* Parse attributes found */
|
||||||
for (i = 0U; length >= sizeof(rsp->list[i]);
|
for (uint8_t i = 0U; i < count; i++) {
|
||||||
i++, length -= sizeof(rsp->list[i])) {
|
|
||||||
struct bt_uuid_16 uuid_svc;
|
struct bt_uuid_16 uuid_svc;
|
||||||
struct bt_gatt_attr attr = {};
|
struct bt_gatt_attr attr = {};
|
||||||
struct bt_gatt_service_val value;
|
struct bt_gatt_service_val value;
|
||||||
|
|
||||||
start_handle = sys_le16_to_cpu(rsp->list[i].start_handle);
|
start_handle = sys_le16_to_cpu(rsp[i].start_handle);
|
||||||
end_handle = sys_le16_to_cpu(rsp->list[i].end_handle);
|
end_handle = sys_le16_to_cpu(rsp[i].end_handle);
|
||||||
|
|
||||||
BT_DBG("start_handle 0x%04x end_handle 0x%04x", start_handle,
|
BT_DBG("start_handle 0x%04x end_handle 0x%04x", start_handle,
|
||||||
end_handle);
|
end_handle);
|
||||||
|
@ -2790,11 +2791,6 @@ static void gatt_find_type_rsp(struct bt_conn *conn, uint8_t err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop if could not parse the whole PDU */
|
|
||||||
if (length > 0) {
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
gatt_discover_next(conn, end_handle, params);
|
gatt_discover_next(conn, end_handle, params);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue