From 0b414958c9f9ece3ecf6ec61af4f043cf518382b Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 29 Aug 2025 02:10:41 +0200 Subject: [PATCH 1/7] bt: audio: Use proper flexible array 0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin --- subsys/bluetooth/audio/has_internal.h | 10 +++++----- subsys/bluetooth/audio/pacs_internal.h | 4 ++-- subsys/bluetooth/audio/tbs_internal.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/subsys/bluetooth/audio/has_internal.h b/subsys/bluetooth/audio/has_internal.h index 97b4d2017aefa..8560a93ff7603 100644 --- a/subsys/bluetooth/audio/has_internal.h +++ b/subsys/bluetooth/audio/has_internal.h @@ -68,7 +68,7 @@ struct bt_has { struct bt_has_cp_hdr { uint8_t opcode; - uint8_t data[0]; + uint8_t data[]; } __packed; struct bt_has_cp_read_presets_req { @@ -80,25 +80,25 @@ struct bt_has_cp_read_preset_rsp { uint8_t is_last; uint8_t index; uint8_t properties; - uint8_t name[0]; + uint8_t name[]; } __packed; struct bt_has_cp_preset_changed { uint8_t change_id; uint8_t is_last; - uint8_t additional_params[0]; + uint8_t additional_params[]; } __packed; struct bt_has_cp_generic_update { uint8_t prev_index; uint8_t index; uint8_t properties; - uint8_t name[0]; + uint8_t name[]; } __packed; struct bt_has_cp_write_preset_name { uint8_t index; - uint8_t name[0]; + uint8_t name[]; } __packed; struct bt_has_cp_set_active_preset { diff --git a/subsys/bluetooth/audio/pacs_internal.h b/subsys/bluetooth/audio/pacs_internal.h index 897f8800504da..0d6ded670dea7 100644 --- a/subsys/bluetooth/audio/pacs_internal.h +++ b/subsys/bluetooth/audio/pacs_internal.h @@ -23,12 +23,12 @@ struct bt_pac_codec { struct bt_pac_ltv { uint8_t len; uint8_t type; - uint8_t value[0]; + uint8_t value[]; } __packed; struct bt_pac_ltv_data { uint8_t len; - struct bt_pac_ltv data[0]; + struct bt_pac_ltv data[]; } __packed; struct bt_pacs_read_rsp { diff --git a/subsys/bluetooth/audio/tbs_internal.h b/subsys/bluetooth/audio/tbs_internal.h index 68b4dbb0e7004..e8ae47d44d2da 100644 --- a/subsys/bluetooth/audio/tbs_internal.h +++ b/subsys/bluetooth/audio/tbs_internal.h @@ -246,12 +246,12 @@ struct bt_tbs_call_cp_retrieve { struct bt_tbs_call_cp_originate { uint8_t opcode; - uint8_t uri[0]; + uint8_t uri[]; } __packed; struct bt_tbs_call_cp_join { uint8_t opcode; - uint8_t call_indexes[0]; + uint8_t call_indexes[]; } __packed; union bt_tbs_call_cp_t { From 4e046c1920b43e4b37d187d9d135954eabf60031 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 29 Aug 2025 02:13:01 +0200 Subject: [PATCH 2/7] lib: heap: Use proper flexible array 0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin --- lib/heap/heap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/heap/heap.h b/lib/heap/heap.h index 8a3b893a658a6..d053a6db88392 100644 --- a/lib/heap/heap.h +++ b/lib/heap/heap.h @@ -74,7 +74,7 @@ struct z_heap { size_t allocated_bytes; size_t max_allocated_bytes; #endif - struct z_heap_bucket buckets[0]; + struct z_heap_bucket buckets[]; }; static inline bool big_heap_chunks(chunksz_t chunks) From 0ca4f46a0c8cc0994a855e041d1588c675fb87b6 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 29 Aug 2025 02:16:38 +0200 Subject: [PATCH 3/7] bt: controller/util: Use proper flexible array 0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin --- subsys/bluetooth/controller/util/dbuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/controller/util/dbuf.h b/subsys/bluetooth/controller/util/dbuf.h index 8593b368d3799..3bd10a431af48 100644 --- a/subsys/bluetooth/controller/util/dbuf.h +++ b/subsys/bluetooth/controller/util/dbuf.h @@ -18,7 +18,7 @@ struct dbuf_hdr { /* Size in a bytes of a single element stored in double buffer. */ uint8_t elem_size; /* Pointer for actual buffer memory. Its size should be 2 times @p elem_size. */ - uint8_t data[0]; + uint8_t data[]; }; /** From 9be698b3b201c010af49846e99a468a69bb6c629 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 29 Aug 2025 02:23:49 +0200 Subject: [PATCH 4/7] tests: bt/tester: Use proper flexible array 0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin --- tests/bluetooth/tester/src/audio/btp/btp_bap.h | 11 ++++++----- tests/bluetooth/tester/src/audio/btp/btp_cap.h | 15 ++++++++------- tests/bluetooth/tester/src/audio/btp/btp_mcp.h | 3 ++- tests/bluetooth/tester/src/audio/btp/btp_micp.h | 2 +- tests/bluetooth/tester/src/audio/btp/btp_pacs.h | 2 +- tests/bluetooth/tester/src/btp/btp_core.h | 5 +++-- tests/bluetooth/tester/src/btp/btp_gap.h | 7 ++++--- tests/bluetooth/tester/src/btp/btp_mesh.h | 9 +++++---- tests/bluetooth/tester/src/btp/btp_ots.h | 5 +++-- 9 files changed, 33 insertions(+), 26 deletions(-) diff --git a/tests/bluetooth/tester/src/audio/btp/btp_bap.h b/tests/bluetooth/tester/src/audio/btp/btp_bap.h index c0e1470fd415a..90544cdcbd0d0 100644 --- a/tests/bluetooth/tester/src/audio/btp/btp_bap.h +++ b/tests/bluetooth/tester/src/audio/btp/btp_bap.h @@ -11,11 +11,12 @@ #include #include #include +#include /* BAP commands */ #define BTP_BAP_READ_SUPPORTED_COMMANDS 0x01 struct btp_bap_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_BAP_DISCOVER 0x02 @@ -31,7 +32,7 @@ struct btp_bap_send_cmd { bt_addr_le_t address; uint8_t ase_id; uint8_t data_len; - uint8_t data[0]; + uint8_t data[]; } __packed; struct btp_bap_send_rp { @@ -148,7 +149,7 @@ struct btp_bap_add_broadcast_src_cmd { uint8_t padv_sync; uint16_t padv_interval; uint8_t num_subgroups; - uint8_t subgroups[0]; + uint8_t subgroups[]; } __packed; #define BTP_BAP_REMOVE_BROADCAST_SRC 0x15 @@ -164,7 +165,7 @@ struct btp_bap_modify_broadcast_src_cmd { uint8_t padv_sync; uint16_t padv_interval; uint8_t num_subgroups; - uint8_t subgroups[0]; + uint8_t subgroups[]; } __packed; #define BTP_BAP_SET_BROADCAST_CODE 0x17 @@ -287,7 +288,7 @@ struct btp_bap_broadcast_receive_state_ev { uint8_t pa_sync_state; uint8_t big_encryption; uint8_t num_subgroups; - uint8_t subgroups[0]; + uint8_t subgroups[]; } __packed; #define BTP_BAP_EV_PA_SYNC_REQ 0x8a diff --git a/tests/bluetooth/tester/src/audio/btp/btp_cap.h b/tests/bluetooth/tester/src/audio/btp/btp_cap.h index d039bee7dbda0..b59aec900539a 100644 --- a/tests/bluetooth/tester/src/audio/btp/btp_cap.h +++ b/tests/bluetooth/tester/src/audio/btp/btp_cap.h @@ -11,12 +11,13 @@ #include #include #include +#include #include /* CAP commands */ #define BTP_CAP_READ_SUPPORTED_COMMANDS 0x01 struct btp_cap_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_CAP_DISCOVER 0x02 @@ -41,7 +42,7 @@ struct btp_cap_unicast_setup_ase_cmd { uint8_t presentation_delay[3]; uint8_t cc_ltvs_len; uint8_t metadata_ltvs_len; - uint8_t ltvs[0]; + uint8_t ltvs[]; } __packed; #define BTP_CAP_UNICAST_AUDIO_START 0x04 @@ -55,13 +56,13 @@ struct btp_cap_unicast_audio_start_cmd { #define BTP_CAP_UNICAST_AUDIO_UPDATE 0x05 struct btp_cap_unicast_audio_update_cmd { uint8_t stream_count; - uint8_t update_data[0]; + uint8_t update_data[]; } __packed; struct btp_cap_unicast_audio_update_data { bt_addr_le_t address; uint8_t ase_id; uint8_t metadata_ltvs_len; - uint8_t metadata_ltvs[0]; + uint8_t metadata_ltvs[]; } __packed; #define BTP_CAP_UNICAST_AUDIO_STOP 0x06 @@ -80,7 +81,7 @@ struct btp_cap_broadcast_source_setup_stream_cmd { uint16_t cid; uint8_t cc_ltvs_len; uint8_t metadata_ltvs_len; - uint8_t ltvs[0]; + uint8_t ltvs[]; } __packed; #define BTP_CAP_BROADCAST_SOURCE_SETUP_SUBGROUP 0x08 @@ -92,7 +93,7 @@ struct btp_cap_broadcast_source_setup_subgroup_cmd { uint16_t cid; uint8_t cc_ltvs_len; uint8_t metadata_ltvs_len; - uint8_t ltvs[0]; + uint8_t ltvs[]; } __packed; #define BTP_CAP_BROADCAST_SOURCE_SETUP 0x09 @@ -145,7 +146,7 @@ struct btp_cap_broadcast_source_stop_cmd { struct btp_cap_broadcast_source_update_cmd { uint8_t source_id; uint8_t metadata_ltvs_len; - uint8_t metadata_ltvs[0]; + uint8_t metadata_ltvs[]; } __packed; /* CAP events */ diff --git a/tests/bluetooth/tester/src/audio/btp/btp_mcp.h b/tests/bluetooth/tester/src/audio/btp/btp_mcp.h index 77a3b25063be4..0b2cac9fe9e06 100644 --- a/tests/bluetooth/tester/src/audio/btp/btp_mcp.h +++ b/tests/bluetooth/tester/src/audio/btp/btp_mcp.h @@ -11,11 +11,12 @@ #include #include +#include /* MCP commands */ #define BTP_MCP_READ_SUPPORTED_COMMANDS 0x01 struct btp_mcp_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_MCP_DISCOVER 0x02 diff --git a/tests/bluetooth/tester/src/audio/btp/btp_micp.h b/tests/bluetooth/tester/src/audio/btp/btp_micp.h index a480358773471..4992b033768a0 100644 --- a/tests/bluetooth/tester/src/audio/btp/btp_micp.h +++ b/tests/bluetooth/tester/src/audio/btp/btp_micp.h @@ -13,7 +13,7 @@ /* MICP commands */ #define BTP_MICP_READ_SUPPORTED_COMMANDS 0x01 struct btp_micp_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_MICP_CTLR_DISCOVER 0x02 diff --git a/tests/bluetooth/tester/src/audio/btp/btp_pacs.h b/tests/bluetooth/tester/src/audio/btp/btp_pacs.h index e17700581504d..84f0728442ec9 100644 --- a/tests/bluetooth/tester/src/audio/btp/btp_pacs.h +++ b/tests/bluetooth/tester/src/audio/btp/btp_pacs.h @@ -11,7 +11,7 @@ /* PACS commands */ #define BTP_PACS_READ_SUPPORTED_COMMANDS 0x01 struct btp_pacs_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_PACS_CHARACTERISTIC_SINK_PAC 0x01 diff --git a/tests/bluetooth/tester/src/btp/btp_core.h b/tests/bluetooth/tester/src/btp/btp_core.h index 9b4f1a88d4019..867042084a5d9 100644 --- a/tests/bluetooth/tester/src/btp/btp_core.h +++ b/tests/bluetooth/tester/src/btp/btp_core.h @@ -8,16 +8,17 @@ */ #include +#include /* Core Service */ #define BTP_CORE_READ_SUPPORTED_COMMANDS 0x01 struct btp_core_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_CORE_READ_SUPPORTED_SERVICES 0x02 struct btp_core_read_supported_services_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_CORE_REGISTER_SERVICE 0x03 diff --git a/tests/bluetooth/tester/src/btp/btp_gap.h b/tests/bluetooth/tester/src/btp/btp_gap.h index e410b56e460db..924859c461c2d 100644 --- a/tests/bluetooth/tester/src/btp/btp_gap.h +++ b/tests/bluetooth/tester/src/btp/btp_gap.h @@ -12,12 +12,13 @@ #include #include +#include /* GAP Service */ /* commands */ #define BTP_GAP_READ_SUPPORTED_COMMANDS 0x01 struct btp_gap_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_GAP_READ_CONTROLLER_INDEX_LIST 0x02 @@ -360,7 +361,7 @@ struct btp_gap_big_create_sync_cmd { uint32_t mse; uint16_t sync_timeout; uint8_t encryption; - uint8_t broadcast_code[0]; + uint8_t broadcast_code[]; } __packed; #define BTP_GAP_CREATE_BIG_ENC_DISABLE 0x00 @@ -377,7 +378,7 @@ struct btp_gap_create_big_cmd { uint8_t packing; uint8_t framing; uint8_t encryption; - uint8_t broadcast_code[0]; + uint8_t broadcast_code[]; } __packed; #define BTP_GAP_BIS_BROADCAST 0x2e diff --git a/tests/bluetooth/tester/src/btp/btp_mesh.h b/tests/bluetooth/tester/src/btp/btp_mesh.h index 7f197e907cdf5..353971261b437 100644 --- a/tests/bluetooth/tester/src/btp/btp_mesh.h +++ b/tests/bluetooth/tester/src/btp/btp_mesh.h @@ -10,13 +10,14 @@ #include #include +#include #include /* MESH Service */ /* commands */ #define BTP_MESH_READ_SUPPORTED_COMMANDS 0x01 struct btp_mesh_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_MESH_OUT_BLINK BIT(0) @@ -156,7 +157,7 @@ struct btp_mesh_comp_data_get_cmd { uint8_t page; } __packed; struct btp_mesh_comp_data_get_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_MESH_CFG_BEACON_GET 0x15 @@ -824,7 +825,7 @@ struct btp_mesh_large_comp_data_get_cmd { uint16_t offset; } __packed; struct btp_mesh_large_comp_data_get_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_MESH_MODELS_METADATA_GET 0x54 @@ -835,7 +836,7 @@ struct btp_mesh_models_metadata_get_cmd { uint16_t offset; } __packed; struct btp_mesh_models_metadata_get_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_MESH_OPCODES_AGGREGATOR_INIT 0x55 diff --git a/tests/bluetooth/tester/src/btp/btp_ots.h b/tests/bluetooth/tester/src/btp/btp_ots.h index be2f2fab48804..54b36cd00bafb 100644 --- a/tests/bluetooth/tester/src/btp/btp_ots.h +++ b/tests/bluetooth/tester/src/btp/btp_ots.h @@ -7,11 +7,12 @@ */ #include +#include /* OTS commands */ #define BTP_OTS_READ_SUPPORTED_COMMANDS 0x01 struct btp_ots_read_supported_commands_rp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BTP_OTS_REGISTER_OBJECT_FLAGS_SKIP_UNSUPPORTED_PROPS 0x01 @@ -23,7 +24,7 @@ struct btp_ots_register_object_cmd { uint32_t alloc_size; uint32_t current_size; uint8_t name_len; - uint8_t name[0]; + uint8_t name[]; } __packed; struct btp_ots_register_object_rp { uint64_t object_id; From 6d3965fa436e8145a8d097ee9768c2e87ee0e9ca Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 29 Aug 2025 02:29:18 +0200 Subject: [PATCH 5/7] bt: host/classic: Use proper flexible array 0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin --- subsys/bluetooth/host/classic/l2cap_br_internal.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/host/classic/l2cap_br_internal.h b/subsys/bluetooth/host/classic/l2cap_br_internal.h index ad34bb487fbb2..c4989d2c1fc36 100644 --- a/subsys/bluetooth/host/classic/l2cap_br_internal.h +++ b/subsys/bluetooth/host/classic/l2cap_br_internal.h @@ -10,6 +10,7 @@ #include #include +#include #include "l2cap_br_interface.h" #define BT_L2CAP_CID_BR_SIG 0x0001 @@ -177,12 +178,12 @@ struct bt_l2cap_disconn_rsp { #define BT_L2CAP_ECHO_REQ 0x08 struct bt_l2cap_echo_req { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BT_L2CAP_ECHO_RSP 0x09 struct bt_l2cap_echo_rsp { - uint8_t data[0]; + FLEXIBLE_ARRAY_DECLARE(uint8_t, data); } __packed; #define BT_L2CAP_INFO_CONNLESS_MTU 0x0001 From fe60526e8caced078e5cf2813e82f584f58e0588 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 29 Aug 2025 02:57:06 +0200 Subject: [PATCH 6/7] bt: controller/openisa: Use proper flexible array 0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin --- .../controller/ll_sw/openisa/lll/pdu_vendor.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/pdu_vendor.h b/subsys/bluetooth/controller/ll_sw/openisa/lll/pdu_vendor.h index 7dd10aa7a247a..e67c22e8b03b7 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/pdu_vendor.h +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/pdu_vendor.h @@ -4,33 +4,27 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + /* Minimum vendor specific Rx payload buffer allocation */ #define LL_VND_OCTETS_RX_MIN 0 /* No vendor Data PDU struct octet3 */ struct pdu_data_vnd_octet3 { - union { - uint8_t resv[0]; - } __packed; + FLEXIBLE_ARRAY_DECLARE(uint8_t, resv); } __packed; /* No vendor BIS PDU struct octet3 */ struct pdu_bis_vnd_octet3 { - union { - uint8_t resv[0]; - } __packed; + FLEXIBLE_ARRAY_DECLARE(uint8_t, resv); } __packed; /* No vendor CIS PDU struct octet3 */ struct pdu_cis_vnd_octet3 { - union { - uint8_t resv[0]; - } __packed; + FLEXIBLE_ARRAY_DECLARE(uint8_t, resv); } __packed; /* No ISOAL helper vendor ISO PDU struct octet3 */ struct pdu_iso_vnd_octet3 { - union { - uint8_t resv[0]; - } __packed; + FLEXIBLE_ARRAY_DECLARE(uint8_t, resv); } __packed; From 0df79cf54f337373d102ebebc13da030d8f515e3 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 29 Aug 2025 02:58:47 +0200 Subject: [PATCH 7/7] bt: host/classic: Use proper flexible array 0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin --- subsys/bluetooth/host/classic/avdtp_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/host/classic/avdtp_internal.h b/subsys/bluetooth/host/classic/avdtp_internal.h index 951e1a11d9cfc..6af196dcfb089 100644 --- a/subsys/bluetooth/host/classic/avdtp_internal.h +++ b/subsys/bluetooth/host/classic/avdtp_internal.h @@ -189,13 +189,13 @@ struct bt_avdtp_recovery_capabilities { struct bt_avdtp_media_codec_capabilities { uint8_t media_type; uint8_t media_code_type; - uint8_t media_codec_spec_info[0]; + uint8_t media_codec_spec_info[]; } __packed; struct bt_avdtp_content_protection_capabilities { uint8_t cp_type_lsb; uint8_t cp_type_msb; - uint8_t cp_type_spec_value[0]; + uint8_t cp_type_spec_value[]; } __packed; struct bt_avdtp_header_compression_capabilities {