* [RFC 0/8] Avoid overlapping declarations
@ 2025-08-27 23:14 Stephen Hemminger
2025-08-27 23:14 ` [RFC 1/8] test/ring: avoid shadow variable usage Stephen Hemminger
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
This is first part of changes to fix places where a variable
declaration overlaps another. These get shown if -Wshadow
is enabled. Lots of drivers and eventdev still have
this problem.
Stephen Hemminger (8):
test/ring: avoid shadow variable usage
test/table: replace conflicting variable name
eal: add macro to disable shadow warnings
eal: avoid shadowed variable aligned_end
eal: avoid shadowed variables in trace code
ethdev: avoid shadowed variable warnings
telemetry: avoid potential name conflict for handler
pcapng: avoid shadow declaration warning
app/test/test_ring.c | 190 +++++++++++++++---------------
app/test/test_table.c | 2 +-
app/test/test_table.h | 2 +-
app/test/test_table_acl.c | 28 ++---
app/test/test_table_pipeline.c | 22 ++--
lib/eal/common/eal_common_trace.c | 42 +++----
lib/eal/common/malloc_heap.c | 6 +-
lib/eal/include/rte_common.h | 17 +++
lib/ethdev/ethdev_driver.c | 2 +-
lib/ethdev/ethdev_driver.h | 6 +-
lib/ethdev/rte_ethdev.c | 1 -
lib/pcapng/rte_pcapng.c | 9 +-
lib/telemetry/rte_telemetry.h | 2 +-
lib/telemetry/telemetry.c | 2 +-
14 files changed, 173 insertions(+), 158 deletions(-)
--
2.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC 1/8] test/ring: avoid shadow variable usage
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
@ 2025-08-27 23:14 ` Stephen Hemminger
2025-08-27 23:14 ` [RFC 2/8] test/table: replace conflicting variable name Stephen Hemminger
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev
Cc: Stephen Hemminger, honnappa.nagarahalli, Konstantin Ananyev,
Gavin Hu, Olivier Matz
The code had a global array "esize" and also local variable
with same name. This would cause warnings if -Wshadow was enabled.
Fix by renaming the array to "esizes".
Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
Cc: honnappa.nagarahalli@arm.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_ring.c | 190 +++++++++++++++++++++----------------------
1 file changed, 95 insertions(+), 95 deletions(-)
diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index ba1fec1de3..dadd8be612 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -66,7 +66,7 @@
#define TEST_RING_FULL_EMPTY_ITER 8
-static const int esize[] = {-1, 4, 8, 16, 20};
+static const int esizes[] = {-1, 4, 8, 16, 20};
/* Wrappers around the zero-copy APIs. The wrappers match
* the normal enqueue/dequeue API declarations.
@@ -514,9 +514,9 @@ test_ring_negative_tests(void)
}
- for (i = 0; i < RTE_DIM(esize); i++) {
+ for (i = 0; i < RTE_DIM(esizes); i++) {
/* Test if ring size is not power of 2 */
- rp = test_ring_create("test_bad_ring_size", esize[i],
+ rp = test_ring_create("test_bad_ring_size", esizes[i],
RING_SIZE + 1, SOCKET_ID_ANY, 0);
if (rp != NULL) {
printf("Test failed to detect odd count\n");
@@ -524,7 +524,7 @@ test_ring_negative_tests(void)
}
/* Test if ring size is exceeding the limit */
- rp = test_ring_create("test_bad_ring_size", esize[i],
+ rp = test_ring_create("test_bad_ring_size", esizes[i],
RTE_RING_SZ_MASK + 1, SOCKET_ID_ANY, 0);
if (rp != NULL) {
printf("Test failed to detect limits\n");
@@ -541,12 +541,12 @@ test_ring_negative_tests(void)
/* Test to if a non-power of 2 count causes the create
* function to fail correctly
*/
- rp = test_ring_create("test_ring_count", esize[i], 4097,
+ rp = test_ring_create("test_ring_count", esizes[i], 4097,
SOCKET_ID_ANY, 0);
if (rp != NULL)
goto test_fail;
- rp = test_ring_create("test_ring_negative", esize[i], RING_SIZE,
+ rp = test_ring_create("test_ring_negative", esizes[i], RING_SIZE,
SOCKET_ID_ANY,
RING_F_SP_ENQ | RING_F_SC_DEQ);
if (rp == NULL) {
@@ -562,7 +562,7 @@ test_ring_negative_tests(void)
/* Tests if it would always fail to create ring with an used
* ring name.
*/
- rt = test_ring_create("test_ring_negative", esize[i], RING_SIZE,
+ rt = test_ring_create("test_ring_negative", esizes[i], RING_SIZE,
SOCKET_ID_ANY, 0);
if (rt != NULL)
goto test_fail;
@@ -593,24 +593,24 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
int rand;
const unsigned int rsz = RING_SIZE - 1;
- for (i = 0; i < RTE_DIM(esize); i++) {
+ for (i = 0; i < RTE_DIM(esizes); i++) {
test_ring_print_test_string(test_enqdeq_impl[test_idx].desc,
- test_enqdeq_impl[test_idx].api_type, esize[i]);
+ test_enqdeq_impl[test_idx].api_type, esizes[i]);
/* Create the ring */
- r = test_ring_create("test_ring_burst_bulk_tests", esize[i],
+ r = test_ring_create("test_ring_burst_bulk_tests", esizes[i],
RING_SIZE, SOCKET_ID_ANY,
test_enqdeq_impl[test_idx].create_flags);
/* alloc dummy object pointers */
- src = test_ring_calloc(RING_SIZE * 2, esize[i]);
+ src = test_ring_calloc(RING_SIZE * 2, esizes[i]);
if (src == NULL)
goto fail;
- test_ring_mem_init(src, RING_SIZE * 2, esize[i]);
+ test_ring_mem_init(src, RING_SIZE * 2, esizes[i]);
cur_src = src;
/* alloc some room for copied objects */
- dst = test_ring_calloc(RING_SIZE * 2, esize[i]);
+ dst = test_ring_calloc(RING_SIZE * 2, esizes[i]);
if (dst == NULL)
goto fail;
cur_dst = dst;
@@ -622,16 +622,16 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
rand = RTE_MAX(rte_rand() % RING_SIZE, 1UL);
printf("%s: iteration %u, random shift: %u;\n",
__func__, i, rand);
- ret = test_ring_enq_impl(r, cur_src, esize[i], rand,
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], rand,
test_idx);
TEST_RING_VERIFY(ret != 0, r, goto fail);
- ret = test_ring_deq_impl(r, cur_dst, esize[i], rand,
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], rand,
test_idx);
TEST_RING_VERIFY(ret == rand, r, goto fail);
/* fill the ring */
- ret = test_ring_enq_impl(r, cur_src, esize[i], rsz,
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], rsz,
test_idx);
TEST_RING_VERIFY(ret != 0, r, goto fail);
@@ -641,7 +641,7 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
TEST_RING_VERIFY(rte_ring_empty(r) == 0, r, goto fail);
/* empty the ring */
- ret = test_ring_deq_impl(r, cur_dst, esize[i], rsz,
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], rsz,
test_idx);
TEST_RING_VERIFY(ret == (int)rsz, r, goto fail);
@@ -652,8 +652,8 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
/* check data */
temp_sz = rsz * sizeof(void *);
- if (esize[i] != -1)
- temp_sz = rsz * esize[i];
+ if (esizes[i] != -1)
+ temp_sz = rsz * esizes[i];
TEST_RING_VERIFY(test_ring_mem_cmp(src, dst,
temp_sz) == 0, r, goto fail);
}
@@ -688,58 +688,58 @@ test_ring_burst_bulk_tests2(unsigned int test_idx)
int ret;
unsigned int i;
- for (i = 0; i < RTE_DIM(esize); i++) {
+ for (i = 0; i < RTE_DIM(esizes); i++) {
test_ring_print_test_string(test_enqdeq_impl[test_idx].desc,
- test_enqdeq_impl[test_idx].api_type, esize[i]);
+ test_enqdeq_impl[test_idx].api_type, esizes[i]);
/* Create the ring */
- r = test_ring_create("test_ring_burst_bulk_tests", esize[i],
+ r = test_ring_create("test_ring_burst_bulk_tests", esizes[i],
RING_SIZE, SOCKET_ID_ANY,
test_enqdeq_impl[test_idx].create_flags);
/* alloc dummy object pointers */
- src = test_ring_calloc(RING_SIZE * 2, esize[i]);
+ src = test_ring_calloc(RING_SIZE * 2, esizes[i]);
if (src == NULL)
goto fail;
- test_ring_mem_init(src, RING_SIZE * 2, esize[i]);
+ test_ring_mem_init(src, RING_SIZE * 2, esizes[i]);
cur_src = src;
/* alloc some room for copied objects */
- dst = test_ring_calloc(RING_SIZE * 2, esize[i]);
+ dst = test_ring_calloc(RING_SIZE * 2, esizes[i]);
if (dst == NULL)
goto fail;
cur_dst = dst;
printf("enqueue 1 obj\n");
- ret = test_ring_enq_impl(r, cur_src, esize[i], 1, test_idx);
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], 1, test_idx);
TEST_RING_VERIFY(ret == 1, r, goto fail);
- cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i], 1);
printf("enqueue 2 objs\n");
- ret = test_ring_enq_impl(r, cur_src, esize[i], 2, test_idx);
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], 2, test_idx);
TEST_RING_VERIFY(ret == 2, r, goto fail);
- cur_src = test_ring_inc_ptr(cur_src, esize[i], 2);
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i], 2);
printf("enqueue MAX_BULK objs\n");
- ret = test_ring_enq_impl(r, cur_src, esize[i], MAX_BULK,
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], MAX_BULK,
test_idx);
TEST_RING_VERIFY(ret == MAX_BULK, r, goto fail);
printf("dequeue 1 obj\n");
- ret = test_ring_deq_impl(r, cur_dst, esize[i], 1, test_idx);
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], 1, test_idx);
TEST_RING_VERIFY(ret == 1, r, goto fail);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 1);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], 1);
printf("dequeue 2 objs\n");
- ret = test_ring_deq_impl(r, cur_dst, esize[i], 2, test_idx);
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], 2, test_idx);
TEST_RING_VERIFY(ret == 2, r, goto fail);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], 2);
printf("dequeue MAX_BULK objs\n");
- ret = test_ring_deq_impl(r, cur_dst, esize[i], MAX_BULK,
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], MAX_BULK,
test_idx);
TEST_RING_VERIFY(ret == MAX_BULK, r, goto fail);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], MAX_BULK);
/* check data */
TEST_RING_VERIFY(test_ring_mem_cmp(src, dst,
@@ -775,40 +775,40 @@ test_ring_burst_bulk_tests3(unsigned int test_idx)
int ret;
unsigned int i, j;
- for (i = 0; i < RTE_DIM(esize); i++) {
+ for (i = 0; i < RTE_DIM(esizes); i++) {
test_ring_print_test_string(test_enqdeq_impl[test_idx].desc,
- test_enqdeq_impl[test_idx].api_type, esize[i]);
+ test_enqdeq_impl[test_idx].api_type, esizes[i]);
/* Create the ring */
- r = test_ring_create("test_ring_burst_bulk_tests", esize[i],
+ r = test_ring_create("test_ring_burst_bulk_tests", esizes[i],
RING_SIZE, SOCKET_ID_ANY,
test_enqdeq_impl[test_idx].create_flags);
/* alloc dummy object pointers */
- src = test_ring_calloc(RING_SIZE * 2, esize[i]);
+ src = test_ring_calloc(RING_SIZE * 2, esizes[i]);
if (src == NULL)
goto fail;
- test_ring_mem_init(src, RING_SIZE * 2, esize[i]);
+ test_ring_mem_init(src, RING_SIZE * 2, esizes[i]);
cur_src = src;
/* alloc some room for copied objects */
- dst = test_ring_calloc(RING_SIZE * 2, esize[i]);
+ dst = test_ring_calloc(RING_SIZE * 2, esizes[i]);
if (dst == NULL)
goto fail;
cur_dst = dst;
printf("fill and empty the ring\n");
for (j = 0; j < RING_SIZE / MAX_BULK; j++) {
- ret = test_ring_enq_impl(r, cur_src, esize[i], MAX_BULK,
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], MAX_BULK,
test_idx);
TEST_RING_VERIFY(ret == MAX_BULK, r, goto fail);
- cur_src = test_ring_inc_ptr(cur_src, esize[i],
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i],
MAX_BULK);
- ret = test_ring_deq_impl(r, cur_dst, esize[i], MAX_BULK,
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], MAX_BULK,
test_idx);
TEST_RING_VERIFY(ret == MAX_BULK, r, goto fail);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i],
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i],
MAX_BULK);
}
@@ -849,41 +849,41 @@ test_ring_burst_bulk_tests4(unsigned int test_idx)
api_type = test_enqdeq_impl[test_idx].api_type;
- for (i = 0; i < RTE_DIM(esize); i++) {
+ for (i = 0; i < RTE_DIM(esizes); i++) {
test_ring_print_test_string(test_enqdeq_impl[test_idx].desc,
- test_enqdeq_impl[test_idx].api_type, esize[i]);
+ test_enqdeq_impl[test_idx].api_type, esizes[i]);
/* Create the ring */
- r = test_ring_create("test_ring_burst_bulk_tests", esize[i],
+ r = test_ring_create("test_ring_burst_bulk_tests", esizes[i],
RING_SIZE, SOCKET_ID_ANY,
test_enqdeq_impl[test_idx].create_flags);
/* alloc dummy object pointers */
- src = test_ring_calloc(RING_SIZE * 2, esize[i]);
+ src = test_ring_calloc(RING_SIZE * 2, esizes[i]);
if (src == NULL)
goto fail;
- test_ring_mem_init(src, RING_SIZE * 2, esize[i]);
+ test_ring_mem_init(src, RING_SIZE * 2, esizes[i]);
cur_src = src;
/* alloc some room for copied objects */
- dst = test_ring_calloc(RING_SIZE * 2, esize[i]);
+ dst = test_ring_calloc(RING_SIZE * 2, esizes[i]);
if (dst == NULL)
goto fail;
cur_dst = dst;
printf("Test enqueue without enough memory space\n");
for (j = 0; j < (RING_SIZE/MAX_BULK - 1); j++) {
- ret = test_ring_enq_impl(r, cur_src, esize[i], MAX_BULK,
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], MAX_BULK,
test_idx);
TEST_RING_VERIFY(ret == MAX_BULK, r, goto fail);
- cur_src = test_ring_inc_ptr(cur_src, esize[i],
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i],
MAX_BULK);
}
printf("Enqueue 2 objects, free entries = MAX_BULK - 2\n");
- ret = test_ring_enq_impl(r, cur_src, esize[i], 2, test_idx);
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], 2, test_idx);
TEST_RING_VERIFY(ret == 2, r, goto fail);
- cur_src = test_ring_inc_ptr(cur_src, esize[i], 2);
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i], 2);
printf("Enqueue the remaining entries = MAX_BULK - 3\n");
/* Bulk APIs enqueue exact number of elements */
@@ -892,42 +892,42 @@ test_ring_burst_bulk_tests4(unsigned int test_idx)
else
num_elems = MAX_BULK;
/* Always one free entry left */
- ret = test_ring_enq_impl(r, cur_src, esize[i], num_elems,
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], num_elems,
test_idx);
TEST_RING_VERIFY(ret == MAX_BULK - 3, r, goto fail);
- cur_src = test_ring_inc_ptr(cur_src, esize[i], MAX_BULK - 3);
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i], MAX_BULK - 3);
printf("Test if ring is full\n");
TEST_RING_VERIFY(rte_ring_full(r) == 1, r, goto fail);
printf("Test enqueue for a full entry\n");
- ret = test_ring_enq_impl(r, cur_src, esize[i], MAX_BULK,
+ ret = test_ring_enq_impl(r, cur_src, esizes[i], MAX_BULK,
test_idx);
TEST_RING_VERIFY(ret == 0, r, goto fail);
printf("Test dequeue without enough objects\n");
for (j = 0; j < RING_SIZE / MAX_BULK - 1; j++) {
- ret = test_ring_deq_impl(r, cur_dst, esize[i], MAX_BULK,
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], MAX_BULK,
test_idx);
TEST_RING_VERIFY(ret == MAX_BULK, r, goto fail);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i],
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i],
MAX_BULK);
}
/* Available memory space for the exact MAX_BULK entries */
- ret = test_ring_deq_impl(r, cur_dst, esize[i], 2, test_idx);
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], 2, test_idx);
TEST_RING_VERIFY(ret == 2, r, goto fail);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], 2);
/* Bulk APIs enqueue exact number of elements */
if ((api_type & TEST_RING_ELEM_BULK) == TEST_RING_ELEM_BULK)
num_elems = MAX_BULK - 3;
else
num_elems = MAX_BULK;
- ret = test_ring_deq_impl(r, cur_dst, esize[i], num_elems,
+ ret = test_ring_deq_impl(r, cur_dst, esizes[i], num_elems,
test_idx);
TEST_RING_VERIFY(ret == MAX_BULK - 3, r, goto fail);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK - 3);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], MAX_BULK - 3);
printf("Test if ring is empty\n");
/* Check if ring is empty */
@@ -966,8 +966,8 @@ test_ring_basic_ex(void)
struct rte_ring *rp = NULL;
void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
- for (i = 0; i < RTE_DIM(esize); i++) {
- rp = test_ring_create("test_ring_basic_ex", esize[i], RING_SIZE,
+ for (i = 0; i < RTE_DIM(esizes); i++) {
+ rp = test_ring_create("test_ring_basic_ex", esizes[i], RING_SIZE,
SOCKET_ID_ANY,
RING_F_SP_ENQ | RING_F_SC_DEQ);
if (rp == NULL) {
@@ -976,16 +976,16 @@ test_ring_basic_ex(void)
}
/* alloc dummy object pointers */
- src = test_ring_calloc(RING_SIZE, esize[i]);
+ src = test_ring_calloc(RING_SIZE, esizes[i]);
if (src == NULL) {
printf("%s: failed to alloc src memory\n", __func__);
goto fail_test;
}
- test_ring_mem_init(src, RING_SIZE, esize[i]);
+ test_ring_mem_init(src, RING_SIZE, esizes[i]);
cur_src = src;
/* alloc some room for copied objects */
- dst = test_ring_calloc(RING_SIZE, esize[i]);
+ dst = test_ring_calloc(RING_SIZE, esizes[i]);
if (dst == NULL) {
printf("%s: failed to alloc dst memory\n", __func__);
goto fail_test;
@@ -1001,19 +1001,19 @@ test_ring_basic_ex(void)
rte_ring_free_count(rp));
for (j = 0; j < RING_SIZE - 1; j++) {
- ret = test_ring_enqueue(rp, cur_src, esize[i], 1,
+ ret = test_ring_enqueue(rp, cur_src, esizes[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
TEST_RING_VERIFY(ret == 0, rp, goto fail_test);
- cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i], 1);
}
TEST_RING_VERIFY(rte_ring_full(rp) == 1, rp, goto fail_test);
for (j = 0; j < RING_SIZE - 1; j++) {
- ret = test_ring_dequeue(rp, cur_dst, esize[i], 1,
+ ret = test_ring_dequeue(rp, cur_dst, esizes[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
TEST_RING_VERIFY(ret == 0, rp, goto fail_test);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 1);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], 1);
}
TEST_RING_VERIFY(rte_ring_empty(rp) == 1, rp, goto fail_test);
@@ -1034,25 +1034,25 @@ test_ring_basic_ex(void)
cur_dst = dst;
/* Covering the ring burst operation */
- ret = test_ring_enqueue(rp, cur_src, esize[i], 2,
+ ret = test_ring_enqueue(rp, cur_src, esizes[i], 2,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);
TEST_RING_VERIFY(ret == 2, rp, goto fail_test);
- cur_src = test_ring_inc_ptr(cur_src, esize[i], 2);
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i], 2);
- ret = test_ring_dequeue(rp, cur_dst, esize[i], 2,
+ ret = test_ring_dequeue(rp, cur_dst, esizes[i], 2,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);
TEST_RING_VERIFY(ret == 2, rp, goto fail_test);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], 2);
/* Covering the ring bulk operation */
- ret = test_ring_enqueue(rp, cur_src, esize[i], 2,
+ ret = test_ring_enqueue(rp, cur_src, esizes[i], 2,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK);
TEST_RING_VERIFY(ret == 2, rp, goto fail_test);
- ret = test_ring_dequeue(rp, cur_dst, esize[i], 2,
+ ret = test_ring_dequeue(rp, cur_dst, esizes[i], 2,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK);
TEST_RING_VERIFY(ret == 2, rp, goto fail_test);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], 2);
/* check data */
TEST_RING_VERIFY(test_ring_mem_cmp(src, dst,
@@ -1089,19 +1089,19 @@ test_ring_with_exact_size(void)
unsigned int i, j;
int ret = -1;
- for (i = 0; i < RTE_DIM(esize); i++) {
+ for (i = 0; i < RTE_DIM(esizes); i++) {
test_ring_print_test_string("Test exact size ring",
TEST_RING_IGNORE_API_TYPE,
- esize[i]);
+ esizes[i]);
- std_r = test_ring_create("std", esize[i], ring_sz,
+ std_r = test_ring_create("std", esizes[i], ring_sz,
rte_socket_id(),
RING_F_SP_ENQ | RING_F_SC_DEQ);
if (std_r == NULL) {
printf("%s: error, can't create std ring\n", __func__);
goto test_fail;
}
- exact_sz_r = test_ring_create("exact sz", esize[i], ring_sz,
+ exact_sz_r = test_ring_create("exact sz", esizes[i], ring_sz,
rte_socket_id(),
RING_F_SP_ENQ | RING_F_SC_DEQ |
RING_F_EXACT_SZ);
@@ -1114,14 +1114,14 @@ test_ring_with_exact_size(void)
/* alloc object pointers. Allocate one extra object
* and create an unaligned address.
*/
- src_orig = test_ring_calloc(17, esize[i]);
+ src_orig = test_ring_calloc(17, esizes[i]);
if (src_orig == NULL)
goto test_fail;
- test_ring_mem_init(src_orig, 17, esize[i]);
+ test_ring_mem_init(src_orig, 17, esizes[i]);
src = (void **)((uintptr_t)src_orig + 1);
cur_src = src;
- dst_orig = test_ring_calloc(17, esize[i]);
+ dst_orig = test_ring_calloc(17, esizes[i]);
if (dst_orig == NULL)
goto test_fail;
dst = (void **)((uintptr_t)dst_orig + 1);
@@ -1140,26 +1140,26 @@ test_ring_with_exact_size(void)
* than the standard ring. (16 vs 15 elements)
*/
for (j = 0; j < ring_sz - 1; j++) {
- ret = test_ring_enqueue(std_r, cur_src, esize[i], 1,
+ ret = test_ring_enqueue(std_r, cur_src, esizes[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
TEST_RING_VERIFY(ret == 0, std_r, goto test_fail);
- ret = test_ring_enqueue(exact_sz_r, cur_src, esize[i], 1,
+ ret = test_ring_enqueue(exact_sz_r, cur_src, esizes[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
TEST_RING_VERIFY(ret == 0, exact_sz_r, goto test_fail);
- cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
+ cur_src = test_ring_inc_ptr(cur_src, esizes[i], 1);
}
- ret = test_ring_enqueue(std_r, cur_src, esize[i], 1,
+ ret = test_ring_enqueue(std_r, cur_src, esizes[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
TEST_RING_VERIFY(ret == -ENOBUFS, std_r, goto test_fail);
- ret = test_ring_enqueue(exact_sz_r, cur_src, esize[i], 1,
+ ret = test_ring_enqueue(exact_sz_r, cur_src, esizes[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
TEST_RING_VERIFY(ret != -ENOBUFS, exact_sz_r, goto test_fail);
/* check that dequeue returns the expected number of elements */
- ret = test_ring_dequeue(exact_sz_r, cur_dst, esize[i], ring_sz,
+ ret = test_ring_dequeue(exact_sz_r, cur_dst, esizes[i], ring_sz,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);
TEST_RING_VERIFY(ret == (int)ring_sz, exact_sz_r, goto test_fail);
- cur_dst = test_ring_inc_ptr(cur_dst, esize[i], ring_sz);
+ cur_dst = test_ring_inc_ptr(cur_dst, esizes[i], ring_sz);
/* check that the capacity function returns expected value */
TEST_RING_VERIFY(rte_ring_get_capacity(exact_sz_r) == ring_sz,
--
2.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC 2/8] test/table: replace conflicting variable name
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
2025-08-27 23:14 ` [RFC 1/8] test/ring: avoid shadow variable usage Stephen Hemminger
@ 2025-08-27 23:14 ` Stephen Hemminger
2025-08-27 23:14 ` [RFC 3/8] eal: add macro to disable shadow warnings Stephen Hemminger
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu
The variable name table_id is used in several places causing
warnings if -Wshadow is enabled. Rename it to table_ids.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_table.c | 2 +-
app/test/test_table.h | 2 +-
app/test/test_table_acl.c | 28 ++++++++++++++--------------
app/test/test_table_pipeline.c | 22 +++++++++++-----------
4 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/app/test/test_table.c b/app/test/test_table.c
index 27d2407517..6da0012944 100644
--- a/app/test/test_table.c
+++ b/app/test/test_table.c
@@ -33,7 +33,7 @@ struct rte_mempool *pool = NULL;
uint32_t port_in_id[N_PORTS];
uint32_t port_out_id[N_PORTS];
uint32_t port_out_id_type[3];
-uint32_t table_id[N_PORTS*2];
+uint32_t table_ids[N_PORTS*2];
uint64_t override_hit_mask = 0xFFFFFFFF;
uint64_t override_miss_mask = 0xFFFFFFFF;
uint64_t non_reserved_actions_hit = 0;
diff --git a/app/test/test_table.h b/app/test/test_table.h
index 209bdbff2c..b8fdd98281 100644
--- a/app/test/test_table.h
+++ b/app/test/test_table.h
@@ -120,7 +120,7 @@ extern struct rte_mempool *pool;
extern uint32_t port_in_id[N_PORTS];
extern uint32_t port_out_id[N_PORTS];
extern uint32_t port_out_id_type[3];
-extern uint32_t table_id[N_PORTS*2];
+extern uint32_t table_ids[N_PORTS*2];
extern uint64_t override_hit_mask;
extern uint64_t override_miss_mask;
extern uint64_t non_reserved_actions_hit;
diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index dff9bddfb9..4076c513fb 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -427,14 +427,14 @@ setup_acl_pipeline(void)
table_params.ops = &rte_table_acl_ops;
table_params.arg_create = &acl_params;
- if (rte_pipeline_table_create(p, &table_params, &table_id[i])) {
+ if (rte_pipeline_table_create(p, &table_params, &table_ids[i])) {
rte_panic("Unable to configure table %u\n", i);
goto fail;
}
if (connect_miss_action_to_table) {
if (rte_pipeline_table_create(p, &table_params,
- &table_id[i+2])) {
+ &table_ids[i+2])) {
rte_panic("Unable to configure table %u\n", i);
goto fail;
}
@@ -443,10 +443,10 @@ setup_acl_pipeline(void)
for (i = 0; i < N_PORTS; i++) {
if (rte_pipeline_port_in_connect_to_table(p, port_in_id[i],
- table_id[i])) {
+ table_ids[i])) {
rte_panic("Unable to connect input port %u to "
"table %u\n",
- port_in_id[i], table_id[i]);
+ port_in_id[i], table_ids[i]);
goto fail;
}
}
@@ -485,11 +485,11 @@ setup_acl_pipeline(void)
table_entries_ptr[n] = &entries_ptr[n];
}
- ret = rte_pipeline_table_entry_add_bulk(p, table_id[i],
+ ret = rte_pipeline_table_entry_add_bulk(p, table_ids[i],
(void **)key_array, table_entries, 5, key_found, table_entries_ptr);
if (ret < 0) {
rte_panic("Add entry bulk to table %u failed (%d)\n",
- table_id[i], ret);
+ table_ids[i], ret);
goto fail;
}
}
@@ -519,11 +519,11 @@ setup_acl_pipeline(void)
}
}
- ret = rte_pipeline_table_entry_delete_bulk(p, table_id[i],
+ ret = rte_pipeline_table_entry_delete_bulk(p, table_ids[i],
(void **)key_array, 5, key_found, table_entries);
if (ret < 0) {
rte_panic("Delete bulk entries from table %u failed (%d)\n",
- table_id[i], ret);
+ table_ids[i], ret);
goto fail;
} else
printf("Bulk deleted rules.\n");
@@ -555,12 +555,12 @@ setup_acl_pipeline(void)
rule_params.priority = RTE_ACL_MAX_PRIORITY - n;
- ret = rte_pipeline_table_entry_add(p, table_id[i],
+ ret = rte_pipeline_table_entry_add(p, table_ids[i],
&rule_params,
&table_entry, &key_found, &entry_ptr);
if (ret < 0) {
rte_panic("Add entry to table %u failed (%d)\n",
- table_id[i], ret);
+ table_ids[i], ret);
goto fail;
}
}
@@ -581,11 +581,11 @@ setup_acl_pipeline(void)
delete_params = (struct
rte_pipeline_table_acl_rule_delete_params *)
&(rule_params.field_value[0]);
- ret = rte_pipeline_table_entry_delete(p, table_id[i],
+ ret = rte_pipeline_table_entry_delete(p, table_ids[i],
delete_params, &key_found, NULL);
if (ret < 0) {
rte_panic("Add entry to table %u failed (%d)\n",
- table_id[i], ret);
+ table_ids[i], ret);
goto fail;
} else
printf("Deleted Rule.\n");
@@ -607,12 +607,12 @@ setup_acl_pipeline(void)
rule_params.priority = RTE_ACL_MAX_PRIORITY - n;
- ret = rte_pipeline_table_entry_add(p, table_id[i],
+ ret = rte_pipeline_table_entry_add(p, table_ids[i],
&rule_params,
&table_entry, &key_found, &entry_ptr);
if (ret < 0) {
rte_panic("Add entry to table %u failed (%d)\n",
- table_id[i], ret);
+ table_ids[i], ret);
goto fail;
}
}
diff --git a/app/test/test_table_pipeline.c b/app/test/test_table_pipeline.c
index 960f730cf2..318ef1ac6c 100644
--- a/app/test/test_table_pipeline.c
+++ b/app/test/test_table_pipeline.c
@@ -311,14 +311,14 @@ setup_pipeline(int test_type)
.action_data_size = 0,
};
- if (rte_pipeline_table_create(p, &table_params, &table_id[i])) {
+ if (rte_pipeline_table_create(p, &table_params, &table_ids[i])) {
rte_panic("Unable to configure table %u\n", i);
goto fail;
}
if (connect_miss_action_to_table)
if (rte_pipeline_table_create(p, &table_params,
- &table_id[i+2])) {
+ &table_ids[i+2])) {
rte_panic("Unable to configure table %u\n", i);
goto fail;
}
@@ -326,9 +326,9 @@ setup_pipeline(int test_type)
for (i = 0; i < N_PORTS; i++)
if (rte_pipeline_port_in_connect_to_table(p, port_in_id[i],
- table_id[i])) {
+ table_ids[i])) {
rte_panic("Unable to connect input port %u to "
- "table %u\n", port_in_id[i], table_id[i]);
+ "table %u\n", port_in_id[i], table_ids[i]);
goto fail;
}
@@ -344,20 +344,20 @@ setup_pipeline(int test_type)
if (connect_miss_action_to_table) {
printf("Setting first table to output to next table\n");
default_entry.action = RTE_PIPELINE_ACTION_TABLE;
- default_entry.table_id = table_id[i+2];
+ default_entry.table_id = table_ids[i+2];
}
/* Add the default action for the table. */
- ret = rte_pipeline_table_default_entry_add(p, table_id[i],
+ ret = rte_pipeline_table_default_entry_add(p, table_ids[i],
&default_entry, &default_entry_ptr);
if (ret < 0) {
rte_panic("Unable to add default entry to table %u "
- "code %d\n", table_id[i], ret);
+ "code %d\n", table_ids[i], ret);
goto fail;
} else
printf("Added default entry to table id %d with "
"action %x\n",
- table_id[i], default_entry.action);
+ table_ids[i], default_entry.action);
if (connect_miss_action_to_table) {
/* We create a second table so the first can pass
@@ -370,17 +370,17 @@ setup_pipeline(int test_type)
/* Add the default action for the table. */
ret = rte_pipeline_table_default_entry_add(p,
- table_id[i+2],
+ table_ids[i+2],
&default_entry, &default_entry_ptr);
if (ret < 0) {
rte_panic("Unable to add default entry to "
"table %u code %d\n",
- table_id[i], ret);
+ table_ids[i], ret);
goto fail;
} else
printf("Added default entry to table id %d "
"with action %x\n",
- table_id[i], default_entry.action);
+ table_ids[i], default_entry.action);
}
}
--
2.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC 3/8] eal: add macro to disable shadow warnings
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
2025-08-27 23:14 ` [RFC 1/8] test/ring: avoid shadow variable usage Stephen Hemminger
2025-08-27 23:14 ` [RFC 2/8] test/table: replace conflicting variable name Stephen Hemminger
@ 2025-08-27 23:14 ` Stephen Hemminger
2025-08-27 23:14 ` [RFC 4/8] eal: avoid shadowed variable aligned_end Stephen Hemminger
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff
When using constructs like:
RTE_MIN(x, RTE_MIN(y, z))
the compiler would generate warnings about overlapping definitions
of the variables in the macro. This is safe so add pragma support
to silence the problem.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/eal/include/rte_common.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 9e7d84f929..34862cc97a 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -210,6 +210,15 @@ typedef uint16_t unaligned_uint16_t;
#define __rte_diagnostic_ignored_wcast_qual
#endif
+/**
+ * Macro to disable compiler warnings about shadow declaration.
+ */
+#if !defined(RTE_TOOLCHAIN_MSVC)
+#define __rte_diagnostic_ignored_shadow _Pragma("GCC diagnostic ignored \"-Wshadow\"")
+#else
+#define __rte_diagnostic_ignored_shadow
+#endif
+
/**
* Mark a function or variable to a weak reference.
*/
@@ -791,12 +800,17 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
/**
* Macro to return the minimum of two numbers
+ * Need to disable warnings about shadowed variables to allow
+ * for nested usage.
*/
#define RTE_MIN(a, b) \
__extension__ ({ \
+ __rte_diagnostic_push \
+ __rte_diagnostic_ignored_shadow \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a < _b ? _a : _b; \
+ __rte_diagnostic_pop \
})
/**
@@ -814,9 +828,12 @@ __extension__ typedef uint64_t RTE_MARKER64[0];
*/
#define RTE_MAX(a, b) \
__extension__ ({ \
+ __rte_diagnostic_push \
+ __rte_diagnostic_ignored_shadow \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; \
+ __rte_diagnostic_pop \
})
/**
--
2.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC 4/8] eal: avoid shadowed variable aligned_end
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
` (2 preceding siblings ...)
2025-08-27 23:14 ` [RFC 3/8] eal: add macro to disable shadow warnings Stephen Hemminger
@ 2025-08-27 23:14 ` Stephen Hemminger
2025-08-27 23:14 ` [RFC 5/8] eal: avoid shadowed variables in trace code Stephen Hemminger
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Anatoly Burakov, Tyler Retzlaff
Fix instance where variable was being shadowed by
using a new name.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/eal/common/malloc_heap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index 13a56e490e..602266fba0 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -1044,7 +1044,7 @@ 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 *asan_aligned = RTE_PTR_ADD(aligned_start, aligned_len);
void *aligned_trailer = RTE_PTR_SUB(aligned_start,
MALLOC_ELEM_TRAILER_LEN);
@@ -1064,8 +1064,8 @@ malloc_heap_free(struct malloc_elem *elem)
* unmapped space that was marked as freezone for ASan, we need
* to mark the malloc header as available.
*/
- if (asan_end > aligned_end)
- asan_set_zone(aligned_end, MALLOC_ELEM_HEADER_LEN, 0x00);
+ if (asan_end > asan_aligned)
+ asan_set_zone(asan_aligned, MALLOC_ELEM_HEADER_LEN, 0x00);
/* if there's space before unmapped memory, mark as available */
if (asan_ptr < aligned_start)
--
2.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC 5/8] eal: avoid shadowed variables in trace code
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
` (3 preceding siblings ...)
2025-08-27 23:14 ` [RFC 4/8] eal: avoid shadowed variable aligned_end Stephen Hemminger
@ 2025-08-27 23:14 ` Stephen Hemminger
2025-08-27 23:14 ` [RFC 6/8] ethdev: avoid shadowed variable warnings Stephen Hemminger
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jerin Jacob, Sunil Kumar Kori, Tyler Retzlaff
The trace code had a global variable and local variable with
same name. Rename the globals to get rid of warning.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/eal/common/eal_common_trace.c | 42 +++++++++++++++----------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index be1f78a68d..d3cacfb47c 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -24,12 +24,12 @@ RTE_DEFINE_PER_LCORE(void *, trace_mem);
static RTE_DEFINE_PER_LCORE(char *, ctf_field);
static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
-static struct trace trace = { .args = STAILQ_HEAD_INITIALIZER(trace.args), };
+static struct trace tr_obj = { .args = STAILQ_HEAD_INITIALIZER(tr_obj.args), };
struct trace *
trace_obj_get(void)
{
- return &trace;
+ return &tr_obj;
}
struct trace_point_head *
@@ -47,12 +47,12 @@ eal_trace_init(void)
RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
/* One of the trace point registration failed */
- if (trace.register_errno) {
- rte_errno = trace.register_errno;
+ if (tr_obj.register_errno) {
+ rte_errno = tr_obj.register_errno;
goto fail;
}
- rte_spinlock_init(&trace.lock);
+ rte_spinlock_init(&tr_obj.lock);
/* Is duplicate trace name registered */
if (trace_has_duplicate_entry())
@@ -75,10 +75,10 @@ eal_trace_init(void)
goto free_meta;
/* Apply global configurations */
- STAILQ_FOREACH(arg, &trace.args, next)
+ STAILQ_FOREACH(arg, &tr_obj.args, next)
trace_args_apply(arg->val);
- rte_trace_mode_set(trace.mode);
+ rte_trace_mode_set(tr_obj.mode);
return 0;
@@ -101,7 +101,7 @@ RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_trace_is_enabled, 20.05)
bool
rte_trace_is_enabled(void)
{
- return rte_atomic_load_explicit(&trace.status, rte_memory_order_acquire) != 0;
+ return rte_atomic_load_explicit(&tr_obj.status, rte_memory_order_acquire) != 0;
}
static void
@@ -124,20 +124,20 @@ rte_trace_mode_set(enum rte_trace_mode mode)
STAILQ_FOREACH(tp, &tp_list, next)
trace_mode_set(tp->handle, mode);
- trace.mode = mode;
+ tr_obj.mode = mode;
}
RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_trace_mode_get, 20.05)
enum
rte_trace_mode rte_trace_mode_get(void)
{
- return trace.mode;
+ return tr_obj.mode;
}
static bool
trace_point_is_invalid(rte_trace_point_t *t)
{
- return (t == NULL) || (trace_id_get(t) >= trace.nb_trace_points);
+ return (t == NULL) || (trace_id_get(t) >= tr_obj.nb_trace_points);
}
RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_trace_point_is_enabled, 20.05)
@@ -165,7 +165,7 @@ rte_trace_point_enable(rte_trace_point_t *t)
prev = rte_atomic_fetch_or_explicit(t, __RTE_TRACE_FIELD_ENABLE_MASK,
rte_memory_order_release);
if ((prev & __RTE_TRACE_FIELD_ENABLE_MASK) == 0)
- rte_atomic_fetch_add_explicit(&trace.status, 1, rte_memory_order_release);
+ rte_atomic_fetch_add_explicit(&tr_obj.status, 1, rte_memory_order_release);
return 0;
}
@@ -181,7 +181,7 @@ rte_trace_point_disable(rte_trace_point_t *t)
prev = rte_atomic_fetch_and_explicit(t, ~__RTE_TRACE_FIELD_ENABLE_MASK,
rte_memory_order_release);
if ((prev & __RTE_TRACE_FIELD_ENABLE_MASK) != 0)
- rte_atomic_fetch_sub_explicit(&trace.status, 1, rte_memory_order_release);
+ rte_atomic_fetch_sub_explicit(&tr_obj.status, 1, rte_memory_order_release);
return 0;
}
@@ -295,7 +295,7 @@ 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_point_head *tp_head = trace_list_head_get();
struct trace *trace = trace_obj_get();
struct trace_point *tp;
@@ -310,7 +310,7 @@ rte_trace_dump(FILE *f)
trace_lcore_mem_dump(f);
fprintf(f, "\nTrace point info\n----------------\n");
- STAILQ_FOREACH(tp, tp_list, next)
+ STAILQ_FOREACH(tp, tp_head, next)
trace_point_dump(f, tp);
}
@@ -508,7 +508,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,
}
/* Are we running out of space to store trace points? */
- if (trace.nb_trace_points > UINT16_MAX) {
+ if (tr_obj.nb_trace_points > UINT16_MAX) {
trace_err("trace point exceeds the max count");
rte_errno = ENOSPC;
goto fail;
@@ -534,10 +534,10 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,
/* Form the trace handle */
*handle = sz;
- *handle |= trace.nb_trace_points << __RTE_TRACE_FIELD_ID_SHIFT;
- trace_mode_set(handle, trace.mode);
+ *handle |= tr_obj.nb_trace_points << __RTE_TRACE_FIELD_ID_SHIFT;
+ trace_mode_set(handle, tr_obj.mode);
- trace.nb_trace_points++;
+ tr_obj.nb_trace_points++;
tp->handle = handle;
/* Add the trace point at tail */
@@ -548,8 +548,8 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,
return 0;
fail:
- if (trace.register_errno == 0)
- trace.register_errno = rte_errno;
+ if (tr_obj.register_errno == 0)
+ tr_obj.register_errno = rte_errno;
return -rte_errno;
}
--
2.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC 6/8] ethdev: avoid shadowed variable warnings
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
` (4 preceding siblings ...)
2025-08-27 23:14 ` [RFC 5/8] eal: avoid shadowed variables in trace code Stephen Hemminger
@ 2025-08-27 23:14 ` Stephen Hemminger
2025-08-27 23:14 ` [RFC 7/8] telemetry: avoid potential name conflict for handler Stephen Hemminger
2025-08-27 23:14 ` [RFC 8/8] pcapng: avoid shadow declaration warning Stephen Hemminger
7 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Thomas Monjalon, Andrew Rybchenko
With shadow warnings enabled there were a couple of cases
to fix. One was simple reuse of 'ret', other was overlap
between type and variable name.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/ethdev/ethdev_driver.c | 2 +-
lib/ethdev/ethdev_driver.h | 6 +++---
lib/ethdev/rte_ethdev.c | 1 -
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c
index ec0c1e1176..11ffaa2219 100644
--- a/lib/ethdev/ethdev_driver.c
+++ b/lib/ethdev/ethdev_driver.c
@@ -295,7 +295,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_t ethdev_bus_specific_init,
void *bus_init_params,
ethdev_init_t ethdev_init, void *init_params)
{
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index 2b4d2ae9c3..4c2f2e3489 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1998,8 +1998,8 @@ rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs,
typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
-typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
- void *bus_specific_init_params);
+typedef int (*ethdev_bus_specific_init_t)(struct rte_eth_dev *ethdev,
+ void *bus_specific_init_params);
/**
* PMD helper function for the creation of a new ethdev ports.
@@ -2026,7 +2026,7 @@ __rte_internal
int
rte_eth_dev_create(struct rte_device *device, const char *name,
size_t priv_data_size,
- ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
+ ethdev_bus_specific_init_t bus_specific_init, void *bus_init_params,
ethdev_init_t ethdev_init, void *init_params);
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index dd7c00bc94..9934e48415 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -2468,7 +2468,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.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC 7/8] telemetry: avoid potential name conflict for handler
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
` (5 preceding siblings ...)
2025-08-27 23:14 ` [RFC 6/8] ethdev: avoid shadowed variable warnings Stephen Hemminger
@ 2025-08-27 23:14 ` Stephen Hemminger
2025-08-27 23:14 ` [RFC 8/8] pcapng: avoid shadow declaration warning Stephen Hemminger
7 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Bruce Richardson
The typedef for handler creates shadow declaration warnings
in other drivers with variables of that name. Add telemetry_
prefix like other variables in the library.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/telemetry/rte_telemetry.h | 2 +-
lib/telemetry/telemetry.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index c4554e4028..4202847cd7 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -369,7 +369,7 @@ typedef int (*telemetry_arg_cb)(const char *cmd, const char *params, void *arg,
* @return
* Void.
*/
-typedef void * (*handler)(void *sock_id);
+typedef void * (*telemetry_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..7b8fee0e0e 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_handler fn;
RTE_ATOMIC(uint16_t) *num_clients;
};
static struct socket v2_socket; /* socket for v2 telemetry */
--
2.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC 8/8] pcapng: avoid shadow declaration warning
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
` (6 preceding siblings ...)
2025-08-27 23:14 ` [RFC 7/8] telemetry: avoid potential name conflict for handler Stephen Hemminger
@ 2025-08-27 23:14 ` Stephen Hemminger
7 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2025-08-27 23:14 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Reshma Pattan
The BPF filter insert logic had shadowed declaration of len.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/pcapng/rte_pcapng.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 2a07b4c1f5..a46f4bf0bf 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,
opt = pcapng_add_option(opt, PCAPNG_IFB_HARDWARE,
ifhw, strlen(ifhw));
if (filter) {
- size_t len;
+ 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));
+ memcpy(opt->data + 1, filter, filter_len - 1);
- 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.47.2
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-08-27 23:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-27 23:14 [RFC 0/8] Avoid overlapping declarations Stephen Hemminger
2025-08-27 23:14 ` [RFC 1/8] test/ring: avoid shadow variable usage Stephen Hemminger
2025-08-27 23:14 ` [RFC 2/8] test/table: replace conflicting variable name Stephen Hemminger
2025-08-27 23:14 ` [RFC 3/8] eal: add macro to disable shadow warnings Stephen Hemminger
2025-08-27 23:14 ` [RFC 4/8] eal: avoid shadowed variable aligned_end Stephen Hemminger
2025-08-27 23:14 ` [RFC 5/8] eal: avoid shadowed variables in trace code Stephen Hemminger
2025-08-27 23:14 ` [RFC 6/8] ethdev: avoid shadowed variable warnings Stephen Hemminger
2025-08-27 23:14 ` [RFC 7/8] telemetry: avoid potential name conflict for handler Stephen Hemminger
2025-08-27 23:14 ` [RFC 8/8] pcapng: avoid shadow declaration warning Stephen Hemminger
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).