Skip to contentSkip to conversation

More fixes after enabling -Wshadow

PATCH In review Thomas Monjalon 3 participants 7 messages Jan 21 Network drivers

lore
Share & tools
lore
#0 lore raw

cover More fixes after enabling -Wshadow

The drivers mvpp2 and mlx5 for Windows
were not checked when enabling -Wshadow.
Here are the missing small fixes.

Thomas Monjalon (2):
common/mlx5: fix variable shadowing
net/mvpp2: fix variable shadowing

 drivers/common/mlx5/windows/mlx5_glue.h | 2 +-
 drivers/net/mvpp2/mrvl_ethdev.c         | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/2 common/mlx5: fix variable shadowing

The word "unused" is too common for being used in a header. There is a warning because a parameter is named "unused" in mbuf:

lib/mbuf/rte_mbuf.h: In function 'rte_mbuf_tx_offload':
error: declaration of 'unused' shadows a previous local [-Werror=shadow]
1910 | uint64_t ol3, uint64_t ol2, uint64_t unused)

      |                                     ~~~~~~~~~^~~~~~

Such value should be prefixed with "MLX5".

Fixes bd935fe3e624 ("net/mlx5: wrap sampling actions per OS")
---
 drivers/common/mlx5/windows/mlx5_glue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/common/mlx5/windows/mlx5_glue.h +1 -1
index 5ba324ebc4..f53142e3d4 100644
@@ -16,7 +16,7 @@
 #endif
 
 #ifndef HAVE_MLX5DV_DR
-enum  mlx5dv_dr_domain_type { unused, };
+enum  mlx5dv_dr_domain_type { MLX5_UNUSED_DOMAIN_TYPE };
 struct mlx5dv_dr_domain;
 struct mlx5dv_dr_action;
 #endif
Signature · 1 line
2.52.0
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] common/mlx5: fix variable shadowing

Quoted 7 lines · Thomas Monjalon

The word "unused" is too common for being used in a header. There is a warning because a parameter is named "unused" in mbuf:

lib/mbuf/rte_mbuf.h: In function 'rte_mbuf_tx_offload':
error: declaration of 'unused' shadows a previous local [-Werror=shadow]
1910 | uint64_t ol3, uint64_t ol2, uint64_t unused)

Quoted 8 lines
      |                                     ~~~~~~~~~^~~~~~

Such value should be prefixed with "MLX5".

Fixes bd935fe3e624 ("net/mlx5: wrap sampling actions per OS")
Signature · 1 line
David Marchand
#3 lore raw

PATCH 2/2 net/mvpp2: fix variable shadowing

In reply to Thomas Monjalon

With shadowing warning enabled, we can see "i" was declared twice:

drivers/net/mvpp2/mrvl_ethdev.c: In function 'mrvl_rx_pkt_burst':
error: declaration of 'i' shadows a previous local [-Werror=shadow]
2676 | int i;
| ^
/mrvl_ethdev.c:2592:13: note: shadowed declaration is here
2592 | int i, ret, rx_done = 0;
| ^

Fixes afb4d0d0bf91 ("net/mrvl: add Rx/Tx support")
---
 drivers/net/mvpp2/mrvl_ethdev.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/mvpp2/mrvl_ethdev.c +0 -1
index 845819e4d8..1074092d43 100644
@@ -2673,7 +2673,6 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 			     (!rx_done && num < q->priv->bpool_init_size))) {
 			mrvl_fill_bpool(q, q->priv->fill_bpool_buffs);
 		} else if (unlikely(num > q->priv->bpool_max_size)) {
-			int i;
 			int pkt_to_remove = num - q->priv->bpool_init_size;
 			struct rte_mbuf *mbuf;
 			struct pp2_buff_inf buff;
Signature · 1 line
2.52.0
Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] net/mvpp2: fix variable shadowing

Quoted 11 lines · Thomas Monjalon

With shadowing warning enabled, we can see "i" was declared twice:

drivers/net/mvpp2/mrvl_ethdev.c: In function 'mrvl_rx_pkt_burst':
error: declaration of 'i' shadows a previous local [-Werror=shadow]
2676 | int i;
| ^
/mrvl_ethdev.c:2592:13: note: shadowed declaration is here
2592 | int i, ret, rx_done = 0;
| ^

Quoted 4 lines
Fixes afb4d0d0bf91 ("net/mrvl: add Rx/Tx support")
Signature · 1 line
David Marchand
Acked-by on the v1 series
#5 lore raw
In reply to Thomas Monjalon
Quoted 4 lines · Thomas Monjalon

The drivers mvpp2 and mlx5 for Windows
were not checked when enabling -Wshadow.
Here are the missing small fixes.

Quoted 8 lines

Thomas Monjalon (2):
common/mlx5: fix variable shadowing
net/mvpp2: fix variable shadowing

 drivers/common/mlx5/windows/mlx5_glue.h | 2 +-
 drivers/net/mvpp2/mrvl_ethdev.c         | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

Thanks Thomas.

#6 lore raw
In reply to Thomas Monjalon
Quoted 5 lines · Thomas Monjalon

The drivers mvpp2 and mlx5 for Windows
were not checked when enabling -Wshadow.
Here are the missing small fixes.

Quoted 7 lines

Thomas Monjalon (2):
common/mlx5: fix variable shadowing
net/mvpp2: fix variable shadowing

 drivers/common/mlx5/windows/mlx5_glue.h | 2 +-
 drivers/net/mvpp2/mrvl_ethdev.c         | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

Series applied, merci Thomas.

Signature · 1 line
David Marchand