diff mbox series

[next] net: atlantic: Aavoid -Wflex-array-member-not-at-end warnings

Message ID ZrDwoVKH8d6TdVxn@cute (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [next] net: atlantic: Aavoid -Wflex-array-member-not-at-end warnings | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 34 this patch: 34
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-06--00-00 (tests: 707)

Commit Message

Gustavo A. R. Silva Aug. 5, 2024, 3:32 p.m. UTC
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Move the conflicting declaration to the end of the structure. Notice
that `struct hw_atl_utils_fw_rpc` ends in a flexible-array member
through `struct offload_info fw2x_offloads;`

Fix the following warnings:
drivers/net/ethernet/aquantia/atlantic/aq_hw.h:197:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:197:36: 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>
---
 drivers/net/ethernet/aquantia/atlantic/aq_hw.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Igor Russkikh Aug. 6, 2024, 9:42 a.m. UTC | #1
On 8/5/2024 5:32 PM, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally. Move the conflicting declaration to
> the end of the structure. Notice that `struct hw_atl_utils_fw_rpc` ends in
> a flexible-array member
> 
> Fix the following warnings:
> 
> drivers/net/ethernet/aquantia/atlantic/aq_hw.h:197:36: warning: structure
> containing a flexible array member is not at the end of another structure
> [-Wflex-array-member-not-at-end]
> 
> drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:197:36: warning:
> structure containing a flexible array member is not at the end of another
> structure [-Wflex-array-member-not-at-end]

Hi Gustavo!

I was abit curious about this variable length structure, because it looks strange and not actually used by driver.

I've cross checked, and its really some outdated declaration. The structure is never used as as a flex sized struct.

So better would be to do just this:

--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
@@ -226,7 +226,6 @@ struct __packed offload_info {
        struct offload_port_info ports;
        struct offload_ka_info kas;
        struct offload_rr_info rrs;
-       u8 buf[];
 };

Let me know if you want to submit this, or I can do this as well.

Regards,
  Igor
Gustavo A. R. Silva Aug. 6, 2024, 1:42 p.m. UTC | #2
On 06/08/24 03:42, Igor Russkikh wrote:
> 
> 
> On 8/5/2024 5:32 PM, Gustavo A. R. Silva wrote:
>> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
>> getting ready to enable it, globally. Move the conflicting declaration to
>> the end of the structure. Notice that `struct hw_atl_utils_fw_rpc` ends in
>> a flexible-array member
>>
>> Fix the following warnings:
>>
>> drivers/net/ethernet/aquantia/atlantic/aq_hw.h:197:36: warning: structure
>> containing a flexible array member is not at the end of another structure
>> [-Wflex-array-member-not-at-end]
>>
>> drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:197:36: warning:
>> structure containing a flexible array member is not at the end of another
>> structure [-Wflex-array-member-not-at-end]
> 
> Hi Gustavo!
> 
> I was abit curious about this variable length structure, because it looks strange and not actually used by driver.
> 
> I've cross checked, and its really some outdated declaration. The structure is never used as as a flex sized struct.

Oh, this is great to know. Thanks for looking into this!

> 
> So better would be to do just this:
> 
> --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
> +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
> @@ -226,7 +226,6 @@ struct __packed offload_info {
>          struct offload_port_info ports;
>          struct offload_ka_info kas;
>          struct offload_rr_info rrs;
> -       u8 buf[];
>   };
> 
> Let me know if you want to submit this, or I can do this as well.
> 

Feel free to send a patch if you wish. :)

Thanks!
--
Gustavo
diff mbox series

Patch

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
index f010bda61c96..a66cd784f90e 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
@@ -194,10 +194,12 @@  struct aq_hw_s {
 	u32 rpc_addr;
 	u32 settings_addr;
 	u32 rpc_tid;
-	struct hw_atl_utils_fw_rpc rpc;
 	s64 ptp_clk_offset;
 	u16 phy_id;
 	void *priv;
+
+	/* Must be last - ends in a flex-array member. */
+	struct hw_atl_utils_fw_rpc rpc;
 };
 
 struct aq_ring_s;