diff mbox series

[Intel-wired-lan,iwl-net,v1] ice: move static_assert to declaration section

Message ID 20241204150224.346606-1-mateusz.polchlopek@intel.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [Intel-wired-lan,iwl-net,v1] ice: move static_assert to declaration section | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 3 blamed authors not CCed: anthony.l.nguyen@intel.com jacob.e.keller@intel.com przemyslaw.kitszel@intel.com; 7 maintainers not CCed: kuba@kernel.org pabeni@redhat.com anthony.l.nguyen@intel.com jacob.e.keller@intel.com przemyslaw.kitszel@intel.com edumazet@google.com andrew+netdev@lunn.ch
netdev/build_clang success Errors and warnings before: 3 this patch: 3
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 Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 304 this patch: 304
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 138 this patch: 138
netdev/source_inline success Was 0 now: 0

Commit Message

Mateusz Polchlopek Dec. 4, 2024, 3:02 p.m. UTC
static_assert() needs to be placed in the declaration section,
so move it there in ice_cfg_tx_topo() function.

Current code causes following warnings on some gcc versions:
error: ISO C90 forbids mixed declarations and code
[-Werror=declaration-after-statement]

Fixes: c188afdc3611 ("ice: fix memleak in ice_init_tx_topology()")
Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ddp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Paul Menzel Dec. 4, 2024, 3:05 p.m. UTC | #1
Dear Mateusz,


Thank you for the patch.

Am 04.12.24 um 16:02 schrieb Mateusz Polchlopek:
> static_assert() needs to be placed in the declaration section,
> so move it there in ice_cfg_tx_topo() function.
> 
> Current code causes following warnings on some gcc versions:

Please list the versions you know of.

> error: ISO C90 forbids mixed declarations and code
> [-Werror=declaration-after-statement]

The above could be in one line, as it’s pasted.

> Fixes: c188afdc3611 ("ice: fix memleak in ice_init_tx_topology()")
> Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
> ---
>   drivers/net/ethernet/intel/ice/ice_ddp.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.c b/drivers/net/ethernet/intel/ice/ice_ddp.c
> index 69d5b1a28491..e885f84520ba 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ddp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ddp.c
> @@ -2388,6 +2388,8 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
>   	int status;
>   	u8 flags;
>   
> +	static_assert(ICE_PKG_BUF_SIZE == ICE_AQ_MAX_BUF_LEN);
> +
>   	if (!buf || !len)
>   		return -EINVAL;
>   
> @@ -2482,7 +2484,6 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
>   	}
>   
>   	/* Get the new topology buffer, reuse current topo copy mem */
> -	static_assert(ICE_PKG_BUF_SIZE == ICE_AQ_MAX_BUF_LEN);
>   	new_topo = topo;
>   	memcpy(new_topo, (u8 *)section + offset, size);

The diff looks good.


Kind regards,

Paul
Mateusz Polchlopek Dec. 5, 2024, 1:18 p.m. UTC | #2
On 12/4/2024 4:05 PM, Paul Menzel wrote:
> Dear Mateusz,
> 
> 
> Thank you for the patch.
> 
> Am 04.12.24 um 16:02 schrieb Mateusz Polchlopek:
>> static_assert() needs to be placed in the declaration section,
>> so move it there in ice_cfg_tx_topo() function.
>>
>> Current code causes following warnings on some gcc versions:
> 
> Please list the versions you know of.
> 

Sure, in next version I will add the info.

>> error: ISO C90 forbids mixed declarations and code
>> [-Werror=declaration-after-statement]
> 
> The above could be in one line, as it’s pasted.
> 

Okay, it will be fixed in v2

