Skip to content

Commit 805701d

Browse files
ceolinfabiobaltieri
authored andcommitted
bt: host: Use proper flexible array
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
1 parent 9969ae5 commit 805701d

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

subsys/bluetooth/host/att_internal.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct bt_att_info_128 {
8585
#define BT_ATT_OP_FIND_INFO_RSP 0x05
8686
struct bt_att_find_info_rsp {
8787
uint8_t format;
88-
uint8_t info[0];
88+
uint8_t info[];
8989
} __packed;
9090

9191
/* Find By Type Value Request */
@@ -94,7 +94,7 @@ struct bt_att_find_type_req {
9494
uint16_t start_handle;
9595
uint16_t end_handle;
9696
uint16_t type;
97-
uint8_t value[0];
97+
uint8_t value[];
9898
} __packed;
9999

100100
struct bt_att_handle_group {
@@ -105,27 +105,27 @@ struct bt_att_handle_group {
105105
/* Find By Type Value Response */
106106
#define BT_ATT_OP_FIND_TYPE_RSP 0x07
107107
struct bt_att_find_type_rsp {
108-
struct bt_att_handle_group list[0];
108+
FLEXIBLE_ARRAY_DECLARE(struct bt_att_handle_group, list);
109109
} __packed;
110110

111111
/* Read By Type Request */
112112
#define BT_ATT_OP_READ_TYPE_REQ 0x08
113113
struct bt_att_read_type_req {
114114
uint16_t start_handle;
115115
uint16_t end_handle;
116-
uint8_t uuid[0];
116+
uint8_t uuid[];
117117
} __packed;
118118

119119
struct bt_att_data {
120120
uint16_t handle;
121-
uint8_t value[0];
121+
uint8_t value[];
122122
} __packed;
123123

124124
/* Read By Type Response */
125125
#define BT_ATT_OP_READ_TYPE_RSP 0x09
126126
struct bt_att_read_type_rsp {
127127
uint8_t len;
128-
struct bt_att_data data[0];
128+
struct bt_att_data data[];
129129
} __packed;
130130

131131
/* Read Request */
@@ -137,7 +137,7 @@ struct bt_att_read_req {
137137
/* Read Response */
138138
#define BT_ATT_OP_READ_RSP 0x0b
139139
struct bt_att_read_rsp {
140-
uint8_t value[0];
140+
FLEXIBLE_ARRAY_DECLARE(uint8_t, value);
141141
} __packed;
142142

143143
/* Read Blob Request */
@@ -150,49 +150,49 @@ struct bt_att_read_blob_req {
150150
/* Read Blob Response */
151151
#define BT_ATT_OP_READ_BLOB_RSP 0x0d
152152
struct bt_att_read_blob_rsp {
153-
uint8_t value[0];
153+
FLEXIBLE_ARRAY_DECLARE(uint8_t, value);
154154
} __packed;
155155

156156
/* Read Multiple Request */
157157
#define BT_ATT_READ_MULT_MIN_LEN_REQ 0x04
158158

159159
#define BT_ATT_OP_READ_MULT_REQ 0x0e
160160
struct bt_att_read_mult_req {
161-
uint16_t handles[0];
161+
FLEXIBLE_ARRAY_DECLARE(uint16_t, handles);
162162
} __packed;
163163

164164
/* Read Multiple Response */
165165
#define BT_ATT_OP_READ_MULT_RSP 0x0f
166166
struct bt_att_read_mult_rsp {
167-
uint8_t value[0];
167+
FLEXIBLE_ARRAY_DECLARE(uint8_t, value);
168168
} __packed;
169169

170170
/* Read by Group Type Request */
171171
#define BT_ATT_OP_READ_GROUP_REQ 0x10
172172
struct bt_att_read_group_req {
173173
uint16_t start_handle;
174174
uint16_t end_handle;
175-
uint8_t uuid[0];
175+
uint8_t uuid[];
176176
} __packed;
177177

178178
struct bt_att_group_data {
179179
uint16_t start_handle;
180180
uint16_t end_handle;
181-
uint8_t value[0];
181+
uint8_t value[];
182182
} __packed;
183183

184184
/* Read by Group Type Response */
185185
#define BT_ATT_OP_READ_GROUP_RSP 0x11
186186
struct bt_att_read_group_rsp {
187187
uint8_t len;
188-
struct bt_att_group_data data[0];
188+
struct bt_att_group_data data[];
189189
} __packed;
190190

191191
/* Write Request */
192192
#define BT_ATT_OP_WRITE_REQ 0x12
193193
struct bt_att_write_req {
194194
uint16_t handle;
195-
uint8_t value[0];
195+
uint8_t value[];
196196
} __packed;
197197

198198
/* Write Response */
@@ -203,15 +203,15 @@ struct bt_att_write_req {
203203
struct bt_att_prepare_write_req {
204204
uint16_t handle;
205205
uint16_t offset;
206-
uint8_t value[0];
206+
uint8_t value[];
207207
} __packed;
208208

209209
/* Prepare Write Respond */
210210
#define BT_ATT_OP_PREPARE_WRITE_RSP 0x17
211211
struct bt_att_prepare_write_rsp {
212212
uint16_t handle;
213213
uint16_t offset;
214-
uint8_t value[0];
214+
uint8_t value[];
215215
} __packed;
216216

217217
/* Execute Write Request */
@@ -230,14 +230,14 @@ struct bt_att_exec_write_req {
230230
#define BT_ATT_OP_NOTIFY 0x1b
231231
struct bt_att_notify {
232232
uint16_t handle;
233-
uint8_t value[0];
233+
uint8_t value[];
234234
} __packed;
235235

236236
/* Handle Value Indication */
237237
#define BT_ATT_OP_INDICATE 0x1d
238238
struct bt_att_indicate {
239239
uint16_t handle;
240-
uint8_t value[0];
240+
uint8_t value[];
241241
} __packed;
242242

243243
/* Handle Value Confirm */
@@ -249,36 +249,36 @@ struct bt_att_signature {
249249

250250
#define BT_ATT_OP_READ_MULT_VL_REQ 0x20
251251
struct bt_att_read_mult_vl_req {
252-
uint16_t handles[0];
252+
FLEXIBLE_ARRAY_DECLARE(uint16_t, handles);
253253
} __packed;
254254

255255
/* Read Multiple Response */
256256
#define BT_ATT_OP_READ_MULT_VL_RSP 0x21
257257
struct bt_att_read_mult_vl_rsp {
258258
uint16_t len;
259-
uint8_t value[0];
259+
uint8_t value[];
260260
} __packed;
261261

262262
/* Handle Multiple Value Notification */
263263
#define BT_ATT_OP_NOTIFY_MULT 0x23
264264
struct bt_att_notify_mult {
265265
uint16_t handle;
266266
uint16_t len;
267-
uint8_t value[0];
267+
uint8_t value[];
268268
} __packed;
269269

270270
/* Write Command */
271271
#define BT_ATT_OP_WRITE_CMD 0x52
272272
struct bt_att_write_cmd {
273273
uint16_t handle;
274-
uint8_t value[0];
274+
uint8_t value[];
275275
} __packed;
276276

277277
/* Signed Write Command */
278278
#define BT_ATT_OP_SIGNED_WRITE_CMD 0xd2
279279
struct bt_att_signed_write_cmd {
280280
uint16_t handle;
281-
uint8_t value[0];
281+
uint8_t value[];
282282
} __packed;
283283

284284
typedef void (*bt_att_func_t)(struct bt_conn *conn, int err,

subsys/bluetooth/host/classic/l2cap_br_internal.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct bt_l2cap_sig_hdr {
3434
#define BT_L2CAP_CMD_REJECT 0x01
3535
struct bt_l2cap_cmd_reject {
3636
uint16_t reason;
37-
uint8_t data[0];
37+
uint8_t data[];
3838
} __packed;
3939

4040
struct bt_l2cap_cmd_reject_cid_data {
@@ -83,15 +83,15 @@ struct bt_l2cap_conn_rsp {
8383
struct bt_l2cap_conf_req {
8484
uint16_t dcid;
8585
uint16_t flags;
86-
uint8_t data[0];
86+
uint8_t data[];
8787
} __packed;
8888

8989
#define BT_L2CAP_CONF_RSP 0x05
9090
struct bt_l2cap_conf_rsp {
9191
uint16_t scid;
9292
uint16_t flags;
9393
uint16_t result;
94-
uint8_t data[0];
94+
uint8_t data[];
9595
} __packed;
9696

9797
/* Option type used by MTU config request data */
@@ -110,7 +110,7 @@ struct bt_l2cap_conf_rsp {
110110
struct bt_l2cap_conf_opt {
111111
uint8_t type;
112112
uint8_t len;
113-
uint8_t data[0];
113+
uint8_t data[];
114114
} __packed;
115115

116116
struct bt_l2cap_conf_opt_mtu {
@@ -200,7 +200,7 @@ struct bt_l2cap_info_req {
200200
struct bt_l2cap_info_rsp {
201201
uint16_t type;
202202
uint16_t result;
203-
uint8_t data[0];
203+
uint8_t data[];
204204
} __packed;
205205

206206
/* I Frame Standard Control Field Format definition */

subsys/bluetooth/host/l2cap_internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct bt_l2cap_sig_hdr {
5252
#define BT_L2CAP_CMD_REJECT 0x01
5353
struct bt_l2cap_cmd_reject {
5454
uint16_t reason;
55-
uint8_t data[0];
55+
uint8_t data[];
5656
} __packed;
5757

5858
struct bt_l2cap_cmd_reject_cid_data {
@@ -131,7 +131,7 @@ struct bt_l2cap_ecred_conn_req {
131131
uint16_t mtu;
132132
uint16_t mps;
133133
uint16_t credits;
134-
uint16_t scid[0];
134+
uint16_t scid[];
135135
} __packed;
136136

137137
#define BT_L2CAP_ECRED_CONN_RSP 0x18
@@ -140,14 +140,14 @@ struct bt_l2cap_ecred_conn_rsp {
140140
uint16_t mps;
141141
uint16_t credits;
142142
uint16_t result;
143-
uint16_t dcid[0];
143+
uint16_t dcid[];
144144
} __packed;
145145

146146
#define BT_L2CAP_ECRED_RECONF_REQ 0x19
147147
struct bt_l2cap_ecred_reconf_req {
148148
uint16_t mtu;
149149
uint16_t mps;
150-
uint16_t scid[0];
150+
uint16_t scid[];
151151
} __packed;
152152

153153
#define BT_L2CAP_RECONF_SUCCESS 0x0000

0 commit comments

Comments
 (0)