public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
* [PATCH 0/2] net/bnxt: shadow variable warnings
@ 2026-03-12  0:20 Stephen Hemminger
  2026-03-12  0:20 ` [PATCH 1/2] eal: add RTE_MIN4 and RTE_MAX4 macros Stephen Hemminger
  2026-03-12  0:20 ` [PATCH 2/2] net/bnxt: fix shadow variable warnings Stephen Hemminger
  0 siblings, 2 replies; 6+ messages in thread
From: Stephen Hemminger @ 2026-03-12  0:20 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This allows bnxt driver to build cleanly with -Wshadow.
Part of a larger effort to globally enable shadow warning.

Stephen Hemminger (2):
  eal: add RTE_MIN4 and RTE_MAX4 macros
  net/bnxt: fix shadow variable warnings

 drivers/net/bnxt/bnxt.h        |  6 +++---
 drivers/net/bnxt/bnxt_ethdev.c |  3 +--
 drivers/net/bnxt/bnxt_rxq.c    |  6 ++----
 drivers/net/bnxt/bnxt_txr.c    |  3 ---
 lib/eal/include/rte_common.h   | 20 ++++++++++++++++++++
 5 files changed, 26 insertions(+), 12 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] eal: add RTE_MIN4 and RTE_MAX4 macros
  2026-03-12  0:20 [PATCH 0/2] net/bnxt: shadow variable warnings Stephen Hemminger
@ 2026-03-12  0:20 ` Stephen Hemminger
  2026-03-12  0:20 ` [PATCH 2/2] net/bnxt: fix shadow variable warnings Stephen Hemminger
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2026-03-12  0:20 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

These are analogous to the existing RTE_MIN3 macros and allow
drivers to take compute minimum of four values without invoking
the shadow warning gods.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/include/rte_common.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 573bf4f2ce..79364170d6 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -812,6 +812,16 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
 			(_b_min3 < _c_min3 ? _b_min3 : _c_min3); \
 	})
 
