* [RFC PATCH 01/19] eal: fix variable shadowing
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 02/19] ethdev: fix variable shadowing issues Bruce Richardson
` (17 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
Fix a range of variable shadowing issues flagged by -Wshadow:
* In tracing code, rename local variables to remove shadowing in the
code. The file-level variable "trace" is kept as-is, but the shorter
name "t" is used for function-local vars.
* In options code, rename the "args" variable to "out_args" in the
telemetry callback, to fix shadowing issues there.
* In malloc code, remove the redefinition of aligned_end, and just use
the already-defined local variable in the last block of code in the
function.
Bugzilla ID: 1742
Bugzilla ID: 1743
Fixes: 29d985cad8db ("trace: implement memory allocation")
Fixes: f330b01df996 ("eal: define the parameters in argparse format")
Fixes: 4d8bdd8b56a1 ("malloc: fix ASan handling for unmapped memory")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/eal/common/eal_common_options.c | 12 ++--
lib/eal/common/eal_common_trace.c | 89 ++++++++++++++---------------
lib/eal/common/malloc_heap.c | 2 +-
3 files changed, 51 insertions(+), 52 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index b1fb670ea0..820725884f 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -339,21 +339,21 @@ int
handle_eal_info_request(const char *cmd, const char *params __rte_unused,
struct rte_tel_data *d)
{
- char **args;
+ char **out_args;
int used = 0;
int i = 0;
if (strcmp(cmd, EAL_PARAM_REQ) == 0)
- args = eal_args;
+ out_args = eal_args;
else
- args = eal_app_args;
+ out_args = eal_app_args;
rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
- if (args == NULL || args[0] == NULL)
+ if (out_args == NULL || out_args[0] == NULL)
return 0;
- for ( ; args[i] != NULL; i++)
- used = rte_tel_data_add_array_string(d, args[i]);
+ for ( ; out_args[i] != NULL; i++)
+ used = rte_tel_data_add_array_string(d, out_args[i]);
return used;
}
diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index be041c45bb..2ef5637cdd 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -270,33 +270,32 @@ trace_point_dump(FILE *f, struct trace_point *tp)
static void
trace_lcore_mem_dump(FILE *f)
{
- struct trace *trace = trace_obj_get();
+ struct trace *t = trace_obj_get();
struct __rte_trace_header *header;
uint32_t count;
- rte_spinlock_lock(&trace->lock);
- if (trace->nb_trace_mem_list == 0)
+ rte_spinlock_lock(&t->lock);
+ if (t->nb_trace_mem_list == 0)
goto out;
- fprintf(f, "nb_trace_mem_list = %d\n", trace->nb_trace_mem_list);
+ fprintf(f, "nb_trace_mem_list = %d\n", t->nb_trace_mem_list);
fprintf(f, "\nTrace mem info\n--------------\n");
- for (count = 0; count < trace->nb_trace_mem_list; count++) {
- header = trace->lcore_meta[count].mem;
+ for (count = 0; count < t->nb_trace_mem_list; count++) {
+ header = t->lcore_meta[count].mem;
fprintf(f, "\tid %d, mem=%p, area=%s, lcore_id=%d, name=%s\n",
count, header,
- trace_area_to_string(trace->lcore_meta[count].area),
+ trace_area_to_string(t->lcore_meta[count].area),
header->stream_header.lcore_id,
header->stream_header.thread_name);
}
out:
- rte_spinlock_unlock(&trace->lock);
+ rte_spinlock_unlock(&t->lock);
}
RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_trace_dump, 20.05)
void
rte_trace_dump(FILE *f)
{
- struct trace_point_head *tp_list = trace_list_head_get();
- struct trace *trace = trace_obj_get();
+ struct trace *t = trace_obj_get();
struct trace_point *tp;
fprintf(f, "\nGlobal info\n-----------\n");
@@ -304,13 +303,13 @@ rte_trace_dump(FILE *f)
rte_trace_is_enabled() ? "enabled" : "disabled");
fprintf(f, "mode = %s\n",
trace_mode_to_string(rte_trace_mode_get()));
- fprintf(f, "dir = %s\n", trace->dir);
- fprintf(f, "buffer len = %d\n", trace->buff_len);
- fprintf(f, "number of trace points = %d\n", trace->nb_trace_points);
+ fprintf(f, "dir = %s\n", t->dir);
+ fprintf(f, "buffer len = %d\n", t->buff_len);
+ fprintf(f, "number of trace points = %d\n", t->nb_trace_points);
trace_lcore_mem_dump(f);
fprintf(f, "\nTrace point info\n----------------\n");
- STAILQ_FOREACH(tp, tp_list, next)
+ STAILQ_FOREACH(tp, trace_list_head_get(), next)
trace_point_dump(f, tp);
}
@@ -331,7 +330,7 @@ RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_trace_mem_per_thread_alloc, 20.05)
void
__rte_trace_mem_per_thread_alloc(void)
{
- struct trace *trace = trace_obj_get();
+ struct trace *t = trace_obj_get();
struct __rte_trace_header *header;
uint32_t count;
@@ -341,30 +340,30 @@ __rte_trace_mem_per_thread_alloc(void)
if (RTE_PER_LCORE(trace_mem))
return;
- rte_spinlock_lock(&trace->lock);
+ rte_spinlock_lock(&t->lock);
- count = trace->nb_trace_mem_list;
+ count = t->nb_trace_mem_list;
/* Allocate room for storing the thread trace mem meta */
- trace->lcore_meta = realloc(trace->lcore_meta,
- sizeof(trace->lcore_meta[0]) * (count + 1));
+ t->lcore_meta = realloc(t->lcore_meta,
+ sizeof(t->lcore_meta[0]) * (count + 1));
/* Provide dummy space for fast path to consume */
- if (trace->lcore_meta == NULL) {
+ if (t->lcore_meta == NULL) {
trace_crit("trace mem meta memory realloc failed");
header = NULL;
goto fail;
}
/* First attempt from huge page */
- header = eal_malloc_no_trace(NULL, trace_mem_sz(trace->buff_len), 8);
+ header = eal_malloc_no_trace(NULL, trace_mem_sz(t->buff_len), 8);
if (header) {
- trace->lcore_meta[count].area = TRACE_AREA_HUGEPAGE;
+ t->lcore_meta[count].area = TRACE_AREA_HUGEPAGE;
goto found;
}
/* Second attempt from heap with proper alignment */
- size_t mem_size = trace_mem_sz(trace->buff_len);
+ size_t mem_size = trace_mem_sz(t->buff_len);
void *aligned_ptr = NULL;
int ret = posix_memalign(&aligned_ptr, 8, mem_size);
header = (ret == 0) ? aligned_ptr : NULL;
@@ -376,14 +375,14 @@ __rte_trace_mem_per_thread_alloc(void)
}
/* Second attempt from heap is success */
- trace->lcore_meta[count].area = TRACE_AREA_HEAP;
+ t->lcore_meta[count].area = TRACE_AREA_HEAP;
/* Initialize the trace header */
found:
header->offset = 0;
- header->len = trace->buff_len;
+ header->len = t->buff_len;
header->stream_header.magic = TRACE_CTF_MAGIC;
- rte_uuid_copy(header->stream_header.uuid, trace->uuid);
+ rte_uuid_copy(header->stream_header.uuid, t->uuid);
header->stream_header.lcore_id = rte_lcore_id();
/* Store the thread name */
@@ -392,11 +391,11 @@ __rte_trace_mem_per_thread_alloc(void)
thread_get_name(rte_thread_self(), name,
__RTE_TRACE_EMIT_STRING_LEN_MAX);
- trace->lcore_meta[count].mem = header;
- trace->nb_trace_mem_list++;
+ t->lcore_meta[count].mem = header;
+ t->nb_trace_mem_list++;
fail:
RTE_PER_LCORE(trace_mem) = header;
- rte_spinlock_unlock(&trace->lock);
+ rte_spinlock_unlock(&t->lock);
}
static void
@@ -411,7 +410,7 @@ trace_mem_per_thread_free_unlocked(struct thread_mem_meta *meta)
void
trace_mem_per_thread_free(void)
{
- struct trace *trace = trace_obj_get();
+ struct trace *t = trace_obj_get();
struct __rte_trace_header *header;
uint32_t count;
@@ -419,37 +418,37 @@ trace_mem_per_thread_free(void)
if (header == NULL)
return;
- rte_spinlock_lock(&trace->lock);
- for (count = 0; count < trace->nb_trace_mem_list; count++) {
- if (trace->lcore_meta[count].mem == header)
+ rte_spinlock_lock(&t->lock);
+ for (count = 0; count < t->nb_trace_mem_list; count++) {
+ if (t->lcore_meta[count].mem == header)
break;
}
- if (count != trace->nb_trace_mem_list) {
- struct thread_mem_meta *meta = &trace->lcore_meta[count];
+ if (count != t->nb_trace_mem_list) {
+ struct thread_mem_meta *meta = &t->lcore_meta[count];
trace_mem_per_thread_free_unlocked(meta);
- if (count != trace->nb_trace_mem_list - 1) {
+ if (count != t->nb_trace_mem_list - 1) {
memmove(meta, meta + 1,
sizeof(*meta) *
- (trace->nb_trace_mem_list - count - 1));
+ (t->nb_trace_mem_list - count - 1));
}
- trace->nb_trace_mem_list--;
+ t->nb_trace_mem_list--;
}
- rte_spinlock_unlock(&trace->lock);
+ rte_spinlock_unlock(&t->lock);
}
void
trace_mem_free(void)
{
- struct trace *trace = trace_obj_get();
+ struct trace *t = trace_obj_get();
uint32_t count;
- rte_spinlock_lock(&trace->lock);
- for (count = 0; count < trace->nb_trace_mem_list; count++) {
- trace_mem_per_thread_free_unlocked(&trace->lcore_meta[count]);
+ rte_spinlock_lock(&t->lock);
+ for (count = 0; count < t->nb_trace_mem_list; count++) {
+ trace_mem_per_thread_free_unlocked(&t->lcore_meta[count]);
}
- trace->nb_trace_mem_list = 0;
- rte_spinlock_unlock(&trace->lock);
+ t->nb_trace_mem_list = 0;
+ rte_spinlock_unlock(&t->lock);
}
RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_trace_point_emit_field, 20.05)
diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index 13a56e490e..39240c261c 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -1044,9 +1044,9 @@ malloc_heap_free(struct malloc_elem *elem)
/* if we unmapped some memory, we need to do additional work for ASan */
if (unmapped) {
void *asan_end = RTE_PTR_ADD(asan_ptr, asan_data_len);
- void *aligned_end = RTE_PTR_ADD(aligned_start, aligned_len);
void *aligned_trailer = RTE_PTR_SUB(aligned_start,
MALLOC_ELEM_TRAILER_LEN);
+ aligned_end = RTE_PTR_ADD(aligned_start, aligned_len);
/*
* There was a memory area that was unmapped. This memory area
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 02/19] ethdev: fix variable shadowing issues
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 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 03/19] eventdev: " Bruce Richardson
` (16 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
Remove unneeded extra variable definitions, and rename variables as
necessary to ensure clean compile with -Wshadow warnings enabled.
Fixes: e489007a411c ("ethdev: add generic create/destroy ethdev APIs")
Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/ethdev/ethdev_driver.c | 6 +++---
lib/ethdev/rte_ethdev.c | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c
index f89562b237..2ec665be0f 100644
--- a/lib/ethdev/ethdev_driver.c
+++ b/lib/ethdev/ethdev_driver.c
@@ -310,7 +310,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_eth_dev_create)
int
rte_eth_dev_create(struct rte_device *device, const char *name,
size_t priv_data_size,
- ethdev_bus_specific_init ethdev_bus_specific_init,
+ ethdev_bus_specific_init bus_specific_init,
void *bus_init_params,
ethdev_init_t ethdev_init, void *init_params)
{
@@ -358,8 +358,8 @@ rte_eth_dev_create(struct rte_device *device, const char *name,
ethdev->device = device;
- if (ethdev_bus_specific_init) {
- retval = ethdev_bus_specific_init(ethdev, bus_init_params);
+ if (bus_specific_init) {
+ retval = bus_specific_init(ethdev, bus_init_params);
if (retval) {
RTE_ETHDEV_LOG_LINE(ERR,
"ethdev bus specific initialisation failed");
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index c6fe0d5165..2659e8d9eb 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -2471,7 +2471,6 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
if (local_conf.offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO) {
uint32_t overhead_len;
uint32_t max_rx_pktlen;
- int ret;
overhead_len = eth_dev_get_overhead_len(dev_info.max_rx_pktlen,
dev_info.max_mtu);
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 03/19] eventdev: fix variable shadowing issues
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 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 04/19] net: remove shadowed variable Bruce Richardson
` (15 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
Rename a macro variable to avoid shadowing conflicts, and reduce the
scope of another variable for the same reason.
Fixes: a3bbf2e09756 ("eventdev: add eth Tx adapter implementation")
Fixes: 7f33abd49b26 ("eventdev/eth_rx: support appropriately report idle")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/eventdev/rte_event_eth_rx_adapter.c | 5 ++---
lib/eventdev/rte_event_eth_tx_adapter.c | 8 ++++----
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 994f256322..d564e14b72 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -1191,7 +1191,6 @@ rxa_intr_thread(void *arg)
static inline bool
rxa_intr_ring_dequeue(struct event_eth_rx_adapter *rx_adapter)
{
- uint32_t n;
uint32_t nb_rx = 0;
int rxq_empty;
struct eth_event_enqueue_buffer *buf;
@@ -1260,9 +1259,9 @@ rxa_intr_ring_dequeue(struct event_eth_rx_adapter *rx_adapter)
if (rxa_shared_intr(dev_info, queue)) {
uint16_t i;
uint16_t nb_queues;
+ uint32_t n = 0;
nb_queues = dev_info->dev->data->nb_rx_queues;
- n = 0;
for (i = dev_info->next_q_idx; i < nb_queues; i++) {
uint8_t enq_buffer_full;
@@ -1289,7 +1288,7 @@ rxa_intr_ring_dequeue(struct event_eth_rx_adapter *rx_adapter)
RTE_MAX_RXTX_INTR_VEC_ID - 1 :
0;
} else {
- n = rxa_eth_rx(rx_adapter, port, queue, nb_rx,
+ uint32_t n = rxa_eth_rx(rx_adapter, port, queue, nb_rx,
rx_adapter->max_nb_rx,
&rxq_empty, buf, stats);
rx_adapter->qd_valid = !rxq_empty;
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 83b6af0955..91c7be55c7 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -64,11 +64,11 @@ do { \
#define TXA_CHECK_OR_ERR_RET(id) \
do {\
- int ret; \
+ int _ret; \
RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET((id), -EINVAL); \
- ret = txa_init(); \
- if (ret != 0) \
- return ret; \
+ _ret = txa_init(); \
+ if (_ret != 0) \
+ return _ret; \
if (!txa_adapter_exist((id))) \
return -EINVAL; \
} while (0)
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 04/19] net: remove shadowed variable
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (2 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 03/19] eventdev: " Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 05/19] graph: fix variable shadowing errors Bruce Richardson
` (14 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The "mask" local variable shadowed a global definition. The local var
was only used on two lines as a temporary value to pass the return value
of one function as a parameter to another. Therefore, we can remove the
shadowing issue by removing the variable.
Fixes: 17a937baed3e ("net: add CRC AVX512 implementation")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/net/net_crc_avx512.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/net/net_crc_avx512.c b/lib/net/net_crc_avx512.c
index d18eb96971..7cd681b1cd 100644
--- a/lib/net/net_crc_avx512.c
+++ b/lib/net/net_crc_avx512.c
@@ -180,7 +180,6 @@ crc32_eth_calc_vpclmulqdq(const uint8_t *data, uint32_t data_len, uint32_t crc,
__m512i temp, k;
__m512i qw0 = _mm512_set1_epi64(0), qw1, qw2, qw3;
__m512i fold0, fold1, fold2, fold3;
- __mmask16 mask;
uint32_t n = 0;
int reduction = 0;
@@ -260,8 +259,7 @@ crc32_eth_calc_vpclmulqdq(const uint8_t *data, uint32_t data_len, uint32_t crc,
res = _mm_xor_si128(res, d);
} else {
res = _mm_cvtsi32_si128(crc);
- mask = byte_len_to_mask_table[data_len];
- d = _mm_maskz_loadu_epi8(mask, data);
+ d = _mm_maskz_loadu_epi8(byte_len_to_mask_table[data_len], data);
res = _mm_xor_si128(res, d);
if (data_len > 3) {
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 05/19] graph: fix variable shadowing errors
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (3 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 04/19] net: remove shadowed variable Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 15:50 ` Stephen Hemminger
2025-11-06 14:09 ` [RFC PATCH 06/19] pipeline: fix variable shadowing Bruce Richardson
` (13 subsequent siblings)
18 siblings, 1 reply; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The nested use of MIN/MAX macros causes shadowing due to the use of the
hard-coded temporary variable names in the macros. We can fix this in
graph library by using MIN_T/MAX_T macros instead, which actually makes
more sense in some circumstances:
* when defining SZ, use of RTE_MIN_T makes sense as the comments says it
is defined to be usable for compile-time evaluation.
* for the size calculations, RTE_MAX_T is also useful as it explicitly
encodes the type, making it clear that we are evaluating the size
variables as "int" type, larger than the uin16_t size is defined as.
Fixes: b6ef3794b866 ("graph: move node clone name func into private as common")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/graph/graph.c | 4 ++--
lib/graph/graph_private.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/graph/graph.c b/lib/graph/graph.c
index 61159edc72..fa03556f14 100644
--- a/lib/graph/graph.c
+++ b/lib/graph/graph.c
@@ -729,7 +729,7 @@ __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node)
RTE_VERIFY(size != UINT16_MAX);
/* Allocate double amount of size to avoid immediate realloc */
- size = RTE_MIN(UINT16_MAX, RTE_MAX(RTE_GRAPH_BURST_SIZE, size * 2));
+ size = RTE_MIN(UINT16_MAX, RTE_MAX_T(RTE_GRAPH_BURST_SIZE, size * 2, int));
node->objs = rte_realloc_socket(node->objs, size * sizeof(void *),
RTE_CACHE_LINE_SIZE, graph->socket);
RTE_VERIFY(node->objs);
@@ -746,7 +746,7 @@ __rte_node_stream_alloc_size(struct rte_graph *graph, struct rte_node *node,
RTE_VERIFY(size != UINT16_MAX);
/* Allocate double amount of size to avoid immediate realloc */
- size = RTE_MIN(UINT16_MAX, RTE_MAX(RTE_GRAPH_BURST_SIZE, req_size * 2));
+ size = RTE_MIN(UINT16_MAX, RTE_MAX_T(RTE_GRAPH_BURST_SIZE, req_size * 2, int));
node->objs = rte_realloc_socket(node->objs, size * sizeof(void *),
RTE_CACHE_LINE_SIZE, graph->socket);
RTE_VERIFY(node->objs);
diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h
index 21912c0ae6..0e064b2d64 100644
--- a/lib/graph/graph_private.h
+++ b/lib/graph/graph_private.h
@@ -149,7 +149,7 @@ static inline int clone_name(char *new_name, char *base_name, const char *append
{
ssize_t sz, rc;
-#define SZ RTE_MIN(RTE_NODE_NAMESIZE, RTE_GRAPH_NAMESIZE)
+#define SZ RTE_MIN_T(RTE_NODE_NAMESIZE, RTE_GRAPH_NAMESIZE, uint16_t)
rc = rte_strscpy(new_name, base_name, SZ);
if (rc < 0)
goto fail;
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [RFC PATCH 05/19] graph: fix variable shadowing errors
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
0 siblings, 1 reply; 23+ messages in thread
From: Stephen Hemminger @ 2025-11-06 15:50 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, stable
On Thu, 6 Nov 2025 14:09:34 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:
> The nested use of MIN/MAX macros causes shadowing due to the use of the
> hard-coded temporary variable names in the macros. We can fix this in
> graph library by using MIN_T/MAX_T macros instead, which actually makes
> more sense in some circumstances:
>
> * when defining SZ, use of RTE_MIN_T makes sense as the comments says it
> is defined to be usable for compile-time evaluation.
> * for the size calculations, RTE_MAX_T is also useful as it explicitly
> encodes the type, making it clear that we are evaluating the size
> variables as "int" type, larger than the uin16_t size is defined as.
>
> Fixes: b6ef3794b866 ("graph: move node clone name func into private as common")
> Cc: stable@dpdk.org
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
I had a patch series (not sent) for lots of these.
This is how I addressed min/max
From 5c8d69c734f90a774f83aaf47bc6c61bb19f411e Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Thu, 28 Aug 2025 09:24:54 -0700
Subject: [PATCH 06/13] eal: add more min/max helpers
Add RTE_MIN3() to handle case of RTE_MIN(RTE_MIN(...)).
Change name of local temporary variables in RTE_MAX()
to allow for combinations of RTE_MIN(RTE_MAX(...)) without
causing shadow declaration warnings.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/eal/include/rte_common.h | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 9e7d84f929..1f0edef73f 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -799,6 +799,19 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
_a < _b ? _a : _b; \
})
+/**
+ * Macro to return the minimum of three numbers
+ */
+#define RTE_MIN3(a, b, c) \
+ __extension__ ({ \
+ typeof (a) _a = (a); \
+ typeof (b) _b = (b); \
+ typeof (c) _c = (c); \
+ _a < _b ? (_a < _c ? _a : _c) \
+ : (_b < _c ? _b : _c); \
+ })
+
+
/**
* Macro to return the minimum of two numbers
*
@@ -814,9 +827,9 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
*/
#define RTE_MAX(a, b) \
__extension__ ({ \
- typeof (a) _a = (a); \
- typeof (b) _b = (b); \
- _a > _b ? _a : _b; \
+ typeof (a) _ax = (a); \
+ typeof (b) _bx = (b); \
+ _ax > _bx ? _ax : _bx; \
})
/**
--
2.51.0
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [RFC PATCH 05/19] graph: fix variable shadowing errors
2025-11-06 15:50 ` Stephen Hemminger
@ 2025-11-06 16:33 ` Bruce Richardson
0 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 16:33 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, stable
On Thu, Nov 06, 2025 at 07:50:13AM -0800, Stephen Hemminger wrote:
> On Thu, 6 Nov 2025 14:09:34 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
>
> > The nested use of MIN/MAX macros causes shadowing due to the use of the
> > hard-coded temporary variable names in the macros. We can fix this in
> > graph library by using MIN_T/MAX_T macros instead, which actually makes
> > more sense in some circumstances:
> >
> > * when defining SZ, use of RTE_MIN_T makes sense as the comments says it
> > is defined to be usable for compile-time evaluation.
> > * for the size calculations, RTE_MAX_T is also useful as it explicitly
> > encodes the type, making it clear that we are evaluating the size
> > variables as "int" type, larger than the uin16_t size is defined as.
> >
> > Fixes: b6ef3794b866 ("graph: move node clone name func into private as common")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>
> I had a patch series (not sent) for lots of these.
> This is how I addressed min/max
>
> From 5c8d69c734f90a774f83aaf47bc6c61bb19f411e Mon Sep 17 00:00:00 2001
> From: Stephen Hemminger <stephen@networkplumber.org>
> Date: Thu, 28 Aug 2025 09:24:54 -0700
> Subject: [PATCH 06/13] eal: add more min/max helpers
>
> Add RTE_MIN3() to handle case of RTE_MIN(RTE_MIN(...)).
> Change name of local temporary variables in RTE_MAX()
> to allow for combinations of RTE_MIN(RTE_MAX(...)) without
> causing shadow declaration warnings.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Yep, since sending the set, I similarly changed the variables in the MAX
call to _x and _y, similar to you. I was also considering the MIN3 / MAX3
change too, but had not implemented it.
I'll roll your patch below into my set in next version, for 26.03.
/Bruce
> ---
> lib/eal/include/rte_common.h | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
> index 9e7d84f929..1f0edef73f 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -799,6 +799,19 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
> _a < _b ? _a : _b; \
> })
>
> +/**
> + * Macro to return the minimum of three numbers
> + */
> +#define RTE_MIN3(a, b, c) \
> + __extension__ ({ \
> + typeof (a) _a = (a); \
> + typeof (b) _b = (b); \
> + typeof (c) _c = (c); \
> + _a < _b ? (_a < _c ? _a : _c) \
> + : (_b < _c ? _b : _c); \
> + })
> +
> +
> /**
> * Macro to return the minimum of two numbers
> *
> @@ -814,9 +827,9 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
> */
> #define RTE_MAX(a, b) \
> __extension__ ({ \
> - typeof (a) _a = (a); \
> - typeof (b) _b = (b); \
> - _a > _b ? _a : _b; \
> + typeof (a) _ax = (a); \
> + typeof (b) _bx = (b); \
> + _ax > _bx ? _ax : _bx; \
> })
>
> /**
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [RFC PATCH 06/19] pipeline: fix variable shadowing
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (4 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 05/19] graph: fix variable shadowing errors Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 07/19] table: fix issues with " Bruce Richardson
` (12 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
Remove unnecessary inner variables and rename others in order to remove
variable shadowing warnings from the code.
Fixes: ea5ab65f5743 ("pipeline: relax table match field requirements")
Fixes: cdaa937d3eaa ("pipeline: support selector table")
Fixes: 5f3e6104227c ("pipeline: prepare for variable size headers")
Fixes: 724f3ef422e9 ("pipeline: generate custom instruction functions")
Fixes: 68b95704a6a3 ("pipeline: add API for shared library-based pipeline build")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/pipeline/rte_swx_ctl.c | 11 +++++------
lib/pipeline/rte_swx_pipeline.c | 21 ++++++++++-----------
lib/pipeline/rte_swx_pipeline_internal.h | 10 +++++-----
3 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c
index 4e9bb842a1..d24764cbbe 100644
--- a/lib/pipeline/rte_swx_ctl.c
+++ b/lib/pipeline/rte_swx_ctl.c
@@ -210,7 +210,7 @@ table_params_get(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)
uint32_t key_size = 0, key_offset = 0, action_data_size = 0, i;
if (table->info.n_match_fields) {
- uint32_t n_match_fields_em = 0, i;
+ uint32_t n_match_fields_em = 0;
/* Find first (smallest offset) and last (biggest offset) match fields. */
first = &table->mf[0];
@@ -855,22 +855,21 @@ selector_free(struct rte_swx_ctl_pipeline *ctl)
for (i = 0; i < ctl->info.n_selectors; i++) {
struct selector *s = &ctl->selectors[i];
- uint32_t i;
/* selector_fields. */
free(s->selector_fields);
/* groups. */
if (s->groups)
- for (i = 0; i < s->info.n_groups_max; i++)
- selector_group_members_free(s, i);
+ for (uint32_t j = 0; j < s->info.n_groups_max; j++)
+ selector_group_members_free(s, j);
free(s->groups);
/* pending_groups. */
if (s->pending_groups)
- for (i = 0; i < s->info.n_groups_max; i++)
- selector_pending_group_members_free(s, i);
+ for (uint32_t j = 0; j < s->info.n_groups_max; j++)
+ selector_pending_group_members_free(s, j);
free(s->pending_groups);
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index 2193bc4ebf..a9157815e4 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -1515,10 +1515,10 @@ static int
header_build(struct rte_swx_pipeline *p)
{
struct header *h;
- uint32_t n_bytes = 0, i;
+ uint32_t total_bytes = 0, i;
TAILQ_FOREACH(h, &p->headers, node) {
- n_bytes += h->st->n_bits / 8;
+ total_bytes += h->st->n_bits / 8;
}
for (i = 0; i < RTE_SWX_PIPELINE_THREADS_MAX; i++) {
@@ -1533,10 +1533,10 @@ header_build(struct rte_swx_pipeline *p)
sizeof(struct header_out_runtime));
CHECK(t->headers_out, ENOMEM);
- t->header_storage = calloc(1, n_bytes);
+ t->header_storage = calloc(1, total_bytes);
CHECK(t->header_storage, ENOMEM);
- t->header_out_storage = calloc(1, n_bytes);
+ t->header_out_storage = calloc(1, total_bytes);
CHECK(t->header_out_storage, ENOMEM);
TAILQ_FOREACH(h, &p->headers, node) {
@@ -14031,7 +14031,6 @@ instruction_group_list_create(struct rte_swx_pipeline *p)
for (i = 0; i < p->n_instructions; i++) {
struct instruction_data *data = &p->instruction_data[i];
- struct instruction_group *g;
uint32_t j;
/* Continue when the current instruction is not a jump destination. */
@@ -14746,11 +14745,11 @@ rte_swx_pipeline_build_from_lib(struct rte_swx_pipeline **pipeline,
/* Action instructions. */
TAILQ_FOREACH(a, &p->actions, node) {
- char name[RTE_SWX_NAME_SIZE * 2];
+ char action_name[RTE_SWX_NAME_SIZE * 2];
- snprintf(name, sizeof(name), "action_%s_run", a->name);
+ snprintf(action_name, sizeof(action_name), "action_%s_run", a->name);
- p->action_funcs[a->id] = dlsym(lib, name);
+ p->action_funcs[a->id] = dlsym(lib, action_name);
if (!p->action_funcs[a->id]) {
status = -EINVAL;
goto free;
@@ -14765,14 +14764,14 @@ rte_swx_pipeline_build_from_lib(struct rte_swx_pipeline **pipeline,
}
TAILQ_FOREACH(g, igl, node) {
- char name[RTE_SWX_NAME_SIZE * 2];
+ char pipeline_name[RTE_SWX_NAME_SIZE * 2];
if (g->first_instr_id == g->last_instr_id)
continue;
- snprintf(name, sizeof(name), "pipeline_func_%u", g->group_id);
+ snprintf(pipeline_name, sizeof(pipeline_name), "pipeline_func_%u", g->group_id);
- g->func = dlsym(lib, name);
+ g->func = dlsym(lib, pipeline_name);
if (!g->func) {
status = -EINVAL;
goto free;
diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h
index df864ea066..f527857861 100644
--- a/lib/pipeline/rte_swx_pipeline_internal.h
+++ b/lib/pipeline/rte_swx_pipeline_internal.h
@@ -1772,14 +1772,14 @@ emit_handler(struct thread *t)
if ((t->n_headers_out == 2) &&
(h1->ptr + h1->n_bytes == t->ptr) &&
(h0->ptr == h0->ptr0)) {
- uint32_t offset;
+ uint32_t ofs;
TRACE("Emit handler: header encapsulation.\n");
- offset = h0->n_bytes + h1->n_bytes;
- memcpy(t->ptr - offset, h0->ptr, h0->n_bytes);
- t->pkt.offset -= offset;
- t->pkt.length += offset;
+ ofs = h0->n_bytes + h1->n_bytes;
+ memcpy(t->ptr - ofs, h0->ptr, h0->n_bytes);
+ t->pkt.offset -= ofs;
+ t->pkt.length += ofs;
return;
}
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 07/19] table: fix issues with variable shadowing
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (5 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 06/19] pipeline: fix variable shadowing Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 08/19] power: rename variable to eliminate shadowing Bruce Richardson
` (11 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
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
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 08/19] power: rename variable to eliminate shadowing
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (6 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 07/19] table: fix issues with " Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 09/19] pcapng: rename variable to fix shadowing Bruce Richardson
` (10 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The "pause_duration" variable is a global and then shadowed as a local
var in clb_pause. Rename the local variable to allow building with
"-Wshadow".
Fixes: 4a8fbc28e431 ("power: add get/set pause duration API")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/power/rte_power_pmd_mgmt.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
index 6cacc562c2..a4d53aac2a 100644
--- a/lib/power/rte_power_pmd_mgmt.c
+++ b/lib/power/rte_power_pmd_mgmt.c
@@ -337,7 +337,7 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused,
struct queue_list_entry *queue_conf = arg;
struct pmd_core_cfg *lcore_conf;
const bool empty = nb_rx == 0;
- uint32_t pause_duration = rte_power_pmd_mgmt_get_pause_duration();
+ const uint32_t duration = rte_power_pmd_mgmt_get_pause_duration();
lcore_conf = RTE_LCORE_VAR(lcore_cfgs);
@@ -357,11 +357,11 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused,
if (global_data.intrinsics_support.power_pause) {
const uint64_t cur = rte_rdtsc();
const uint64_t wait_tsc =
- cur + global_data.tsc_per_us * pause_duration;
+ cur + global_data.tsc_per_us * duration;
rte_power_pause(wait_tsc);
} else {
uint64_t i;
- for (i = 0; i < global_data.pause_per_us * pause_duration; i++)
+ for (i = 0; i < global_data.pause_per_us * duration; i++)
rte_pause();
}
}
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 09/19] pcapng: rename variable to fix shadowing
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (7 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 08/19] power: rename variable to eliminate shadowing Bruce Richardson
@ 2025-11-06 14:09 ` 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
` (9 subsequent siblings)
18 siblings, 1 reply; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The "len" variable is shadowed within a function, so rename inner use to
the more descriptive "filter_len" to fix the issue.
Fixes: d1da6d0d04c7 ("pcapng: require per-interface information")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/pcapng/rte_pcapng.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 21bc94cea1..2cc9e2040d 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -296,16 +296,15 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port, uint16_t link_type,
opt = pcapng_add_option(opt, PCAPNG_IFB_HARDWARE,
ifhw, strlen(ifhw));
if (filter) {
- size_t len;
+ const size_t filter_len = strlen(filter) + 1;
- len = strlen(filter) + 1;
opt->code = PCAPNG_IFB_FILTER;
- opt->length = len;
+ opt->length = filter_len;
/* Encoding is that the first octet indicates string vs BPF */
opt->data[0] = 0;
memcpy(opt->data + 1, filter, strlen(filter));
- opt = (struct pcapng_option *)((uint8_t *)opt + pcapng_optlen(len));
+ opt = (struct pcapng_option *)((uint8_t *)opt + pcapng_optlen(filter_len));
}
opt = pcapng_add_option(opt, PCAPNG_OPT_END, NULL, 0);
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [RFC PATCH 09/19] pcapng: rename variable to fix shadowing
2025-11-06 14:09 ` [RFC PATCH 09/19] pcapng: rename variable to fix shadowing Bruce Richardson
@ 2025-11-06 15:51 ` Stephen Hemminger
0 siblings, 0 replies; 23+ messages in thread
From: Stephen Hemminger @ 2025-11-06 15:51 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, stable
On Thu, 6 Nov 2025 14:09:38 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:
> The "len" variable is shadowed within a function, so rename inner use to
> the more descriptive "filter_len" to fix the issue.
>
> Fixes: d1da6d0d04c7 ("pcapng: require per-interface information")
> Cc: stable@dpdk.org
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [RFC PATCH 10/19] telemetry: make socket handler typedef private
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (8 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 09/19] pcapng: rename variable to fix shadowing Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 11/19] bbdev: fix variable shadowing Bruce Richardson
` (8 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The socket handler typedef, just called "handler" does not belong in the
public namespace, especially since it is unprefixed. Rename to
"telemetry_sock_handler" and move to internal header.
Doing so also clears shadowing warnings in dmadev library, when it is
built with -Wshadow.
Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/telemetry/rte_telemetry.h | 11 -----------
lib/telemetry/telemetry.c | 2 +-
lib/telemetry/telemetry_internal.h | 11 +++++++++++
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index b9662a5213..0a58e518f7 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -325,17 +325,6 @@ typedef int (*telemetry_cb)(const char *cmd, const char *params,
typedef int (*telemetry_arg_cb)(const char *cmd, const char *params, void *arg,
struct rte_tel_data *info);
-/**
- * Used for handling data received over a telemetry socket.
- *
- * @param sock_id
- * ID for the socket to be used by the handler.
- *
- * @return
- * Void.
- */
-typedef void * (*handler)(void *sock_id);
-
/**
* Used when registering a command and callback function with telemetry.
*
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 1cbbffbf3f..cf4324421d 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -47,7 +47,7 @@ struct cmd_callback {
struct socket {
int sock;
char path[sizeof(((struct sockaddr_un *)0)->sun_path)];
- handler fn;
+ telemetry_sock_handler fn;
RTE_ATOMIC(uint16_t) *num_clients;
};
static struct socket v2_socket; /* socket for v2 telemetry */
diff --git a/lib/telemetry/telemetry_internal.h b/lib/telemetry/telemetry_internal.h
index b331e9458f..2fd9fbd7c1 100644
--- a/lib/telemetry/telemetry_internal.h
+++ b/lib/telemetry/telemetry_internal.h
@@ -25,6 +25,17 @@ enum rte_telemetry_legacy_data_req {
DATA_REQ
};
+/**
+ * Used for handling data received over a telemetry socket.
+ *
+ * @param sock_id
+ * ID for the socket to be used by the handler.
+ *
+ * @return
+ * Void.
+ */
+typedef void * (*telemetry_sock_handler)(void *sock_id);
+
/**
* This telemetry callback is used when registering a legacy telemetry command.
* It handles getting and formatting stats to be returned to telemetry when
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 11/19] bbdev: fix variable shadowing
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (9 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 10/19] telemetry: make socket handler typedef private Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 12/19] bus/pci: remove shadowed variables Bruce Richardson
` (7 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The "ret" variable is declared twice in rte_bbdev_setup_queues function.
The second declaration is unneeded so remove it.
Fixes: 4935e1e9f76e ("bbdev: introduce wireless base band device lib")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/bbdev/rte_bbdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c
index 6c98296bdb..ea644c1f9b 100644
--- a/lib/bbdev/rte_bbdev.c
+++ b/lib/bbdev/rte_bbdev.c
@@ -357,7 +357,7 @@ rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
if (dev->data->queues != NULL) {
VALID_FUNC_OR_RET_ERR(dev->dev_ops->queue_release, dev_id);
for (i = 0; i < dev->data->num_queues; i++) {
- int ret = dev->dev_ops->queue_release(dev, i);
+ ret = dev->dev_ops->queue_release(dev, i);
if (ret < 0) {
rte_bbdev_log(ERR,
"Device %u queue %u release failed",
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 12/19] bus/pci: remove shadowed variables
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (10 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 11/19] bbdev: fix variable shadowing Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 13/19] net/intel: rename function param to avoid shadow warnings Bruce Richardson
` (6 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
Remove two instances where we had duplicate shadowed local variables
called "ret". In each case, we could just remove the inner instance,
since the outer value was not needing to be preserved.
Fixes: 03ba15ca65c1 ("vfio: allow mapping MSI-X BARs if kernel allows it")
Fixes: c0ce0577e84d ("pci: consolidate address comparisons")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/bus/pci/linux/pci.c | 1 -
drivers/bus/pci/linux/pci_vfio.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 66d7e09a6e..2ffac82e94 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -326,7 +326,6 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
rte_pci_add_device(dev);
} else {
struct rte_pci_device *dev2;
- int ret;
TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) {
ret = rte_pci_addr_cmp(&dev->addr, &dev2->addr);
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index 8562fdcc6b..242f567ed7 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -797,7 +797,7 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
}
/* if we found our MSI-X BAR region, check if we can mmap it */
if (vfio_res->msix_table.bar_index != -1) {
- int ret = pci_vfio_msix_is_mappable(vfio_dev_fd,
+ ret = pci_vfio_msix_is_mappable(vfio_dev_fd,
vfio_res->msix_table.bar_index);
if (ret < 0) {
PCI_LOG(ERR, "Couldn't check if MSI-X BAR is mappable");
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 13/19] net/intel: rename function param to avoid shadow warnings
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (11 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 12/19] bus/pci: remove shadowed variables Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 14/19] net/e1000: fix build with shadow warnings enabled Bruce Richardson
` (5 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
The rx_free_thresh parameter was conflicting with a global value in
testpmd when certain driver-specific files were included in the testpmd
build. Rename the parameter to just "free_thresh" - the "rx" is
unnecessary since the function itself is for Rx queues.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/common/rx.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/intel/common/rx.h b/drivers/net/intel/common/rx.h
index 5012e4fced..80b62ce3d5 100644
--- a/drivers/net/intel/common/rx.h
+++ b/drivers/net/intel/common/rx.h
@@ -228,11 +228,11 @@ ci_rxq_mbuf_initializer(uint16_t port_id)
* Individual drivers may have other further tests beyond this.
*/
static inline bool
-ci_rxq_vec_capable(uint16_t nb_desc, uint16_t rx_free_thresh)
+ci_rxq_vec_capable(uint16_t nb_desc, uint16_t free_thresh)
{
if (!rte_is_power_of_2(nb_desc) ||
- rx_free_thresh < CI_RX_MAX_BURST ||
- (nb_desc % rx_free_thresh) != 0)
+ free_thresh < CI_RX_MAX_BURST ||
+ (nb_desc % free_thresh) != 0)
return false;
return true;
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 14/19] net/e1000: fix build with shadow warnings enabled
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (12 preceding siblings ...)
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 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 15/19] net/i40e: " Bruce Richardson
` (4 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
Variable "ret" was shadowed within the close function, so rename outer
variable to "retval" to clear the warnings.
Fixes: 62024eb82756 ("ethdev: change stop operation callback to return int")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/e1000/igc_ethdev.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/intel/e1000/igc_ethdev.c b/drivers/net/intel/e1000/igc_ethdev.c
index b9c91d2446..47a91fe38e 100644
--- a/drivers/net/intel/e1000/igc_ethdev.c
+++ b/drivers/net/intel/e1000/igc_ethdev.c
@@ -1313,14 +1313,14 @@ eth_igc_close(struct rte_eth_dev *dev)
struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
struct igc_adapter *adapter = IGC_DEV_PRIVATE(dev);
int retry = 0;
- int ret = 0;
+ int retval = 0;
PMD_INIT_FUNC_TRACE();
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
if (!adapter->stopped)
- ret = eth_igc_stop(dev);
+ retval = eth_igc_stop(dev);
igc_flow_flush(dev, NULL);
igc_clear_all_filter(dev);
@@ -1343,7 +1343,7 @@ eth_igc_close(struct rte_eth_dev *dev)
/* Reset any pending lock */
igc_reset_swfw_lock(hw);
- return ret;
+ return retval;
}
static void
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 15/19] net/i40e: fix build with shadow warnings enabled
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (13 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 14/19] net/e1000: fix build with shadow warnings enabled Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 16/19] net/ice: " Bruce Richardson
` (3 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The local variables defined with the I40E_WRITE_GLB_REG macro are
shadowing other variables. Rename the vars to start with "_" to avoid
this shadowing.
Fixes: 2bedd7277a10 ("net/i40e: print real global changes")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/i40e/i40e_ethdev.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/intel/i40e/i40e_ethdev.h b/drivers/net/intel/i40e/i40e_ethdev.h
index 3fca089d6c..70dc506037 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.h
+++ b/drivers/net/intel/i40e/i40e_ethdev.h
@@ -92,11 +92,11 @@
#define I40E_WRITE_GLB_REG(hw, reg, value) \
do { \
uint32_t ori_val; \
- struct rte_eth_dev *dev; \
- struct rte_eth_dev_data *dev_data; \
+ struct rte_eth_dev *_dev; \
+ struct rte_eth_dev_data *_dev_data; \
ori_val = I40E_READ_REG((hw), (reg)); \
- dev_data = ((struct i40e_adapter *)hw->back)->pf.dev_data; \
- dev = &rte_eth_devices[dev_data->port_id]; \
+ _dev_data = ((struct i40e_adapter *)hw->back)->pf.dev_data; \
+ _dev = &rte_eth_devices[_dev_data->port_id]; \
I40E_PCI_REG_WRITE(I40E_PCI_REG_ADDR((hw), \
(reg)), (value)); \
if (ori_val != value) \
@@ -104,7 +104,7 @@
"i40e device %s changed global " \
"register [0x%08x]. original: 0x%08x, " \
"new: 0x%08x ", \
- (dev->device->name), (reg), \
+ (_dev->device->name), (reg), \
(ori_val), (value)); \
} while (0)
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 16/19] net/ice: fix build with shadow warnings enabled
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (14 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 15/19] net/i40e: " Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 17/19] net/cpfl: " Bruce Richardson
` (2 subsequent siblings)
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The RTE_MIN macro used newly-defined local variables internally, which
means that it had variable shadowing issues when one RTE_MIN call was
used inside another. Fix this for ice driver by using two separate
RTE_MIN calls to have the same effect.
Fixes: 8c03aa5e00f0 ("net/ice: optimize maximum queue number calculation")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/ice/ice_ethdev.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/intel/ice/ice_ethdev.c b/drivers/net/intel/ice/ice_ethdev.c
index 4669eba7c7..d2bd423a69 100644
--- a/drivers/net/intel/ice/ice_ethdev.c
+++ b/drivers/net/intel/ice/ice_ethdev.c
@@ -995,9 +995,9 @@ ice_vsi_config_tc_queue_mapping(struct ice_hw *hw, struct ice_vsi *vsi,
if (vsi->adapter->hw.func_caps.common_cap.num_msix_vectors < 2) {
vsi->nb_qps = 0;
} else {
- vsi->nb_qps = RTE_MIN
- ((uint16_t)vsi->adapter->hw.func_caps.common_cap.num_msix_vectors - 2,
- RTE_MIN(vsi->nb_qps, ICE_MAX_Q_PER_TC));
+ vsi->nb_qps = RTE_MIN(vsi->nb_qps, ICE_MAX_Q_PER_TC);
+ vsi->nb_qps = RTE_MIN(vsi->nb_qps,
+ (uint16_t)vsi->adapter->hw.func_caps.common_cap.num_msix_vectors - 2);
/* cap max QPs to what the HW reports as num-children for each layer.
* Multiply num_children for each layer from the entry_point layer to
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 17/19] net/cpfl: fix build with shadow warnings enabled
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (15 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 16/19] net/ice: " Bruce Richardson
@ 2025-11-06 14:09 ` 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
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
Remove unnecessary variable definitions to ensure compiling with
-Wshadow enabled.
Fixes: db042ef09d26 ("net/cpfl: implement FXP rule creation and destroying")
Fixes: 41f20298ee8c ("net/cpfl: parse flow offloading hint from JSON")
Fixes: 3ca8f6b55435 ("net/cpfl: remove devargs from adapter structure")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c | 2 --
drivers/net/intel/cpfl/cpfl_flow_parser.c | 6 +++---
drivers/net/intel/cpfl/cpfl_fxp_rule.h | 2 --
drivers/net/intel/cpfl/cpfl_representor.h | 2 +-
4 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c b/drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c
index 689ed82f18..361827cb10 100644
--- a/drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c
+++ b/drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c
@@ -386,8 +386,6 @@ cpfl_fxp_parse_action(struct cpfl_itf *itf,
}
if (mr_action) {
- uint32_t i;
-
for (i = 0; i < rim->mr_num; i++)
if (cpfl_parse_mod_content(itf->adapter, rinfo,
&rim->rules[rim->pr_num + i],
diff --git a/drivers/net/intel/cpfl/cpfl_flow_parser.c b/drivers/net/intel/cpfl/cpfl_flow_parser.c
index a67c773d18..e7deb619ee 100644
--- a/drivers/net/intel/cpfl/cpfl_flow_parser.c
+++ b/drivers/net/intel/cpfl/cpfl_flow_parser.c
@@ -1098,12 +1098,12 @@ cpfl_parse_fieldvectors(struct cpfl_itf *itf, struct cpfl_flow_js_fv *js_fvs, in
fv[2 * offset] = (uint8_t)(temp_fv >> 8);
fv[2 * offset + 1] = (uint8_t)(temp_fv & 0x00ff);
} else if (type == CPFL_FV_TYPE_METADATA) {
- uint16_t type, v_offset, mask;
+ uint16_t v_offset, mask;
- type = js_fv->meta.type;
v_offset = js_fv->meta.offset;
mask = js_fv->meta.mask;
- temp_fv = cpfl_metadata_read16(&itf->adapter->meta, type, v_offset) & mask;
+ temp_fv = cpfl_metadata_read16(&itf->adapter->meta, js_fv->meta.type,
+ v_offset) & mask;
fv[2 * offset] = (uint8_t)(temp_fv & 0x00ff);
fv[2 * offset + 1] = (uint8_t)(temp_fv >> 8);
} else if (type == CPFL_FV_TYPE_PROTOCOL) {
diff --git a/drivers/net/intel/cpfl/cpfl_fxp_rule.h b/drivers/net/intel/cpfl/cpfl_fxp_rule.h
index ed757b80b1..94eab6808c 100644
--- a/drivers/net/intel/cpfl/cpfl_fxp_rule.h
+++ b/drivers/net/intel/cpfl/cpfl_fxp_rule.h
@@ -53,8 +53,6 @@ struct cpfl_rule_info {
};
};
-extern struct cpfl_vport_ext *vport;
-
int cpfl_rule_process(struct cpfl_itf *itf,
struct idpf_ctlq_info *tx_cq,
struct idpf_ctlq_info *rx_cq,
diff --git a/drivers/net/intel/cpfl/cpfl_representor.h b/drivers/net/intel/cpfl/cpfl_representor.h
index d7f6e186f8..5c3d3aa3f6 100644
--- a/drivers/net/intel/cpfl/cpfl_representor.h
+++ b/drivers/net/intel/cpfl/cpfl_representor.h
@@ -21,7 +21,7 @@ struct cpfl_repr_param {
struct cpfl_vport_info *vport_info;
};
-extern struct cpfl_devargs *devargs;
+struct cpfl_devargs;
int cpfl_repr_devargs_process(struct cpfl_adapter_ext *adapter, struct cpfl_devargs *devargs);
int cpfl_repr_create(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter);
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 18/19] net/ixgbe: fix build with shadow warnings enabled
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (16 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 17/19] net/cpfl: " Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 19/19] app/test-pmd: " Bruce Richardson
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The loop counter "i" was shadowed, with it being used in a macro and
also as a local variable in the function using that macro. Fix the issue
by making "i" a loop-local variable in all contexts.
Fixes: 76c6f89e80d4 ("ixgbe: support new flow director masks")
Fixes: 2c6b19af78e3 ("ethdev: increase flow type limit from 32 to 64")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/intel/ixgbe/ixgbe_fdir.c b/drivers/net/intel/ixgbe/ixgbe_fdir.c
index b6351bc2cf..97ef185583 100644
--- a/drivers/net/intel/ixgbe/ixgbe_fdir.c
+++ b/drivers/net/intel/ixgbe/ixgbe_fdir.c
@@ -67,8 +67,7 @@
#define IPV6_MASK_TO_ADDR(ipv6m, ipaddr) do { \
uint8_t ipv6_addr[16]; \
- uint8_t i; \
- for (i = 0; i < sizeof(ipv6_addr); i++) { \
+ for (uint8_t i = 0; i < sizeof(ipv6_addr); i++) { \
if ((ipv6m) & (1 << i)) \
ipv6_addr[i] = UINT8_MAX; \
else \
@@ -1282,7 +1281,7 @@ ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir_info
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct ixgbe_hw_fdir_info *info =
IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
- uint32_t fdirctrl, max_num, i;
+ uint32_t fdirctrl, max_num;
uint8_t offset;
fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
@@ -1317,7 +1316,7 @@ ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir_info
fdir_info->flow_types_mask[0] = 0ULL;
else
fdir_info->flow_types_mask[0] = IXGBE_FDIR_FLOW_TYPES;
- for (i = 1; i < RTE_FLOW_MASK_ARRAY_SIZE; i++)
+ for (uint32_t i = 1; i < RTE_FLOW_MASK_ARRAY_SIZE; i++)
fdir_info->flow_types_mask[i] = 0ULL;
fdir_info->flex_payload_unit = sizeof(uint16_t);
--
2.48.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [RFC PATCH 19/19] app/test-pmd: fix build with shadow warnings enabled
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
` (17 preceding siblings ...)
2025-11-06 14:09 ` [RFC PATCH 18/19] net/ixgbe: " Bruce Richardson
@ 2025-11-06 14:09 ` Bruce Richardson
18 siblings, 0 replies; 23+ messages in thread
From: Bruce Richardson @ 2025-11-06 14:09 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
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 | 4 +---
app/test-pmd/testpmd.c | 2 +-
4 files changed, 28 insertions(+), 35 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..e91d45fc45 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -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
^ permalink raw reply [flat|nested] 23+ messages in thread