]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
authorGustavo A. R. Silva <gustavoars@kernel.org>
Tue, 9 Sep 2025 12:13:35 +0000 (14:13 +0200)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sat, 27 Sep 2025 15:37:43 +0000 (11:37 -0400)
-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]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
include/net/bluetooth/mgmt.h
net/bluetooth/mgmt_config.c

index 3575cd16049a88051a0c1762f19f520f6d515568..74edea06985bfaa0af9bf99c6ba17e85d3111a56 100644 (file)
@@ -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;
index 6ef701c27da48db46f65894b2a6e5e5f2075f37b..c4063d200c0a6e473e8a769289c1d546ccd3fc4a 100644 (file)
 
 #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_