>> Fixes: c188afdc3611 ("ice: fix memleak in ice_init_tx_topology()")
>> Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
>> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
>> ---
>>   drivers/net/ethernet/intel/ice/ice_ddp.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.c b/drivers/net/ 
>> ethernet/intel/ice/ice_ddp.c
>> index 69d5b1a28491..e885f84520ba 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_ddp.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_ddp.c
>> @@ -2388,6 +2388,8 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const 
>> void *buf, u32 len)
>>       int status;
>>       u8 flags;
>> +    static_assert(ICE_PKG_BUF_SIZE == ICE_AQ_MAX_BUF_LEN);
>> +
>>       if (!buf || !len)
>>           return -EINVAL;
>> @@ -2482,7 +2484,6 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const 
>> void *buf, u32 len)
>>       }
>>       /* Get the new topology buffer, reuse current topo copy mem */
>> -    static_assert(ICE_PKG_BUF_SIZE == ICE_AQ_MAX_BUF_LEN);
>>       new_topo = topo;
>>       memcpy(new_topo, (u8 *)section + offset, size);
> 
> The diff looks good.
> 
> 
> Kind regards,
> 
> Paul

Thanks Paul for review!

BR
Mateusz Polchlopek Dec. 9, 2024, 2:32 p.m. UTC | #3
On 12/5/2024 2:18 PM, Mateusz Polchlopek wrote:
> 
> 
> On 12/4/2024 4:05 PM, Paul Menzel wrote:
>> Dear Mateusz,
>>
>>
>> Thank you for the patch.
>>
>> Am 04.12.24 um 16:02 schrieb Mateusz Polchlopek:
>>> static_assert() needs to be placed in the declaration section,
>>> so move it there in ice_cfg_tx_topo() function.
>>>
>>> Current code causes following warnings on some gcc versions:
>>
>> Please list the versions you know of.
>>
> 
> Sure, in next version I will add the info.
> 
>>> error: ISO C90 forbids mixed declarations and code
>>> [-Werror=declaration-after-statement]
>>
>> The above could be in one line, as it’s pasted.
>>
> 
> Okay, it will be fixed in v2
> 
>>> Fixes: c188afdc3611 ("ice: fix memleak in ice_init_tx_topology()")
>>> Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
>>> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
>>> ---
>>>   drivers/net/ethernet/intel/ice/ice_ddp.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.c b/drivers/net/ 
>>> ethernet/intel/ice/ice_ddp.c
>>> index 69d5b1a28491..e885f84520ba 100644
>>> --- a/drivers/net/ethernet/intel/ice/ice_ddp.c
>>> +++ b/drivers/net/ethernet/intel/ice/ice_ddp.c
>>> @@ -2388,6 +2388,8 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const 
>>> void *buf, u32 len)
>>>       int status;
>>>       u8 flags;
>>> +    static_assert(ICE_PKG_BUF_SIZE == ICE_AQ_MAX_BUF_LEN);
>>> +
>>>       if (!buf || !len)
>>>           return -EINVAL;
>>> @@ -2482,7 +2484,6 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const 
>>> void *buf, u32 len)
>>>       }
>>>       /* Get the new topology buffer, reuse current topo copy mem */
>>> -    static_assert(ICE_PKG_BUF_SIZE == ICE_AQ_MAX_BUF_LEN);
>>>       new_topo = topo;
>>>       memcpy(new_topo, (u8 *)section + offset, size);
>>
>> The diff looks good.
>>
>>
>> Kind regards,
>>
>> Paul
> 
> Thanks Paul for review!
> 
> BR
> 
> 

Ach... It occurred that this is not the problem with compiler version
but with re-introduction of the -Wdeclaration-after-statement flag in
my test setup :/

Nevertheless this move of static_assert is still considered as a good
practice, so I will send v2 to the net-next with some other polishing
of code as an improvement (and I will drop Fixes: tag).
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.c b/drivers/net/ethernet/intel/ice/ice_ddp.c
index 69d5b1a28491..e885f84520ba 100644
--- a/drivers/net/ethernet/intel/ice/ice_ddp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ddp.c
@@ -2388,6 +2388,8 @@  int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
 	int status;
 	u8 flags;
 
+	static_assert(ICE_PKG_BUF_SIZE == ICE_AQ_MAX_BUF_LEN);
+
 	if (!buf || !len)
 		return -EINVAL;
 
@@ -2482,7 +2484,6 @@  int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
 	}
 
 	/* Get the new topology buffer, reuse current topo copy mem */
-	static_assert(ICE_PKG_BUF_SIZE == ICE_AQ_MAX_BUF_LEN);
 	new_topo = topo;
 	memcpy(new_topo, (u8 *)section + offset, size);