From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>, stable@dpdk.org
Subject: [RFC PATCH 07/19] table: fix issues with variable shadowing
Date: Thu, 6 Nov 2025 14:09:36 +0000 [thread overview]
Message-ID: <20251106140948.2894678-8-bruce.richardson@intel.com> (raw)
In-Reply-To: <20251106140948.2894678-1-bruce.richardson@intel.com>
Building table library with -Wshadow reveals many warnings from shadowed
variables. Fix these by removing definitions, or renaming variables as
appropriate.
Fixes: 0c06fa3bfa8c ("table: support learner tables")
Fixes: d0a00966618b ("table: add exact match SWX table")
Fixes: 1e29a162482c ("table: separate out x86-specific from LRU header")
Fixes: 8aa327214ceb ("table: hash")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/table/rte_lru.h | 38 +++++++++++++++----------------
lib/table/rte_lru_arm64.h | 14 ++++++------
lib/table/rte_lru_x86.h | 4 ++--
lib/table/rte_swx_table_em.c | 2 --
lib/table/rte_swx_table_learner.c | 4 ++--
lib/table/rte_table_hash_key16.c | 4 +---
lib/table/rte_table_hash_key32.c | 4 +---
lib/table/rte_table_hash_key8.c | 4 +---
8 files changed, 33 insertions(+), 41 deletions(-)
diff --git a/lib/table/rte_lru.h b/lib/table/rte_lru.h
index 28aab12923..1436425e16 100644
--- a/lib/table/rte_lru.h
+++ b/lib/table/rte_lru.h
@@ -41,33 +41,33 @@ while (0)
#define lru_update(bucket, mru_val) \
do { \
- uint64_t x, pos, x0, x1, x2, mask; \
+ uint64_t _x, _pos, _x0, _x1, _x2, _mask; \
\
- x = bucket->lru_list; \
+ _x = bucket->lru_list; \
\
- pos = 4; \
- if ((x >> 48) == ((uint64_t) mru_val)) \
- pos = 3; \
+ _pos = 4; \
+ if ((_x >> 48) == ((uint64_t) mru_val)) \
+ _pos = 3; \
\
- if (((x >> 32) & 0xFFFFLLU) == ((uint64_t) mru_val)) \
- pos = 2; \
+ if (((_x >> 32) & 0xFFFFLLU) == ((uint64_t) mru_val)) \
+ _pos = 2; \
\
- if (((x >> 16) & 0xFFFFLLU) == ((uint64_t) mru_val)) \
- pos = 1; \
+ if (((_x >> 16) & 0xFFFFLLU) == ((uint64_t) mru_val)) \
+ _pos = 1; \
\
- if ((x & 0xFFFFLLU) == ((uint64_t) mru_val)) \
- pos = 0; \
+ if ((_x & 0xFFFFLLU) == ((uint64_t) mru_val)) \
+ _pos = 0; \
\
\
- pos <<= 4; \
- mask = (~0LLU) << pos; \
- x0 = x & (~mask); \
- x1 = (x >> 16) & mask; \
- x2 = (x << (48 - pos)) & (0xFFFFLLU << 48); \
- x = x0 | x1 | x2; \
+ _pos <<= 4; \
+ _mask = (~0LLU) << _pos; \
+ _x0 = _x & (~_mask); \
+ _x1 = (_x >> 16) & _mask; \
+ _x2 = (_x << (48 - _pos)) & (0xFFFFLLU << 48); \
+ _x = _x0 | _x1 | _x2; \
\
- if (pos != 64) \
- bucket->lru_list = x; \
+ if (_pos != 64) \
+ bucket->lru_list = _x; \
} while (0)
#elif (RTE_TABLE_HASH_LRU_STRATEGY == 2) || (RTE_TABLE_HASH_LRU_STRATEGY == 3)
diff --git a/lib/table/rte_lru_arm64.h b/lib/table/rte_lru_arm64.h
index f9a4678ee0..817b791b6e 100644
--- a/lib/table/rte_lru_arm64.h
+++ b/lib/table/rte_lru_arm64.h
@@ -40,16 +40,16 @@ f_lru_pos(uint64_t lru_list)
#define lru_update(bucket, mru_val) \
do { \
- const uint64_t orvals[] = {0xFFFFLLU, 0xFFFFLLU << 16, \
+ const uint64_t _orvals[] = {0xFFFFLLU, 0xFFFFLLU << 16, \
0xFFFFLLU << 32, 0xFFFFLLU << 48, 0LLU}; \
- const uint64_t decs[] = {0x1000100010001LLU, 0}; \
- uint64x1_t lru = vdup_n_u64(bucket->lru_list); \
- uint64x1_t vdec = vdup_n_u64(decs[mru_val>>2]); \
+ const uint64_t _decs[] = {0x1000100010001LLU, 0}; \
+ uint64x1_t _lru = vdup_n_u64(bucket->lru_list); \
+ uint64x1_t _vdec = vdup_n_u64(_decs[mru_val>>2]); \
bucket->lru_list = vget_lane_u64(vreinterpret_u64_u16( \
- vsub_u16(vreinterpret_u16_u64(lru), \
- vreinterpret_u16_u64(vdec))), \
+ vsub_u16(vreinterpret_u16_u64(_lru), \
+ vreinterpret_u16_u64(_vdec))), \
0); \
- bucket->lru_list |= orvals[mru_val]; \
+ bucket->lru_list |= _orvals[mru_val]; \
} while (0)
#endif
diff --git a/lib/table/rte_lru_x86.h b/lib/table/rte_lru_x86.h
index 93f4a136a8..de74513653 100644
--- a/lib/table/rte_lru_x86.h
+++ b/lib/table/rte_lru_x86.h
@@ -50,9 +50,9 @@ do { \
/* Find the minimum value (first zero word, if it's in there) */\
__m128i d = _mm_minpos_epu16(c); \
/* Second word is the index to found word (first word is the value) */\
- unsigned int pos = _mm_extract_epi16(d, 1); \
+ unsigned int _pos = _mm_extract_epi16(d, 1); \
/* move the recently used location to top of list */ \
- __m128i k = _mm_shuffle_epi8(b, *((__m128i *) &masks[2 * pos]));\
+ __m128i k = _mm_shuffle_epi8(b, *((__m128i *) &masks[2 * _pos]));\
/* Finally, update the original list with the reordered data */ \
bucket->lru_list = _mm_extract_epi64(k, 0); \
/* Phwew! */ \
diff --git a/lib/table/rte_swx_table_em.c b/lib/table/rte_swx_table_em.c
index 4ec54cb635..c408ea6fc3 100644
--- a/lib/table/rte_swx_table_em.c
+++ b/lib/table/rte_swx_table_em.c
@@ -621,8 +621,6 @@ table_create(struct rte_swx_table_params *params,
return t;
TAILQ_FOREACH(entry, entries, node) {
- int status;
-
status = table_add(t, entry);
if (status) {
table_free(t);
diff --git a/lib/table/rte_swx_table_learner.c b/lib/table/rte_swx_table_learner.c
index 2d61bceeaf..3680bf26c1 100644
--- a/lib/table/rte_swx_table_learner.c
+++ b/lib/table/rte_swx_table_learner.c
@@ -411,13 +411,13 @@ rte_swx_table_learner_lookup(void *table,
for (i = 0; i < TABLE_KEYS_PER_BUCKET; i++) {
uint64_t time = b->time[i];
uint32_t sig = b->sig[i];
- uint8_t *key = table_bucket_key_get(t, b, i);
+ uint8_t *k = table_bucket_key_get(t, b, i);
time <<= 32;
if ((time > input_time) &&
(sig == m->input_sig) &&
- t->params.keycmp_func(key, m->input_key, t->params.key_size)) {
+ t->params.keycmp_func(k, m->input_key, t->params.key_size)) {
uint64_t *data = table_bucket_data_get(t, b, i);
/* Hit. */
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index da24a7985d..5b69106dd7 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -1133,12 +1133,10 @@ rte_table_hash_lookup_key16_ext(
uint64_t buckets_mask_next = 0;
for ( ; buckets_mask; ) {
- uint64_t pkt_mask;
uint32_t pkt_index;
pkt_index = rte_ctz64(buckets_mask);
- pkt_mask = 1LLU << pkt_index;
- buckets_mask &= ~pkt_mask;
+ buckets_mask &= ~(1LLU << pkt_index);
lookup_grinder(pkt_index, buckets, keys, pkts_mask_out,
entries, buckets_mask_next, f);
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 297931a2a5..0963f57828 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -1167,12 +1167,10 @@ rte_table_hash_lookup_key32_ext(
uint64_t buckets_mask_next = 0;
for ( ; buckets_mask; ) {
- uint64_t pkt_mask;
uint32_t pkt_index;
pkt_index = rte_ctz64(buckets_mask);
- pkt_mask = 1LLU << pkt_index;
- buckets_mask &= ~pkt_mask;
+ buckets_mask &= ~(1LLU << pkt_index);
lookup_grinder(pkt_index, buckets, keys, pkts_mask_out,
entries, buckets_mask_next, f);
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 746863082f..5e9dcf10ee 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -1101,12 +1101,10 @@ rte_table_hash_lookup_key8_ext(
uint64_t buckets_mask_next = 0;
for ( ; buckets_mask; ) {
- uint64_t pkt_mask;
uint32_t pkt_index;
pkt_index = rte_ctz64(buckets_mask);
- pkt_mask = 1LLU << pkt_index;
- buckets_mask &= ~pkt_mask;
+ buckets_mask &= ~(1LLU << pkt_index);
lookup_grinder(pkt_index, buckets, keys, pkts_mask_out,
entries, buckets_mask_next, f);
--
2.48.1
next prev parent reply other threads:[~2025-11-06 14:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251106140948.2894678-1-bruce.richardson@intel.com>
2025-11-06 14:09 ` [RFC PATCH 01/19] eal: fix " 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 ` Bruce Richardson [this message]
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-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 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
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=20251106140948.2894678-8-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=stable@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;
as well as URLs for NNTP newsgroup(s).