public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 22/23] examples/l3fwd: fix shadow variable warnings
Date: Mon,  6 Apr 2026 20:49:48 -0700	[thread overview]
Message-ID: <20260407035209.650419-23-stephen@networkplumber.org> (raw)
In-Reply-To: <20260407035209.650419-1-stephen@networkplumber.org>

Correct for shadow variables by renaming:
  - global ipv6 becomes ipv6_enabled (convert int to bool)
  - lcore_params used by eventdev becomes config_parsed
  - masks for sse globals get xmm_ prefix

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l3fwd/l3fwd.h        |  2 +-
 examples/l3fwd/l3fwd_em.c     | 32 ++++++++++++++++++--------------
 examples/l3fwd/l3fwd_em_hlm.h |  8 ++++----
 examples/l3fwd/l3fwd_lpm.c    |  4 ++--
 examples/l3fwd/l3fwd_route.h  | 12 ++++++------
 examples/l3fwd/main.c         | 12 ++++++------
 examples/l3fwd/meson.build    |  1 -
 7 files changed, 37 insertions(+), 34 deletions(-)

diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h
index 471e3b488f..349fc37c79 100644
--- a/examples/l3fwd/l3fwd.h
+++ b/examples/l3fwd/l3fwd.h
@@ -99,7 +99,7 @@ extern struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
 extern uint32_t enabled_port_mask;
 
 /* Used only in exact match mode. */
-extern int ipv6; /**< ipv6 is false by default. */
+extern bool ipv6_enabled; /**< ipv6 is false by default. */
 extern uint32_t hash_entry_number;
 
 extern xmm_t val_eth[RTE_MAX_ETHPORTS];
diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c
index 58c54ed77e..d8748a0edd 100644
--- a/examples/l3fwd/l3fwd_em.c
+++ b/examples/l3fwd/l3fwd_em.c
@@ -211,9 +211,9 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,
 static alignas(RTE_CACHE_LINE_SIZE) uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES];
 static alignas(RTE_CACHE_LINE_SIZE) uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES];
 
-static rte_xmm_t mask0;
-static rte_xmm_t mask1;
-static rte_xmm_t mask2;
+static rte_xmm_t xmm_mask0;
+static rte_xmm_t xmm_mask1;
+static rte_xmm_t xmm_mask2;
 
 #if defined(__SSE2__)
 static inline xmm_t
@@ -275,7 +275,7 @@ em_get_ipv4_dst_port(void *ipv4_hdr, uint16_t portid, void *lookup_struct)
 	 * Get 5 tuple: dst port, src port, dst IP address,
 	 * src IP address and protocol.
 	 */
-	key.xmm = em_mask_key(ipv4_hdr, mask0.x);
+	key.xmm = em_mask_key(ipv4_hdr, xmm_mask0.x);
 
 	/* Find destination port */
 	ret = rte_hash_lookup(ipv4_l3fwd_lookup_struct, (const void *)&key);
@@ -298,7 +298,7 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint16_t portid, void *lookup_struct)
 	void *data2 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t) + sizeof(xmm_t);
 
 	/* Get part of 5 tuple: src IP address lower 96 bits and protocol */
-	key.xmm[0] = em_mask_key(data0, mask1.x);
+	key.xmm[0] = em_mask_key(data0, xmm_mask1.x);
 
 	/*
 	 * Get part of 5 tuple: dst IP address lower 96 bits
@@ -314,7 +314,7 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint16_t portid, void *lookup_struct)
 	 * Get part of 5 tuple: dst port and src port
 	 * and dst IP address higher 32 bits.
 	 */
-	key.xmm[2] = em_mask_key(data2, mask2.x);
+	key.xmm[2] = em_mask_key(data2, xmm_mask2.x);
 
 	/* Find destination port */
 	ret = rte_hash_lookup(ipv6_l3fwd_lookup_struct, (const void *)&key);
@@ -375,8 +375,9 @@ populate_ipv4_flow_into_table(const struct rte_hash *h)
 	char srcbuf[INET6_ADDRSTRLEN];
 	char dstbuf[INET6_ADDRSTRLEN];
 
-	mask0 = (rte_xmm_t){.u32 = {BIT_8_TO_15, ALL_32_BITS,
-				ALL_32_BITS, ALL_32_BITS} };
+	xmm_mask0 = (rte_xmm_t) {
+		.u32 = { BIT_8_TO_15, ALL_32_BITS, ALL_32_BITS, ALL_32_BITS }
+	};
 
 	for (i = 0; i < route_num_v4; i++) {
 		struct em_rule *entry;
@@ -427,10 +428,13 @@ populate_ipv6_flow_into_table(const struct rte_hash *h)
 	char srcbuf[INET6_ADDRSTRLEN];
 	char dstbuf[INET6_ADDRSTRLEN];
 
-	mask1 = (rte_xmm_t){.u32 = {BIT_16_TO_23, ALL_32_BITS,
-				ALL_32_BITS, ALL_32_BITS} };
+	xmm_mask1 = (rte_xmm_t){
+		.u32 = { BIT_16_TO_23, ALL_32_BITS, ALL_32_BITS, ALL_32_BITS }
+	};
 
-	mask2 = (rte_xmm_t){.u32 = {ALL_32_BITS, ALL_32_BITS, 0, 0} };
+	xmm_mask2 = (rte_xmm_t){
+		.u32 = { ALL_32_BITS, ALL_32_BITS, 0, 0 }
+	};
 
 	for (i = 0; i < route_num_v6; i++) {
 		struct em_rule *entry;
@@ -507,11 +511,11 @@ em_check_ptype(int portid)
 		}
 	}
 
-	if (!ipv6 && !ptype_l3_ipv4_ext) {
+	if (!ipv6_enabled && !ptype_l3_ipv4_ext) {
 		printf("port %d cannot parse RTE_PTYPE_L3_IPV4_EXT\n", portid);
 		return 0;
 	}
-	if (ipv6 && !ptype_l3_ipv6_ext) {
+	if (ipv6_enabled && !ptype_l3_ipv6_ext) {
 		printf("port %d cannot parse RTE_PTYPE_L3_IPV6_EXT\n", portid);
 		return 0;
 	}
@@ -1010,7 +1014,7 @@ setup_hash(const int socketid)
 	 * Use data from ipv4/ipv6 l3fwd config file
 	 * directly to initialize the hash table.
 	 */
-	if (ipv6 == 0) {
+	if (!ipv6_enabled) {
 		/* populate the ipv4 hash */
 		populate_ipv4_flow_into_table(
 			ipv4_l3fwd_em_lookup_struct[socketid]);
diff --git a/examples/l3fwd/l3fwd_em_hlm.h b/examples/l3fwd/l3fwd_em_hlm.h
index c1d819997a..ccf5e34496 100644
--- a/examples/l3fwd/l3fwd_em_hlm.h
+++ b/examples/l3fwd/l3fwd_em_hlm.h
@@ -31,7 +31,7 @@ em_get_dst_port_ipv4xN(struct lcore_conf *qconf, struct rte_mbuf *m[],
 	const void *key_array[EM_HASH_LOOKUP_COUNT];
 
 	for (i = 0; i < EM_HASH_LOOKUP_COUNT; i++) {
-		get_ipv4_5tuple(m[i], mask0.x, &key[i]);
+		get_ipv4_5tuple(m[i], xmm_mask0.x, &key[i]);
 		key_array[i] = &key[i];
 	}
 
@@ -58,7 +58,7 @@ em_get_dst_port_ipv6xN(struct lcore_conf *qconf, struct rte_mbuf *m[],
 	const void *key_array[EM_HASH_LOOKUP_COUNT];
 
 	for (i = 0; i < EM_HASH_LOOKUP_COUNT; i++) {
-		get_ipv6_5tuple(m[i], mask1.x, mask2.x, &key[i]);
+		get_ipv6_5tuple(m[i], xmm_mask1.x, xmm_mask2.x, &key[i]);
 		key_array[i] = &key[i];
 	}
 
@@ -85,7 +85,7 @@ em_get_dst_port_ipv4xN_events(struct lcore_conf *qconf, struct rte_mbuf *m[],
 	const void *key_array[EM_HASH_LOOKUP_COUNT];
 
 	for (i = 0; i < EM_HASH_LOOKUP_COUNT; i++) {
-		get_ipv4_5tuple(m[i], mask0.x, &key[i]);
+		get_ipv4_5tuple(m[i], xmm_mask0.x, &key[i]);
 		key_array[i] = &key[i];
 	}
 
@@ -112,7 +112,7 @@ em_get_dst_port_ipv6xN_events(struct lcore_conf *qconf, struct rte_mbuf *m[],
 	const void *key_array[EM_HASH_LOOKUP_COUNT];
 
 	for (i = 0; i < EM_HASH_LOOKUP_COUNT; i++) {
-		get_ipv6_5tuple(m[i], mask1.x, mask2.x, &key[i]);
+		get_ipv6_5tuple(m[i], xmm_mask1.x, xmm_mask2.x, &key[i]);
 		key_array[i] = &key[i];
 	}
 
diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c
index a71eee69ec..2d2651e750 100644
--- a/examples/l3fwd/l3fwd_lpm.c
+++ b/examples/l3fwd/l3fwd_lpm.c
@@ -681,12 +681,12 @@ lpm_check_ptype(int portid)
 			ptype_l3_ipv6 = 1;
 	}
 
-	if (!ipv6 && !ptype_l3_ipv4) {
+	if (!ipv6_enabled && !ptype_l3_ipv4) {
 		printf("port %d cannot parse RTE_PTYPE_L3_IPV4\n", portid);
 		return 0;
 	}
 
-	if (ipv6 && !ptype_l3_ipv6) {
+	if (ipv6_enabled && !ptype_l3_ipv6) {
 		printf("port %d cannot parse RTE_PTYPE_L3_IPV6\n", portid);
 		return 0;
 	}
diff --git a/examples/l3fwd/l3fwd_route.h b/examples/l3fwd/l3fwd_route.h
index b02b9cc11c..fd688504c6 100644
--- a/examples/l3fwd/l3fwd_route.h
+++ b/examples/l3fwd/l3fwd_route.h
@@ -14,14 +14,14 @@
 #define	IPV6_ADDR_U32	(IPV6_ADDR_LEN / sizeof(uint32_t))
 
 #define GET_CB_FIELD(in, fd, base, lim, dlm)	do {            \
-	unsigned long val;                                      \
-	char *end;                                              \
+	unsigned long _val;                                     \
+	char *_end;                                             \
 	errno = 0;                                              \
-	val = strtoul((in), &end, (base));                      \
-	if (errno != 0 || end[0] != (dlm) || val > (lim))       \
+	_val = strtoul((in), &_end, (base));                    \
+	if (errno != 0 || _end[0] != (dlm) || _val > (lim))     \
 		return -EINVAL;                                 \
-	(fd) = (typeof(fd))val;                                 \
-	(in) = end + 1;                                         \
+	(fd) = (typeof(fd))_val;                                \
+	(in) = _end + 1;                                        \
 } while (0)
 
 struct ipv4_l3fwd_route {
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 4c64194794..8e65472d3d 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -94,7 +94,7 @@ xmm_t val_eth[RTE_MAX_ETHPORTS];
 uint32_t enabled_port_mask;
 
 /* Used only in exact match mode. */
-int ipv6; /**< ipv6 is false by default. */
+bool ipv6_enabled; /**< ipv6 is false by default. */
 
 struct lcore_conf lcore_conf[RTE_MAX_LCORE];
 
@@ -871,7 +871,7 @@ parse_args(int argc, char **argv)
 	char **argvopt;
 	int option_index;
 	char *prgname = argv[0];
-	uint8_t lcore_params = 0;
+	bool config_parsed = false;
 #ifdef RTE_LIB_EVENTDEV
 	uint8_t eventq_sched = 0;
 	uint8_t eth_rx_q = 0;
@@ -924,7 +924,7 @@ parse_args(int argc, char **argv)
 				print_usage(prgname);
 				return -1;
 			}
-			lcore_params = 1;
+			config_parsed = true;
 			break;
 		case CMD_LINK_OPT_ETH_LINK_SPEED_NUM:
 			speed_num = atoi(optarg);
@@ -966,7 +966,7 @@ parse_args(int argc, char **argv)
 			break;
 
 		case CMD_LINE_OPT_IPV6_NUM:
-			ipv6 = 1;
+			ipv6_enabled = true;
 			break;
 
 		case CMD_LINE_OPT_MAX_PKT_LEN_NUM:
@@ -1056,9 +1056,9 @@ parse_args(int argc, char **argv)
 		}
 	}
 
-	RTE_SET_USED(lcore_params); /* needed if no eventdev block */
+	RTE_SET_USED(config_parsed); /* needed if no eventdev block */
 #ifdef RTE_LIB_EVENTDEV
-	if (evt_rsrc->enabled && lcore_params) {
+	if (evt_rsrc->enabled && config_parsed) {
 		fprintf(stderr, "lcore config is not valid when event mode is selected\n");
 		return -1;
 	}
diff --git a/examples/l3fwd/meson.build b/examples/l3fwd/meson.build
index a5c47c02b4..74144c7979 100644
--- a/examples/l3fwd/meson.build
+++ b/examples/l3fwd/meson.build
@@ -22,4 +22,3 @@ if dpdk_conf.has('RTE_LIB_EVENTDEV')
     deps += 'eventdev'
 endif
 cflags += no_wvla_cflag
-cflags += no_shadow_cflag
-- 
2.53.0


  parent reply	other threads:[~2026-04-07  3:54 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07  3:49 [PATCH 00/23] examples: enable -Wshadow across all examples Stephen Hemminger
2026-04-07  3:49 ` [PATCH 01/23] examples/ethtool: fix shadow variable warning Stephen Hemminger
2026-04-07  3:49 ` [PATCH 02/23] examples/eventdev_pipeline: " Stephen Hemminger
2026-04-07  3:49 ` [PATCH 03/23] examples/dma: fix shadow variable warnings Stephen Hemminger
2026-04-07  3:49 ` [PATCH 04/23] examples/packet_ordering: fix shadow variable warning Stephen Hemminger
2026-04-07  3:49 ` [PATCH 05/23] examples/bond: fix shadow variable warnings Stephen Hemminger
2026-04-07  3:49 ` [PATCH 06/23] examples/vmdq: fix shadow variable warning Stephen Hemminger
2026-04-07  3:49 ` [PATCH 07/23] examples/server_node_efd: fix shadowed variable Stephen Hemminger
2026-04-07  3:49 ` [PATCH 08/23] examples/flow_filtering: fix shadowed variables Stephen Hemminger
2026-04-07  3:49 ` [PATCH 09/23] examples/ipsec-secgw: " Stephen Hemminger
2026-04-07  3:49 ` [PATCH 10/23] examples/ip_pipeline: fix shadow variable Stephen Hemminger
2026-04-07  3:49 ` [PATCH 11/23] examples/multi_process: fix shadowed variable Stephen Hemminger
2026-04-07  3:49 ` [PATCH 12/23] examples/vm_power_manage: enable shadow warnings Stephen Hemminger
2026-04-07  3:49 ` [PATCH 13/23] examples/bbdev_app: " Stephen Hemminger
2026-04-07  3:49 ` [PATCH 14/23] examples/ptpclient: fix shadow variable warnings Stephen Hemminger
2026-04-07  3:49 ` [PATCH 15/23] examples/vhost: fix shadow warnings Stephen Hemminger
2026-04-07  3:49 ` [PATCH 16/23] examples/qos_sched: eliminate shadowed variables Stephen Hemminger
2026-04-07  3:49 ` [PATCH 17/23] examples/l2fwd-jobstats: fix shadowed variable Stephen Hemminger
2026-04-07  3:49 ` [PATCH 18/23] examples/l2fwd-crypto: remove no shadow flag Stephen Hemminger
2026-04-07  3:49 ` [PATCH 19/23] examples/l2fwd-event: " Stephen Hemminger
2026-04-07  3:49 ` [PATCH 20/23] examples/l2fwd-keepalive: fix shadow variable warning Stephen Hemminger
2026-04-07  3:49 ` [PATCH 21/23] examples/l3fwd-graph: remove no shadow flag Stephen Hemminger
2026-04-07  3:49 ` Stephen Hemminger [this message]
2026-04-07  3:49 ` [PATCH 23/23] examples/l3fwd-power: fix shadow variable warnings Stephen Hemminger
2026-04-07  9:22 ` [PATCH 00/23] examples: enable -Wshadow across all examples Bruce Richardson
2026-04-07 15:15 ` [PATCH v2 00/23] examples: fix -Wshadow warnings Stephen Hemminger
2026-04-07 15:15   ` [PATCH v2 01/23] examples/ethtool: resolve shadow variable warnings Stephen Hemminger
2026-04-08  0:32     ` fengchengwen
2026-04-07 15:15   ` [PATCH v2 02/23] examples/eventdev_pipeline: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:15   ` [PATCH v2 03/23] examples/dma: resolve shadow variable warnings Stephen Hemminger
2026-04-08  0:30     ` fengchengwen
2026-04-07 15:16   ` [PATCH v2 04/23] examples/packet_ordering: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 05/23] examples/bond: resolve shadow variable warnings Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 06/23] examples/vmdq: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 07/23] examples/server_node_efd: " Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 08/23] examples/flow_filtering: resolve shadowed variable warnings Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 09/23] examples/ipsec-secgw: " Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 10/23] examples/ip_pipeline: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 11/23] examples/multi_process: resolve shadowed variable warnings Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 12/23] examples/vm_power_manage: enable shadow warnings Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 13/23] examples/bbdev_app: " Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 14/23] examples/ptpclient: resolve shadow variable warnings Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 15/23] examples/vhost: resolve shadow warnings Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 16/23] examples/qos_sched: eliminate shadowed variables Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 17/23] examples/l2fwd-jobstats: resolve shadowed variable Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 18/23] examples/l2fwd-crypto: resolve shadow variable Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 19/23] examples/l2fwd-event: resolve shadowed variable Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 20/23] examples/l2fwd-keepalive: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 21/23] examples/l3fwd-graph: " Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 22/23] examples/l3fwd: resolve shadow variable warnings Stephen Hemminger
2026-04-07 15:16   ` [PATCH v2 23/23] examples/l3fwd-power: " Stephen Hemminger

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=20260407035209.650419-23-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /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