Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
Subsystems (4)
PATCH v2 1/1 Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Use the __struct_group() helper to fix 31 instances of the following type of warnings:
30 net/bluetooth/mgmt_config.c:16:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] 1 net/bluetooth/mgmt_config.c:22:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
---
Changes in v2:
- Use __struct_group() instead of TRAILING_OVERLAP().
v1:
- Link: https://lore.kernel.org/linux-hardening/aLSCu8U62Hve7Dau@kspp/
include/net/bluetooth/mgmt.h | 9 +++++++-- net/bluetooth/mgmt_config.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-)
include/net/bluetooth/mgmt.h +7 -2
@@ -53,10 +53,15 @@ struct mgmt_hdr { } __packed;struct mgmt_tlv { -__le16 type; -__u8 length; +/* New members MUST be added within the __struct_group() macro below. */ + __struct_group(mgmt_tlv_hdr, __hdr, __packed, + __le16 type; +__u8 length; + );__u8 value[]; } __packed; +static_assert (offsetof(struct mgmt_tlv , value) ==sizeof (struct mgmt_tlv_hdr ), +"struct member likely outside of __struct_group()" );struct mgmt_addr_info {bdaddr_t bdaddr;
net/bluetooth/mgmt_config.c +2 -2
@@ -13,13 +13,13 @@#define HDEV_PARAM_U16 (_param_name_) \ struct {\ - struct mgmt_tlv entry; \ + struct mgmt_tlv_hdr entry; \ __le16 value; \ } __packed _param_name_#define HDEV_PARAM_U8 (_param_name_) \ struct {\ - struct mgmt_tlv entry; \ + struct mgmt_tlv_hdr entry; \ __u8 value; \ } __packed _param_name_
Signature · 1 line
2.43.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1000473
---Test result---
Test Summary:
CheckPatch PENDING 0.50 seconds GitLint PENDING 0.25 seconds SubjectPrefix PASS 0.08 seconds BuildKernel PASS 24.72 seconds CheckAllWarning PASS 27.53 seconds CheckSparse PASS 30.82 seconds BuildKernel32 PASS 24.53 seconds TestRunnerSetup PASS 486.66 seconds TestRunner_l2cap-tester PASS 25.33 seconds TestRunner_iso-tester PASS 39.31 seconds TestRunner_bnep-tester PASS 5.99 seconds TestRunner_mgmt-tester FAIL 127.39 seconds TestRunner_rfcomm-tester PASS 9.29 seconds TestRunner_sco-tester PASS 14.82 seconds TestRunner_ioctl-tester PASS 10.08 seconds TestRunner_mesh-tester FAIL 11.54 seconds TestRunner_smp-tester PASS 8.63 seconds TestRunner_userchan-tester PASS 6.27 seconds IncrementalBuild PENDING 0.56 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.107 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 1.991 seconds Mesh - Send cancel - 2 Timed out 1.998 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Quoted 9 lines · Gustavo A. R. Silva
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Use the
__struct_group()helper to fix 31 instances of the following type of warnings:30
net/bluetooth/mgmt_config.c:16:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] 1net/bluetooth/mgmt_config.c:22:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
Quoted 7 lines
Signed-off-by Gustavo A. R. Silva <[email protected]>---
Changes in v2:
- Use__struct_group()instead ofTRAILING_OVERLAP().v1:
- Link: https://lore.kernel.org/linux-hardening/aLSCu8U62Hve7Dau@kspp/
Dear Gustavo,
Thank you for your patch.
Am 09.09.25 um 14:13 schrieb Gustavo A. R. Silva:
Quoted 8 lines
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Use the
__struct_group()helper to fix 31 instances of the following type of warnings:30
net/bluetooth/mgmt_config.c:16:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] 1net/bluetooth/mgmt_config.c:22:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
You could add an explanation, why the macro __struct_group() defined in include/uapi/linux/stddef.h fixes this, and why it is preferred over TRAILING_OVERLAP(). Also, the two underscores would suggest to me, it’s some kind of internal implementation.
Quoted 45 lines
Signed-off-by Gustavo A. R. Silva <[email protected]>---
Changes in v2:
- Use__struct_group()instead ofTRAILING_OVERLAP().v1:
- Link: https://lore.kernel.org/linux-hardening/aLSCu8U62Hve7Dau@kspp/include/net/bluetooth/mgmt.h | 9 +++++++-- net/bluetooth/mgmt_config.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-)include/net/bluetooth/mgmt.h +7
-2@@ -53,10 +53,15 @@ struct mgmt_hdr { } __packed;struct mgmt_tlv { -__le16 type; -__u8 length; +/* New members MUST be added within the __struct_group() macro below. */ + __struct_group(mgmt_tlv_hdr, __hdr, __packed, + __le16 type; +__u8 length; + );__u8 value[]; } __packed; +static_assert (offsetof(struct mgmt_tlv , value) ==sizeof (struct mgmt_tlv_hdr ), +"struct member likely outside of __struct_group()" );struct mgmt_addr_info {bdaddr_t bdaddr;net/bluetooth/mgmt_config.c +1
-1@@ -13,13 +13,13 @@#define HDEV_PARAM_U16 (_param_name_) \ struct {\ - struct mgmt_tlv entry; \ + struct mgmt_tlv_hdr entry; \
net/bluetooth/mgmt_config.c line 25
Quoted 10 lines
net/bluetooth/mgmt_config.c +1
-1__le16 value; \ } __packed _param_name_#define HDEV_PARAM_U8 (_param_name_) \ struct {\ - struct mgmt_tlv entry; \ + struct mgmt_tlv_hdr entry; \ __u8 value; \ } __packed _param_name_
Kind regards,
Paul
Hi all,
Friendly ping: who can take this, please? :)
Thanks!
-Gustavo
Quoted 63 lines · Gustavo A. R. Silva
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Use the
__struct_group()helper to fix 31 instances of the following type of warnings:30
net/bluetooth/mgmt_config.c:16:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] 1net/bluetooth/mgmt_config.c:22:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]Signed-off-by Gustavo A. R. Silva <[email protected]>---
Changes in v2:
- Use__struct_group()instead ofTRAILING_OVERLAP().v1:
- Link: https://lore.kernel.org/linux-hardening/aLSCu8U62Hve7Dau@kspp/include/net/bluetooth/mgmt.h | 9 +++++++-- net/bluetooth/mgmt_config.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-)include/net/bluetooth/mgmt.h +7
-2@@ -53,10 +53,15 @@ struct mgmt_hdr { } __packed;struct mgmt_tlv { -__le16 type; -__u8 length; +/* New members MUST be added within the __struct_group() macro below. */ + __struct_group(mgmt_tlv_hdr, __hdr, __packed, + __le16 type; +__u8 length; + );__u8 value[]; } __packed; +static_assert (offsetof(struct mgmt_tlv , value) ==sizeof (struct mgmt_tlv_hdr ), +"struct member likely outside of __struct_group()" );struct mgmt_addr_info {bdaddr_t bdaddr;net/bluetooth/mgmt_config.c +2
-2@@ -13,13 +13,13 @@#define HDEV_PARAM_U16 (_param_name_) \ struct {\ - struct mgmt_tlv entry; \ + struct mgmt_tlv_hdr entry; \ __le16 value; \ } __packed _param_name_#define HDEV_PARAM_U8 (_param_name_) \ struct {\ - struct mgmt_tlv entry; \ + struct mgmt_tlv_hdr entry; \ __u8 value; \ } __packed _param_name_
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 10 lines · On Tue, 9 Sep 2025 14:13:35 +0200 you wrote:
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Use the
__struct_group()helper to fix 31 instances of the following type of warnings:30
net/bluetooth/mgmt_config.c:16:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] 1net/bluetooth/mgmt_config.c:22:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end][...]
Here is the summary with links:
- [v2,next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
https://git.kernel.org/bluetooth/bluetooth-next/c/33c9dc51e8b4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 4 lines · On 9/25/25 15:40, [email protected] wrote:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Thank you, Luiz!
-Gustavo