Bluetooth: hci.h: Avoid a couple -Wflex-array-member-not-at-end warnings
Subsystems (4)
PATCH 1/1 Bluetooth: hci.h: Avoid a couple -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.
struct hci_std_codecs and struct hci_std_codecs_v2 are flexible structures, this is structures that contain a flexible-array member (__u8 codec[]; and struct hci_std_codec_v2 codec[];, correspondingly.)
Since struct hci_rp_read_local_supported_codecs and struct hci_rp_read_local_supported_codecs_v2 are defined by hardware, we create the new struct hci_std_codecs_hdr and struct hci_std_codecs_v2_hdr types, and use them to replace the object types causing trouble in struct hci_rp_read_local_supported_codecs and struct hci_rp_read_local_supported_codecs_v2, namely struct hci_std_codecs std_codecs; and struct hci_std_codecs_v2_hdr std_codecs;.
Also, once -fms-extensions is enabled, we can use transparent struct members in both struct hci_std_codecs and struct hci_std_codecs_v2_hdr.
Notice that the newly created types does not contain the flex-array member codec, which is the object causing the -Wfamnae warnings.
After these changes, the size of struct hci_rp_read_local_supported_codecs and struct hci_rp_read_local_supported_codecs_v2, along with their member's offsets remain the same, hence the memory layouts don't change:
Before changes:
struct hci_rp_read_local_supported_codecs {
__u8 status; /* 0 1 */
struct hci_std_codecs std_codecs; /* 1 1 */
struct hci_vnd_codecs vnd_codecs; /* 2 1 */ /* size: 3, cachelines: 1, members: 3 */
/* last cacheline: 3 bytes */
} __attribute__((__packed__));struct hci_rp_read_local_supported_codecs_v2 {
__u8 status; /* 0 1 */
struct hci_std_codecs_v2 std_codecs; /* 1 1 */
struct hci_vnd_codecs_v2 vendor_codecs; /* 2 1 */ /* size: 3, cachelines: 1, members: 3 */
/* last cacheline: 3 bytes */
} __attribute__((__packed__));After changes:
struct hci_rp_read_local_supported_codecs {
__u8 status; /* 0 1 */ struct hci_std_codecs_hdr std_codecs; /* 1 1 */ struct hci_vnd_codecs vnd_codecs; /* 2 1 */
/* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));
struct hci_rp_read_local_supported_codecs_v2 {
__u8 status; /* 0 1 */ struct hci_std_codecs_v2_hdr std_codecs; /* 1 1 */ struct hci_vnd_codecs_v2 vendor_codecs; /* 2 1 */
/* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));
With these changes fix the following warnings:
include/net/bluetooth/hci.h:1490:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] include/net/bluetooth/hci.h:1525:34: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
--- include/net/bluetooth/hci.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
include/net/bluetooth/hci.h +12 -4
@@ -1468,8 +1468,12 @@ struct hci_rp_read_data_block_size { } __packed;#define HCI_OP_READ_LOCAL_CODECS 0x100b -struct hci_std_codecs { +struct hci_std_codecs_hdr {__u8 num; +} __packed; + +struct hci_std_codecs { +struct hci_std_codecs_hdr ;__u8 codec[]; } __packed;
@@ -1487,7 +1491,7 @@ struct hci_vnd_codecs {struct hci_rp_read_local_supported_codecs {__u8 status; -struct hci_std_codecs std_codecs; +struct hci_std_codecs_hdr std_codecs;struct hci_vnd_codecs vnd_codecs; } __packed;
@@ -1504,8 +1508,12 @@ struct hci_std_codec_v2 {__u8 transport; } __packed; -struct hci_std_codecs_v2 { +struct hci_std_codecs_v2_hdr {__u8 num; +} __packed; + +struct hci_std_codecs_v2 { +struct hci_std_codecs_v2_hdr ;struct hci_std_codec_v2 codec[]; } __packed;
@@ -1522,7 +1530,7 @@ struct hci_vnd_codecs_v2 {struct hci_rp_read_local_supported_codecs_v2 {__u8 status; -struct hci_std_codecs_v2 std_codecs; +struct hci_std_codecs_v2_hdr std_codecs;struct hci_vnd_codecs_v2 vendor_codecs; } __packed;
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=1057406
---Test result---
Test Summary:
CheckPatch PENDING 0.43 seconds GitLint PENDING 0.28 seconds SubjectPrefix PASS 0.09 seconds BuildKernel PASS 25.81 seconds CheckAllWarning PASS 28.38 seconds CheckSparse PASS 31.61 seconds BuildKernel32 PASS 25.21 seconds TestRunnerSetup PASS 560.56 seconds TestRunner_l2cap-tester PASS 28.81 seconds TestRunner_iso-tester PASS 87.99 seconds TestRunner_bnep-tester PASS 6.47 seconds TestRunner_mgmt-tester FAIL 124.94 seconds TestRunner_rfcomm-tester PASS 9.74 seconds TestRunner_sco-tester FAIL 14.84 seconds TestRunner_ioctl-tester PASS 10.59 seconds TestRunner_mesh-tester FAIL 12.51 seconds TestRunner_smp-tester PASS 8.86 seconds TestRunner_userchan-tester PASS 6.93 seconds IncrementalBuild PENDING 0.71 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: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.114 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
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 2.528 seconds Mesh - Send cancel - 2 Timed out 1.991 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Hi all,
Friendly ping: who can take this, please?
Thanks
-Gustavo
Quoted 124 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.
struct
hci_std_codecsand structhci_std_codecs_v2are flexible structures, this is structures that contain a flexible-array member (__u8codec[]; and structhci_std_codec_v2codec[];, correspondingly.)Since struct
hci_rp_read_local_supported_codecsand structhci_rp_read_local_supported_codecs_v2are defined by hardware, we create the new structhci_std_codecs_hdrand structhci_std_codecs_v2_hdrtypes, and use them to replace the object types causing trouble in structhci_rp_read_local_supported_codecsand structhci_rp_read_local_supported_codecs_v2, namely structhci_std_codecsstd_codecs; and structhci_std_codecs_v2_hdrstd_codecs;.Also, once -fms-extensions is enabled, we can use transparent struct members in both struct
hci_std_codecsand structhci_std_codecs_v2_hdr.Notice that the newly created types does not contain the flex-array member
codec, which is the object causing the -Wfamnae warnings.After these changes, the size of struct
hci_rp_read_local_supported_codecsand structhci_rp_read_local_supported_codecs_v2, along with their member's offsets remain the same, hence the memory layouts don't change:Before changes:
structhci_rp_read_local_supported_codecs{__u8 status; /* 0 1 */ struct hci_std_codecs std_codecs; /* 1 1 */ struct hci_vnd_codecs vnd_codecs; /* 2 1 *//* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));struct
hci_rp_read_local_supported_codecs_v2{__u8 status; /* 0 1 */ struct hci_std_codecs_v2 std_codecs; /* 1 1 */ struct hci_vnd_codecs_v2 vendor_codecs; /* 2 1 *//* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));After changes:
structhci_rp_read_local_supported_codecs{__u8 status; /* 0 1 */ struct hci_std_codecs_hdr std_codecs; /* 1 1 */ struct hci_vnd_codecs vnd_codecs; /* 2 1 *//* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));struct
hci_rp_read_local_supported_codecs_v2{__u8 status; /* 0 1 */ struct hci_std_codecs_v2_hdr std_codecs; /* 1 1 */ struct hci_vnd_codecs_v2 vendor_codecs; /* 2 1 *//* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));With these changes fix the following warnings:
include/net/bluetooth/hci.h:1490:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]include/net/bluetooth/hci.h:1525:34: 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]>--- include/net/bluetooth/hci.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)include/net/bluetooth/hci.h +12
-4@@ -1468,8 +1468,12 @@ struct hci_rp_read_data_block_size { } __packed;#define HCI_OP_READ_LOCAL_CODECS 0x100b -struct hci_std_codecs { +struct hci_std_codecs_hdr {__u8 num; +} __packed; + +struct hci_std_codecs { +struct hci_std_codecs_hdr ;__u8 codec[]; } __packed;@@ -1487,7 +1491,7 @@ struct hci_vnd_codecs {struct hci_rp_read_local_supported_codecs {__u8 status; -struct hci_std_codecs std_codecs; +struct hci_std_codecs_hdr std_codecs;struct hci_vnd_codecs vnd_codecs; } __packed;@@ -1504,8 +1508,12 @@ struct hci_std_codec_v2 {__u8 transport; } __packed; -struct hci_std_codecs_v2 { +struct hci_std_codecs_v2_hdr {__u8 num; +} __packed; + +struct hci_std_codecs_v2 { +struct hci_std_codecs_v2_hdr ;struct hci_std_codec_v2 codec[]; } __packed;@@ -1522,7 +1530,7 @@ struct hci_vnd_codecs_v2 {struct hci_rp_read_local_supported_codecs_v2 {__u8 status; -struct hci_std_codecs_v2 std_codecs; +struct hci_std_codecs_v2_hdr std_codecs;struct hci_vnd_codecs_v2 vendor_codecs; } __packed;
Luiz Augusto von Dentz
maintainerHi Gustavo,
Quoted 4 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Just resend as this is no longer available via patchwork.
Quoted 129 lines
Thanks
-GustavoQuoted 124 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.
struct
hci_std_codecsand structhci_std_codecs_v2are flexible structures, this is structures that contain a flexible-array member (__u8codec[]; and structhci_std_codec_v2codec[];, correspondingly.)Since struct
hci_rp_read_local_supported_codecsand structhci_rp_read_local_supported_codecs_v2are defined by hardware, we create the new structhci_std_codecs_hdrand structhci_std_codecs_v2_hdrtypes, and use them to replace the object types causing trouble in structhci_rp_read_local_supported_codecsand structhci_rp_read_local_supported_codecs_v2, namely structhci_std_codecsstd_codecs; and structhci_std_codecs_v2_hdrstd_codecs;.Also, once -fms-extensions is enabled, we can use transparent struct members in both struct
hci_std_codecsand structhci_std_codecs_v2_hdr.Notice that the newly created types does not contain the flex-array member
codec, which is the object causing the -Wfamnae warnings.After these changes, the size of struct
hci_rp_read_local_supported_codecsand structhci_rp_read_local_supported_codecs_v2, along with their member's offsets remain the same, hence the memory layouts don't change:Before changes:
structhci_rp_read_local_supported_codecs{__u8 status; /* 0 1 */ struct hci_std_codecs std_codecs; /* 1 1 */ struct hci_vnd_codecs vnd_codecs; /* 2 1 *//* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));struct
hci_rp_read_local_supported_codecs_v2{__u8 status; /* 0 1 */ struct hci_std_codecs_v2 std_codecs; /* 1 1 */ struct hci_vnd_codecs_v2 vendor_codecs; /* 2 1 *//* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));After changes:
structhci_rp_read_local_supported_codecs{__u8 status; /* 0 1 */ struct hci_std_codecs_hdr std_codecs; /* 1 1 */ struct hci_vnd_codecs vnd_codecs; /* 2 1 *//* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));struct
hci_rp_read_local_supported_codecs_v2{__u8 status; /* 0 1 */ struct hci_std_codecs_v2_hdr std_codecs; /* 1 1 */ struct hci_vnd_codecs_v2 vendor_codecs; /* 2 1 *//* size: 3, cachelines: 1, members: 3 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__));With these changes fix the following warnings:
include/net/bluetooth/hci.h:1490:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]include/net/bluetooth/hci.h:1525:34: 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]>--- include/net/bluetooth/hci.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)include/net/bluetooth/hci.h +12
-4@@ -1468,8 +1468,12 @@ struct hci_rp_read_data_block_size { } __packed;#define HCI_OP_READ_LOCAL_CODECS 0x100b -struct hci_std_codecs { +struct hci_std_codecs_hdr {__u8 num; +} __packed; + +struct hci_std_codecs { +struct hci_std_codecs_hdr ;__u8 codec[]; } __packed;@@ -1487,7 +1491,7 @@ struct hci_vnd_codecs {struct hci_rp_read_local_supported_codecs {__u8 status; -struct hci_std_codecs std_codecs; +struct hci_std_codecs_hdr std_codecs;struct hci_vnd_codecs vnd_codecs; } __packed;@@ -1504,8 +1508,12 @@ struct hci_std_codec_v2 {__u8 transport; } __packed; -struct hci_std_codecs_v2 { +struct hci_std_codecs_v2_hdr {__u8 num; +} __packed; + +struct hci_std_codecs_v2 { +struct hci_std_codecs_v2_hdr ;struct hci_std_codec_v2 codec[]; } __packed;@@ -1522,7 +1530,7 @@ struct hci_vnd_codecs_v2 {struct hci_rp_read_local_supported_codecs_v2 {__u8 status; -struct hci_std_codecs_v2 std_codecs; +struct hci_std_codecs_v2_hdr std_codecs;struct hci_vnd_codecs_v2 vendor_codecs; } __packed;
Signature · 1 line
Luiz Augusto von Dentz