DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	stable@dpdk.org, Ori Kam <orika@nvidia.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Sean Zhang <xiazhang@nvidia.com>,
	Jing Chen <jing.d.chen@intel.com>,
	Helin Zhang <helin.zhang@intel.com>,
	Cunming Liang <cunming.liang@intel.com>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	David Marchand <david.marchand@redhat.com>,
	Remy Horton <remy.horton@intel.com>,
	Reshma Pattan <reshma.pattan@intel.com>,
	Harry van Haaren <harry.van.haaren@intel.com>
Subject: [RFC PATCH v2 19/33] app/test-pmd: fix build with shadow warnings enabled
Date: Fri,  7 Nov 2025 15:50:15 +0000	[thread overview]
Message-ID: <20251107155034.436809-20-bruce.richardson@intel.com> (raw)
In-Reply-To: <20251107155034.436809-1-bruce.richardson@intel.com>

Rename or remove shadowed variables so as to build cleanly with
-Wshadow.

Fixes: 55c074f3ba1d ("app/testpmd: support GENEVE option item")
Fixes: 9213c50e36fa ("app/testpmd: support GTP PSC option in raw sets")
Fixes: 26b7259a798d ("app/testpmd: support GRE option flow item")
Fixes: d2121ceccd29 ("app/testpmd: rework display of Rx descriptors")
Fixes: 90c263867b00 ("app/testpmd: enhance command-line parsing")
Fixes: 62d3216d6194 ("app/testpmd: add latency statistics calculation")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test-pmd/cmdline_flow.c | 42 ++++++++++++++++++-------------------
 app/test-pmd/config.c       | 15 +++++--------
 app/test-pmd/parameters.c   | 38 ++++++++++++++++-----------------
 app/test-pmd/testpmd.c      |  2 +-
 4 files changed, 45 insertions(+), 52 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 54b247899d..ebc036b14b 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -14064,7 +14064,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
 	for (i = n - 1 ; i >= 0; --i) {
 		const struct rte_flow_item_gtp *gtp;
-		const struct rte_flow_item_geneve_opt *opt;
+		const struct rte_flow_item_geneve_opt *geneve_opt;
 		struct rte_flow_item_ipv6_routing_ext *ext;
 
 		item = in->args.vc.pattern + i;
@@ -14136,16 +14136,16 @@ cmd_set_raw_parsed(const struct buffer *in)
 			size = sizeof(struct rte_geneve_hdr);
 			break;
 		case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
-			opt = (const struct rte_flow_item_geneve_opt *)
+			geneve_opt = (const struct rte_flow_item_geneve_opt *)
 								item->spec;
 			size = offsetof(struct rte_flow_item_geneve_opt,
 					option_len) + sizeof(uint8_t);
-			if (opt->option_len && opt->data) {
-				*total_size += opt->option_len *
+			if (geneve_opt->option_len && geneve_opt->data) {
+				*total_size += geneve_opt->option_len *
 					       sizeof(uint32_t);
 				rte_memcpy(data_tail - (*total_size),
-					   opt->data,
-					   opt->option_len * sizeof(uint32_t));
+					   geneve_opt->data,
+					   geneve_opt->option_len * sizeof(uint32_t));
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
@@ -14195,7 +14195,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 				goto error;
 			} else {
 				const struct rte_flow_item_gtp_psc
-					*opt = item->spec;
+					*gtp_opt = item->spec;
 				struct rte_gtp_psc_generic_hdr *hdr;
 				size_t hdr_size = RTE_ALIGN(sizeof(*hdr),
 							 sizeof(int32_t));
@@ -14203,7 +14203,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 				*total_size += hdr_size;
 				hdr = (typeof(hdr))(data_tail - (*total_size));
 				memset(hdr, 0, hdr_size);
-				*hdr = opt->hdr;
+				*hdr = gtp_opt->hdr;
 				hdr->ext_hdr_len = 1;
 				gtp_psc = i;
 				size = 0;
@@ -14225,25 +14225,25 @@ cmd_set_raw_parsed(const struct buffer *in)
 			size = 0;
 			if (item->spec) {
 				const struct rte_flow_item_gre_opt
-					*opt = item->spec;
-				if (opt->checksum_rsvd.checksum) {
+					*gre_opt = item->spec;
+				if (gre_opt->checksum_rsvd.checksum) {
 					*total_size +=
-						sizeof(opt->checksum_rsvd);
+						sizeof(gre_opt->checksum_rsvd);
 					rte_memcpy(data_tail - (*total_size),
-						   &opt->checksum_rsvd,
-						   sizeof(opt->checksum_rsvd));
+						   &gre_opt->checksum_rsvd,
+						   sizeof(gre_opt->checksum_rsvd));
 				}
-				if (opt->key.key) {
-					*total_size += sizeof(opt->key.key);
+				if (gre_opt->key.key) {
+					*total_size += sizeof(gre_opt->key.key);
 					rte_memcpy(data_tail - (*total_size),
-						   &opt->key.key,
-						   sizeof(opt->key.key));
+						   &gre_opt->key.key,
+						   sizeof(gre_opt->key.key));
 				}
-				if (opt->sequence.sequence) {
-					*total_size += sizeof(opt->sequence.sequence);
+				if (gre_opt->sequence.sequence) {
+					*total_size += sizeof(gre_opt->sequence.sequence);
 					rte_memcpy(data_tail - (*total_size),
-						   &opt->sequence.sequence,
-						   sizeof(opt->sequence.sequence));
+						   &gre_opt->sequence.sequence,
+						   sizeof(gre_opt->sequence.sequence));
 				}
 			}
 			proto = 0x2F;
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 3ce2a14a1b..62d7408bc4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -4490,15 +4490,9 @@ ring_rxd_display_dword(union igb_ring_dword dword)
 
 static void
 ring_rx_descriptor_display(const struct rte_memzone *ring_mz,
-#ifndef RTE_NET_INTEL_USE_16BYTE_DESC
 			   portid_t port_id,
-#else
-			   __rte_unused portid_t port_id,
-#endif
 			   uint16_t desc_id)
 {
-	struct igb_ring_desc_16_bytes *ring =
-		(struct igb_ring_desc_16_bytes *)ring_mz->addr;
 #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
 	int ret;
 	struct rte_eth_dev_info dev_info;
@@ -4528,12 +4522,15 @@ ring_rx_descriptor_display(const struct rte_memzone *ring_mz,
 	}
 #endif
 	/* 16 bytes RX descriptor */
+	struct igb_ring_desc_16_bytes *ring =
+		(struct igb_ring_desc_16_bytes *)ring_mz->addr;
 	ring[desc_id].lo_dword.dword =
 		rte_le_to_cpu_64(ring[desc_id].lo_dword.dword);
 	ring_rxd_display_dword(ring[desc_id].lo_dword);
 	ring[desc_id].hi_dword.dword =
 		rte_le_to_cpu_64(ring[desc_id].hi_dword.dword);
 	ring_rxd_display_dword(ring[desc_id].hi_dword);
+	RTE_SET_USED(port_id);
 }
 
 static void
@@ -4742,7 +4739,6 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_algo)
 {
 	struct rte_eth_rss_conf rss_conf = {0};
 	uint8_t rss_key[RSS_HASH_KEY_LENGTH];
-	uint64_t rss_hf;
 	uint8_t i;
 	int diag;
 	struct rte_eth_dev_info dev_info;
@@ -4783,8 +4779,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_algo)
 		}
 		return;
 	}