+/**
+ * Macro to return the minimum of four numbers
+ */
+#define RTE_MIN4(a, b, c, d) \
+	__extension__ ({ \
+		typeof (a) _min4_ab = RTE_MIN((a), (b)); \
+		typeof (c) _min4_cd = RTE_MIN((c), (d)); \
+		RTE_MIN(_min4_ab, _min4_cd); \
+	})
+
 /**
  * Macro to return the minimum of two numbers
  *
@@ -845,6 +855,16 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
 			(_b_max3 > _c_max3 ? _b_max3 : _c_max3); \
 	})
 
+/**
+ * Macro to return the maximum of four numbers
+ */
+#define RTE_MAX4(a, b, c, d) \
+	__extension__ ({ \
+		typeof (a) _max4_ab = RTE_MAX((a), (b)); \
+		typeof (c) _max4_cd = RTE_MAX((c), (d)); \
+		RTE_MAX(_max4_ab, _max4_cd); \
+	})
+
 /**
  * Macro to return the maximum of two numbers
  *
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] net/bnxt: fix shadow variable warnings
  2026-03-12  0:20 [PATCH 0/2] net/bnxt: shadow variable warnings Stephen Hemminger
  2026-03-12  0:20 ` [PATCH 1/2] eal: add RTE_MIN4 and RTE_MAX4 macros Stephen Hemminger
@ 2026-03-12  0:20 ` Stephen Hemminger
  2026-03-12 22:46   ` Kishore Padmanabha
  2026-03-17  8:02   ` Thomas Monjalon
  1 sibling, 2 replies; 6+ messages in thread
From: Stephen Hemminger @ 2026-03-12  0:20 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Kishore Padmanabha, Ajit Khaparde

Fix things flagged as warnings about shadowed variables.
If the variable was harmless overlap then just drop the shadowed
version. For min values case use RTE_MIN3() and RTE_MIN4().

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnxt/bnxt.h        | 6 +++---
 drivers/net/bnxt/bnxt_ethdev.c | 3 +--
 drivers/net/bnxt/bnxt_rxq.c    | 6 ++----
 drivers/net/bnxt/bnxt_txr.c    | 3 ---
 4 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 7515f0564f..8b81c11b32 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -1110,9 +1110,9 @@ inline uint16_t bnxt_max_rings(struct bnxt *bp)
 	 * max Tx rings == max Rx rings, one stat ctx for each.
 	 */
 	if (BNXT_STINGRAY(bp)) {
-		max_rx_rings = RTE_MIN(RTE_MIN(max_rx_rings / 2U,
-					       MAX_STINGRAY_RINGS),
-				       bp->max_stat_ctx / 2U);
+		max_rx_rings = RTE_MIN3(max_rx_rings / 2U,
+					MAX_STINGRAY_RINGS,
+					bp->max_stat_ctx / 2U);
 	} else {
 		max_rx_rings = RTE_MIN(max_rx_rings / 2U,
 				       bp->max_stat_ctx / 2U);
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index b677f9491d..f033c34aab 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -473,7 +473,7 @@ static int bnxt_setup_one_vnic(struct bnxt *bp, uint16_t vnic_id)
 
 	/* Alloc RSS context only if RSS mode is enabled */
 	if (dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_RSS) {
-		int j, nr_ctxs = bnxt_rss_ctxts(bp);
+		unsigned int nr_ctxs = bnxt_rss_ctxts(bp);
 
 		/* RSS table size in P5 is 512.
 		 * Cap max Rx rings to same value
@@ -3560,7 +3560,6 @@ bnxt_rx_descriptor_status_op(void *rx_queue, uint16_t offset)
 	 */
 #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
 	if (bp->flags & BNXT_FLAG_RX_VECTOR_PKT_MODE) {
-		struct rx_pkt_cmpl *rxcmp;
 		uint32_t cons;
 
 		/* Check status of completion descriptor. */
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index 91b3555df6..df9ed391c4 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -98,10 +98,8 @@ int bnxt_mq_rx_configure(struct bnxt *bp)
 			/* ETH_8/64_POOLs */
 			pools = conf->nb_queue_pools;
 			/* For each pool, allocate MACVLAN CFA rule & VNIC */
-			max_pools = RTE_MIN(bp->max_vnics,
-					    RTE_MIN(bp->max_l2_ctx,
-					    RTE_MIN(bp->max_rsscos_ctx,
-						    RTE_ETH_64_POOLS)));
+			max_pools = RTE_MIN4(bp->max_vnics, bp->max_l2_ctx,
+					    bp->max_rsscos_ctx, RTE_ETH_64_POOLS);
 			PMD_DRV_LOG_LINE(DEBUG,
 				    "pools = %u max_pools = %u",
 				    pools, max_pools);
diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
index 27758898b0..498778aae0 100644
--- a/drivers/net/bnxt/bnxt_txr.c
+++ b/drivers/net/bnxt/bnxt_txr.c
@@ -179,9 +179,6 @@ bnxt_check_pkt_needs_ts(struct rte_mbuf *m)
 		if (proto == RTE_ETHER_TYPE_ECPRI)
 			return true;
 		if (proto == RTE_ETHER_TYPE_VLAN) {
-			const struct rte_vlan_hdr *vh;
-			struct rte_vlan_hdr vh_copy;
-
 			vh = rte_pktmbuf_read(m, off, sizeof(*vh), &vh_copy);
 			if (unlikely(vh == NULL))
 				return false;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] net/bnxt: fix shadow variable warnings
  2026-03-12  0:20 ` [PATCH 2/2] net/bnxt: fix shadow variable warnings Stephen Hemminger
@ 2026-03-12 22:46   ` Kishore Padmanabha
  2026-03-17  8:02   ` Thomas Monjalon
  1 sibling, 0 replies; 6+ messages in thread
From: Kishore Padmanabha @ 2026-03-12 22:46 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Ajit Khaparde


[-- Attachment #1.1: Type: text/plain, Size: 4386 bytes --]

On Wed, Mar 11, 2026 at 8:21 PM Stephen Hemminger <
stephen@networkplumber.org> wrote:

> Fix things flagged as warnings about shadowed variables.
> If the variable was harmless overlap then just drop the shadowed
> version. For min values case use RTE_MIN3() and RTE_MIN4().
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>
Acked-by:  Kishore Padmanabha <kishore.padmanabha@broadcom.com>

>  drivers/net/bnxt/bnxt.h        | 6 +++---
>  drivers/net/bnxt/bnxt_ethdev.c | 3 +--
>  drivers/net/bnxt/bnxt_rxq.c    | 6 ++----
>  drivers/net/bnxt/bnxt_txr.c    | 3 ---
>  4 files changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
> index 7515f0564f..8b81c11b32 100644
> --- a/drivers/net/bnxt/bnxt.h
> +++ b/drivers/net/bnxt/bnxt.h
> @@ -1110,9 +1110,9 @@ inline uint16_t bnxt_max_rings(struct bnxt *bp)
>          * max Tx rings == max Rx rings, one stat ctx for each.
>          */
>         if (BNXT_STINGRAY(bp)) {
> -               max_rx_rings = RTE_MIN(RTE_MIN(max_rx_rings / 2U,
> -                                              MAX_STINGRAY_RINGS),
> -                                      bp->max_stat_ctx / 2U);
> +               max_rx_rings = RTE_MIN3(max_rx_rings / 2U,
> +                                       MAX_STINGRAY_RINGS,
> +                                       bp->max_stat_ctx / 2U);
>         } else {
>                 max_rx_rings = RTE_MIN(max_rx_rings / 2U,
>                                        bp->max_stat_ctx / 2U);
> diff --git a/drivers/net/bnxt/bnxt_ethdev.c
> b/drivers/net/bnxt/bnxt_ethdev.c
> index b677f9491d..f033c34aab 100644
> --- a/drivers/net/bnxt/bnxt_ethdev.c
> +++ b/drivers/net/bnxt/bnxt_ethdev.c
> @@ -473,7 +473,7 @@ static int bnxt_setup_one_vnic(struct bnxt *bp,
> uint16_t vnic_id)
>
>         /* Alloc RSS context only if RSS mode is enabled */
>         if (dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_RSS) {
> -               int j, nr_ctxs = bnxt_rss_ctxts(bp);
> +               unsigned int nr_ctxs = bnxt_rss_ctxts(bp);
>
>                 /* RSS table size in P5 is 512.
>                  * Cap max Rx rings to same value
> @@ -3560,7 +3560,6 @@ bnxt_rx_descriptor_status_op(void *rx_queue,
> uint16_t offset)
>          */
>  #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
>         if (bp->flags & BNXT_FLAG_RX_VECTOR_PKT_MODE) {
> -               struct rx_pkt_cmpl *rxcmp;
>                 uint32_t cons;
>
>                 /* Check status of completion descriptor. */
> diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
> index 91b3555df6..df9ed391c4 100644
> --- a/drivers/net/bnxt/bnxt_rxq.c
> +++ b/drivers/net/bnxt/bnxt_rxq.c
> @@ -98,10 +98,8 @@ int bnxt_mq_rx_configure(struct bnxt *bp)
>                         /* ETH_8/64_POOLs */
>                         pools = conf->nb_queue_pools;
>                         /* For each pool, allocate MACVLAN CFA rule & VNIC
> */
> -                       max_pools = RTE_MIN(bp->max_vnics,
> -                                           RTE_MIN(bp->max_l2_ctx,
> -                                           RTE_MIN(bp->max_rsscos_ctx,
> -                                                   RTE_ETH_64_POOLS)));
> +                       max_pools = RTE_MIN4(bp->max_vnics, bp->max_l2_ctx,
> +                                           bp->max_rsscos_ctx,
> RTE_ETH_64_POOLS);
>                         PMD_DRV_LOG_LINE(DEBUG,
>                                     "pools = %u max_pools = %u",
>                                     pools, max_pools);
> diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
> index 27758898b0..498778aae0 100644
> --- a/drivers/net/bnxt/bnxt_txr.c
> +++ b/drivers/net/bnxt/bnxt_txr.c
> @@ -179,9 +179,6 @@ bnxt_check_pkt_needs_ts(struct rte_mbuf *m)
>                 if (proto == RTE_ETHER_TYPE_ECPRI)
>                         return true;
>                 if (proto == RTE_ETHER_TYPE_VLAN) {
> -                       const struct rte_vlan_hdr *vh;
> -                       struct rte_vlan_hdr vh_copy;
> -
>                         vh = rte_pktmbuf_read(m, off, sizeof(*vh),
> &vh_copy);
>                         if (unlikely(vh == NULL))
>                                 return false;
> --
> 2.51.0
>
>

[-- Attachment #1.2: Type: text/html, Size: 5785 bytes --]

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5493 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] net/bnxt: fix shadow variable warnings
  2026-03-12  0:20 ` [PATCH 2/2] net/bnxt: fix shadow variable warnings Stephen Hemminger
  2026-03-12 22:46   ` Kishore Padmanabha
@ 2026-03-17  8:02   ` Thomas Monjalon
  2026-03-18  3:16     ` Stephen Hemminger
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2026-03-17  8:02 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Kishore Padmanabha, Ajit Khaparde

12/03/2026 01:20, Stephen Hemminger:
> Fix things flagged as warnings about shadowed variables.
> If the variable was harmless overlap then just drop the shadowed
> version. For min values case use RTE_MIN3() and RTE_MIN4().
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/bnxt/bnxt.h        | 6 +++---
>  drivers/net/bnxt/bnxt_ethdev.c | 3 +--
>  drivers/net/bnxt/bnxt_rxq.c    | 6 ++----
>  drivers/net/bnxt/bnxt_txr.c    | 3 ---
>  4 files changed, 6 insertions(+), 12 deletions(-)

Why not removing cflags += no_shadow_cflag ?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] net/bnxt: fix shadow variable warnings
  2026-03-17  8:02   ` Thomas Monjalon
@ 2026-03-18  3:16     ` Stephen Hemminger
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2026-03-18  3:16 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Kishore Padmanabha, Ajit Khaparde

On Tue, 17 Mar 2026 09:02:45 +0100
Thomas Monjalon <thomas@monjalon.net> wrote:

> 12/03/2026 01:20, Stephen Hemminger:
> > Fix things flagged as warnings about shadowed variables.
> > If the variable was harmless overlap then just drop the shadowed
> > version. For min values case use RTE_MIN3() and RTE_MIN4().
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  drivers/net/bnxt/bnxt.h        | 6 +++---
> >  drivers/net/bnxt/bnxt_ethdev.c | 3 +--
> >  drivers/net/bnxt/bnxt_rxq.c    | 6 ++----
> >  drivers/net/bnxt/bnxt_txr.c    | 3 ---
> >  4 files changed, 6 insertions(+), 12 deletions(-)  
> 
> Why not removing cflags += no_shadow_cflag ?
> 
> 

Yes, should do that, just wasn't on the tree I was testing.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-18  3:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12  0:20 [PATCH 0/2] net/bnxt: shadow variable warnings Stephen Hemminger
2026-03-12  0:20 ` [PATCH 1/2] eal: add RTE_MIN4 and RTE_MAX4 macros Stephen Hemminger
2026-03-12  0:20 ` [PATCH 2/2] net/bnxt: fix shadow variable warnings Stephen Hemminger
2026-03-12 22:46   ` Kishore Padmanabha
2026-03-17  8:02   ` Thomas Monjalon
2026-03-18  3:16     ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox