* [Intel-wired-lan] [PATCH iwl-net v1] ice: move static_assert to declaration section
@ 2024-12-04 15:02 Mateusz Polchlopek
2024-12-04 15:05 ` Paul Menzel
0 siblings, 1 reply; 4+ messages in thread
From: Mateusz Polchlopek @ 2024-12-04 15:02 UTC (permalink / raw)
To: intel-wired-lan; +Cc: netdev, Mateusz Polchlopek, Marcin Szycik
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(-)
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);
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-net v1] ice: move static_assert to declaration section
2024-12-04 15:02 [Intel-wired-lan] [PATCH iwl-net v1] ice: move static_assert to declaration section Mateusz Polchlopek
@ 2024-12-04 15:05 ` Paul Menzel
2024-12-05 13:18 ` Mateusz Polchlopek
0 siblings, 1 reply; 4+ messages in thread
From: Paul Menzel @ 2024-12-04 15:05 UTC (permalink / raw)
To: Mateusz Polchlopek; +Cc: intel-wired-lan, netdev, Marcin Szycik
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-net v1] ice: move static_assert to declaration section
2024-12-04 15:05 ` Paul Menzel
@ 2024-12-05 13:18 ` Mateusz Polchlopek
2024-12-09 14:32 ` Mateusz Polchlopek
0 siblings, 1 reply; 4+ messages in thread
From: Mateusz Polchlopek @ 2024-12-05 13:18 UTC (permalink / raw)
To: Paul Menzel; +Cc: intel-wired-lan, netdev, Marcin Szycik
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-net v1] ice: move static_assert to declaration section
2024-12-05 13:18 ` Mateusz Polchlopek
@ 2024-12-09 14:32 ` Mateusz Polchlopek
0 siblings, 0 replies; 4+ messages in thread
From: Mateusz Polchlopek @ 2024-12-09 14:32 UTC (permalink / raw)
To: Paul Menzel; +Cc: intel-wired-lan, netdev, Marcin Szycik
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).
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-09 14:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 15:02 [Intel-wired-lan] [PATCH iwl-net v1] ice: move static_assert to declaration section Mateusz Polchlopek
2024-12-04 15:05 ` Paul Menzel
2024-12-05 13:18 ` Mateusz Polchlopek
2024-12-09 14:32 ` Mateusz Polchlopek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).