-	rss_hf = rss_conf.rss_hf;
-	if (rss_hf == 0) {
+	if (rss_conf.rss_hf == 0) {
 		printf("RSS disabled\n");
 		return;
 	}
@@ -4796,7 +4791,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_algo)
 	}
 
 	printf("RSS functions:\n");
-	rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
+	rss_types_display(rss_conf.rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
 
 	if (!show_rss_key)
 		return;
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 96973906fd..f2037925c2 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -777,42 +777,42 @@ parse_ringnuma_config(const char *q_arg)
 }
 
 static int
-parse_event_printing_config(const char *optarg, int enable)
+parse_event_printing_config(const char *event_arg, int enable)
 {
 	uint32_t mask = 0;
 
-	if (!strcmp(optarg, "unknown"))
+	if (!strcmp(event_arg, "unknown"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
-	else if (!strcmp(optarg, "intr_lsc"))
+	else if (!strcmp(event_arg, "intr_lsc"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
-	else if (!strcmp(optarg, "queue_state"))
+	else if (!strcmp(event_arg, "queue_state"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
-	else if (!strcmp(optarg, "intr_reset"))
+	else if (!strcmp(event_arg, "intr_reset"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
-	else if (!strcmp(optarg, "vf_mbox"))
+	else if (!strcmp(event_arg, "vf_mbox"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
-	else if (!strcmp(optarg, "ipsec"))
+	else if (!strcmp(event_arg, "ipsec"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_IPSEC;
-	else if (!strcmp(optarg, "macsec"))
+	else if (!strcmp(event_arg, "macsec"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
-	else if (!strcmp(optarg, "intr_rmv"))
+	else if (!strcmp(event_arg, "intr_rmv"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
-	else if (!strcmp(optarg, "dev_probed"))
+	else if (!strcmp(event_arg, "dev_probed"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_NEW;
-	else if (!strcmp(optarg, "dev_released"))
+	else if (!strcmp(event_arg, "dev_released"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY;
-	else if (!strcmp(optarg, "flow_aged"))
+	else if (!strcmp(event_arg, "flow_aged"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_FLOW_AGED;
-	else if (!strcmp(optarg, "err_recovering"))
+	else if (!strcmp(event_arg, "err_recovering"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_ERR_RECOVERING;
-	else if (!strcmp(optarg, "recovery_success"))
+	else if (!strcmp(event_arg, "recovery_success"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_RECOVERY_SUCCESS;
-	else if (!strcmp(optarg, "recovery_failed"))
+	else if (!strcmp(event_arg, "recovery_failed"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_RECOVERY_FAILED;
-	else if (!strcmp(optarg, "all"))
+	else if (!strcmp(event_arg, "all"))
 		mask = ~UINT32_C(0);
 	else {
-		fprintf(stderr, "Invalid event: %s\n", optarg);
+		fprintf(stderr, "Invalid event: %s\n", event_arg);
 		return -1;
 	}
 	if (enable)
@@ -987,11 +987,10 @@ launch_args_parse(int argc, char** argv)
 			break;
 		case TESTPMD_OPT_STATS_PERIOD_NUM: {
 			char *end = NULL;
-			unsigned int n;
 
 			n = strtoul(optarg, &end, 10);
 			if ((optarg[0] == '\0') || (end == NULL) ||
-					(*end != '\0'))
+					(*end != '\0') || n <= 0 || n >= UINT16_MAX)
 				rte_exit(EXIT_FAILURE, "Invalid stats-period value\n");
 
 			stats_period = n;
@@ -1339,7 +1338,6 @@ launch_args_parse(int argc, char** argv)
 			break;
 		case TESTPMD_OPT_HAIRPIN_MODE_NUM: {
 			char *end = NULL;
-			unsigned int n;
 
 			errno = 0;
 			n = strtoul(optarg, &end, 0);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 2360da3a48..af724b2ea8 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4636,7 +4636,7 @@ main(int argc, char** argv)
 
 #ifdef RTE_LIB_LATENCYSTATS
 	if (latencystats_enabled != 0) {
-		int ret = rte_latencystats_init(1, NULL);
+		ret = rte_latencystats_init(1, NULL);
 		if (ret)
 			fprintf(stderr,
 				"Warning: latencystats init() returned error %d\n",
-- 
2.48.1


  parent reply	other threads:[~2025-11-07 15:53 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 01/19] eal: fix variable shadowing Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 02/19] ethdev: fix variable shadowing issues Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 03/19] eventdev: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 04/19] net: remove shadowed variable Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 05/19] graph: fix variable shadowing errors Bruce Richardson
2025-11-06 15:50   ` Stephen Hemminger
2025-11-06 16:33     ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 06/19] pipeline: fix variable shadowing Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 07/19] table: fix issues with " Bruce Richardson
2025-11-06 19:37   ` Stephen Hemminger
2025-11-06 19:58     ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 08/19] power: rename variable to eliminate shadowing Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 09/19] pcapng: rename variable to fix shadowing Bruce Richardson
2025-11-06 15:51   ` Stephen Hemminger
2025-11-06 14:09 ` [RFC PATCH 10/19] telemetry: make socket handler typedef private Bruce Richardson
2025-11-07  2:43   ` fengchengwen
2025-11-06 14:09 ` [RFC PATCH 11/19] bbdev: fix variable shadowing Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 12/19] bus/pci: remove shadowed variables Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 13/19] net/intel: rename function param to avoid shadow warnings Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 14/19] net/e1000: fix build with shadow warnings enabled Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 15/19] net/i40e: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 16/19] net/ice: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 17/19] net/cpfl: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 18/19] net/ixgbe: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 19/19] app/test-pmd: " Bruce Richardson
2025-11-07 15:49 ` [RFC PATCH v2 00/33] build DPDK with -Wshadow Bruce Richardson
2025-11-07 15:49   ` [RFC PATCH v2 01/33] eal: add more min/max helpers Bruce Richardson
2025-11-07 15:49   ` [RFC PATCH v2 02/33] eal: fix variable shadowing Bruce Richardson
2025-11-07 15:49   ` [RFC PATCH v2 03/33] ethdev: fix variable shadowing issues Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 04/33] eventdev: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 05/33] net: remove shadowed variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 06/33] pipeline: fix variable shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 07/33] table: fix issues with " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 08/33] power: rename variable to eliminate shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 09/33] pcapng: rename variable to fix shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 10/33] telemetry: make socket handler typedef private Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 11/33] bbdev: fix variable shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 12/33] bus/pci: remove shadowed variables Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 13/33] net/intel: rename function param to avoid shadow warnings Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 14/33] net/e1000: fix build with shadow warnings enabled Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 15/33] net/i40e: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 16/33] net/ice: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 17/33] net/cpfl: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 18/33] net/ixgbe: " Bruce Richardson
2025-11-07 15:50   ` Bruce Richardson [this message]
2025-11-07 15:50   ` [RFC PATCH v2 20/33] app/graph: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 21/33] app/pdump: fix warning about shadowed variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 22/33] app/test-bbdev: use RTE_MAX3 to remove variable shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 23/33] app/test-compress-perf: fix " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 24/33] app/test-crypto-perf: fix shadowed variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 25/33] app/test-dma-perf: renamed " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 26/33] app/test-eventdev: fix build with shadow warnings enabled Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 27/33] app/test-flow-perf: remove unneeded variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 28/33] app/test-security-perf: fix build with shadow warnings Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 29/33] app/test-pipeline: remove unnecessary variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 30/33] drivers: disable variable shadowing warnings for drivers Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 31/33] app/test: disable shadowing warnings for unit tests Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 32/33] examples: ignore variable shadowing warnings Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 33/33] build: enable shadowed variable warnings Bruce Richardson
2025-11-07 16:02   ` [RFC PATCH v2 00/33] build DPDK with -Wshadow Stephen Hemminger
2025-11-07 16:13     ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251107155034.436809-20-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=cunming.liang@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=harry.van.haaren@intel.com \
    --cc=helin.zhang@intel.com \
    --cc=jing.d.chen@intel.com \
    --cc=orika@nvidia.com \
    --cc=remy.horton@intel.com \
    --cc=reshma.pattan@intel.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@nvidia.com \
    --cc=xiazhang@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).