Skip to content

Commit bfa44f5

Browse files
ceolinjhedberg
authored andcommitted
tests: bt/tester: 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 bb66123 commit bfa44f5

File tree

9 files changed

+33
-26
lines changed

9 files changed

+33
-26
lines changed

tests/bluetooth/tester/src/audio/btp/btp_bap.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
#include <zephyr/bluetooth/addr.h>
1212
#include <zephyr/bluetooth/audio/audio.h>
1313
#include <zephyr/bluetooth/iso.h>
14+
#include <zephyr/sys/util.h>
1415

1516
/* BAP commands */
1617
#define BTP_BAP_READ_SUPPORTED_COMMANDS 0x01
1718
struct btp_bap_read_supported_commands_rp {
18-
uint8_t data[0];
19+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
1920
} __packed;
2021

2122
#define BTP_BAP_DISCOVER 0x02
@@ -31,7 +32,7 @@ struct btp_bap_send_cmd {
3132
bt_addr_le_t address;
3233
uint8_t ase_id;
3334
uint8_t data_len;
34-
uint8_t data[0];
35+
uint8_t data[];
3536
} __packed;
3637

3738
struct btp_bap_send_rp {
@@ -148,7 +149,7 @@ struct btp_bap_add_broadcast_src_cmd {
148149
uint8_t padv_sync;
149150
uint16_t padv_interval;
150151
uint8_t num_subgroups;
151-
uint8_t subgroups[0];
152+
uint8_t subgroups[];
152153
} __packed;
153154

154155
#define BTP_BAP_REMOVE_BROADCAST_SRC 0x15
@@ -164,7 +165,7 @@ struct btp_bap_modify_broadcast_src_cmd {
164165
uint8_t padv_sync;
165166
uint16_t padv_interval;
166167
uint8_t num_subgroups;
167-
uint8_t subgroups[0];
168+
uint8_t subgroups[];
168169
} __packed;
169170

170171
#define BTP_BAP_SET_BROADCAST_CODE 0x17
@@ -287,7 +288,7 @@ struct btp_bap_broadcast_receive_state_ev {
287288
uint8_t pa_sync_state;
288289
uint8_t big_encryption;
289290
uint8_t num_subgroups;
290-
uint8_t subgroups[0];
291+
uint8_t subgroups[];
291292
} __packed;
292293

293294
#define BTP_BAP_EV_PA_SYNC_REQ 0x8a

tests/bluetooth/tester/src/audio/btp/btp_cap.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
#include <zephyr/bluetooth/addr.h>
1212
#include <zephyr/bluetooth/audio/audio.h>
1313
#include <zephyr/bluetooth/iso.h>
14+
#include <zephyr/sys/util.h>
1415
#include <zephyr/sys/util_macro.h>
1516

1617
/* CAP commands */
1718
#define BTP_CAP_READ_SUPPORTED_COMMANDS 0x01
1819
struct btp_cap_read_supported_commands_rp {
19-
uint8_t data[0];
20+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
2021
} __packed;
2122

2223
#define BTP_CAP_DISCOVER 0x02
@@ -41,7 +42,7 @@ struct btp_cap_unicast_setup_ase_cmd {
4142
uint8_t presentation_delay[3];
4243
uint8_t cc_ltvs_len;
4344
uint8_t metadata_ltvs_len;
44-
uint8_t ltvs[0];
45+
uint8_t ltvs[];
4546
} __packed;
4647

4748
#define BTP_CAP_UNICAST_AUDIO_START 0x04
@@ -55,13 +56,13 @@ struct btp_cap_unicast_audio_start_cmd {
5556
#define BTP_CAP_UNICAST_AUDIO_UPDATE 0x05
5657
struct btp_cap_unicast_audio_update_cmd {
5758
uint8_t stream_count;
58-
uint8_t update_data[0];
59+
uint8_t update_data[];
5960
} __packed;
6061
struct btp_cap_unicast_audio_update_data {
6162
bt_addr_le_t address;
6263
uint8_t ase_id;
6364
uint8_t metadata_ltvs_len;
64-
uint8_t metadata_ltvs[0];
65+
uint8_t metadata_ltvs[];
6566
} __packed;
6667

6768
#define BTP_CAP_UNICAST_AUDIO_STOP 0x06
@@ -80,7 +81,7 @@ struct btp_cap_broadcast_source_setup_stream_cmd {
8081
uint16_t cid;
8182
uint8_t cc_ltvs_len;
8283
uint8_t metadata_ltvs_len;
83-
uint8_t ltvs[0];
84+
uint8_t ltvs[];
8485
} __packed;
8586

8687
#define BTP_CAP_BROADCAST_SOURCE_SETUP_SUBGROUP 0x08
@@ -92,7 +93,7 @@ struct btp_cap_broadcast_source_setup_subgroup_cmd {
9293
uint16_t cid;
9394
uint8_t cc_ltvs_len;
9495
uint8_t metadata_ltvs_len;
95-
uint8_t ltvs[0];
96+
uint8_t ltvs[];
9697
} __packed;
9798

9899
#define BTP_CAP_BROADCAST_SOURCE_SETUP 0x09
@@ -145,7 +146,7 @@ struct btp_cap_broadcast_source_stop_cmd {
145146
struct btp_cap_broadcast_source_update_cmd {
146147
uint8_t source_id;
147148
uint8_t metadata_ltvs_len;
148-
uint8_t metadata_ltvs[0];
149+
uint8_t metadata_ltvs[];
149150
} __packed;
150151

151152
/* CAP events */

tests/bluetooth/tester/src/audio/btp/btp_mcp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
#include <zephyr/bluetooth/addr.h>
1313
#include <zephyr/bluetooth/services/ots.h>
14+
#include <zephyr/sys/util.h>
1415

1516
/* MCP commands */
1617
#define BTP_MCP_READ_SUPPORTED_COMMANDS 0x01
1718
struct btp_mcp_read_supported_commands_rp {
18-
uint8_t data[0];
19+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
1920
} __packed;
2021

2122
#define BTP_MCP_DISCOVER 0x02

tests/bluetooth/tester/src/audio/btp/btp_micp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/* MICP commands */
1414
#define BTP_MICP_READ_SUPPORTED_COMMANDS 0x01
1515
struct btp_micp_read_supported_commands_rp {
16-
uint8_t data[0];
16+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
1717
} __packed;
1818

1919
#define BTP_MICP_CTLR_DISCOVER 0x02

tests/bluetooth/tester/src/audio/btp/btp_pacs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/* PACS commands */
1212
#define BTP_PACS_READ_SUPPORTED_COMMANDS 0x01
1313
struct btp_pacs_read_supported_commands_rp {
14-
uint8_t data[0];
14+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
1515
} __packed;
1616

1717
#define BTP_PACS_CHARACTERISTIC_SINK_PAC 0x01

tests/bluetooth/tester/src/btp/btp_core.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
*/
99

1010
#include <stdint.h>
11+
#include <zephyr/sys/util.h>
1112

1213
/* Core Service */
1314
#define BTP_CORE_READ_SUPPORTED_COMMANDS 0x01
1415
struct btp_core_read_supported_commands_rp {
15-
uint8_t data[0];
16+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
1617
} __packed;
1718

1819
#define BTP_CORE_READ_SUPPORTED_SERVICES 0x02
1920
struct btp_core_read_supported_services_rp {
20-
uint8_t data[0];
21+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
2122
} __packed;
2223

2324
#define BTP_CORE_REGISTER_SERVICE 0x03

tests/bluetooth/tester/src/btp/btp_gap.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212

1313
#include <zephyr/bluetooth/addr.h>
1414
#include <zephyr/bluetooth/iso.h>
15+
#include <zephyr/sys/util.h>
1516

1617
/* GAP Service */
1718
/* commands */
1819
#define BTP_GAP_READ_SUPPORTED_COMMANDS 0x01
1920
struct btp_gap_read_supported_commands_rp {
20-
uint8_t data[0];
21+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
2122
} __packed;
2223

2324
#define BTP_GAP_READ_CONTROLLER_INDEX_LIST 0x02
@@ -360,7 +361,7 @@ struct btp_gap_big_create_sync_cmd {
360361
uint32_t mse;
361362
uint16_t sync_timeout;
362363
uint8_t encryption;
363-
uint8_t broadcast_code[0];
364+
uint8_t broadcast_code[];
364365
} __packed;
365366

366367
#define BTP_GAP_CREATE_BIG_ENC_DISABLE 0x00
@@ -377,7 +378,7 @@ struct btp_gap_create_big_cmd {
377378
uint8_t packing;
378379
uint8_t framing;
379380
uint8_t encryption;
380-
uint8_t broadcast_code[0];
381+
uint8_t broadcast_code[];
381382
} __packed;
382383

383384
#define BTP_GAP_BIS_BROADCAST 0x2e

tests/bluetooth/tester/src/btp/btp_mesh.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
#include <stdint.h>
1111

1212
#include <zephyr/bluetooth/addr.h>
13+
#include <zephyr/sys/util.h>
1314
#include <zephyr/sys/util_macro.h>
1415

1516
/* MESH Service */
1617
/* commands */
1718
#define BTP_MESH_READ_SUPPORTED_COMMANDS 0x01
1819
struct btp_mesh_read_supported_commands_rp {
19-
uint8_t data[0];
20+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
2021
} __packed;
2122

2223
#define BTP_MESH_OUT_BLINK BIT(0)
@@ -156,7 +157,7 @@ struct btp_mesh_comp_data_get_cmd {
156157
uint8_t page;
157158
} __packed;
158159
struct btp_mesh_comp_data_get_rp {
159-
uint8_t data[0];
160+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
160161
} __packed;
161162

162163
#define BTP_MESH_CFG_BEACON_GET 0x15
@@ -824,7 +825,7 @@ struct btp_mesh_large_comp_data_get_cmd {
824825
uint16_t offset;
825826
} __packed;
826827
struct btp_mesh_large_comp_data_get_rp {
827-
uint8_t data[0];
828+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
828829
} __packed;
829830

830831
#define BTP_MESH_MODELS_METADATA_GET 0x54
@@ -835,7 +836,7 @@ struct btp_mesh_models_metadata_get_cmd {
835836
uint16_t offset;
836837
} __packed;
837838
struct btp_mesh_models_metadata_get_rp {
838-
uint8_t data[0];
839+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
839840
} __packed;
840841

841842
#define BTP_MESH_OPCODES_AGGREGATOR_INIT 0x55

tests/bluetooth/tester/src/btp/btp_ots.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
*/
88

99
#include <stdint.h>
10+
#include <zephyr/sys/util.h>
1011

1112
/* OTS commands */
1213
#define BTP_OTS_READ_SUPPORTED_COMMANDS 0x01
1314
struct btp_ots_read_supported_commands_rp {
14-
uint8_t data[0];
15+
FLEXIBLE_ARRAY_DECLARE(uint8_t, data);
1516
} __packed;
1617

1718
#define BTP_OTS_REGISTER_OBJECT_FLAGS_SKIP_UNSUPPORTED_PROPS 0x01
@@ -23,7 +24,7 @@ struct btp_ots_register_object_cmd {
2324
uint32_t alloc_size;
2425
uint32_t current_size;
2526
uint8_t name_len;
26-
uint8_t name[0];
27+
uint8_t name[];
2728
} __packed;
2829
struct btp_ots_register_object_rp {
2930
uint64_t object_id;

0 commit comments

Comments
 (0)