patch 'eal: fix variable shadowing' has been queued to stable release 24.11.5
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Fri Feb 20 15:55:07 CET 2026
Hi,
FYI, your patch has been queued to stable release 24.11.5
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/22/26. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable
This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/3e835a35215852d610f3197cf71a6f3d8c0c7d3a
Thanks.
Luca Boccassi
---
>From 3e835a35215852d610f3197cf71a6f3d8c0c7d3a Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson at intel.com>
Date: Wed, 14 Jan 2026 15:44:16 +0000
Subject: [PATCH] eal: fix variable shadowing
[ upstream commit 68c2dde1d441cda8e5656e46b018f7a39e47a669 ]
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")
Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
Acked-by: Chengwen Feng <fengchengwen at huawei.com>
Acked-by: Stephen Hemminger <stephen at networkplumber.org>
---
lib/eal/common/eal_common_options.c | 22 +++----
lib/eal/common/eal_common_trace.c | 90 ++++++++++++++---------------
lib/eal/common/malloc_heap.c | 2 +-
3 files changed, 56 insertions(+), 58 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 6f1a9ffc56..bf4ff858c9 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -188,21 +188,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;
}
@@ -267,21 +267,21 @@ error:
#endif
static int
-eal_option_device_add(enum rte_devtype type, const char *optarg)
+eal_option_device_add(enum rte_devtype type, const char *arg)
{
struct device_option *devopt;
- size_t optlen;
+ size_t arglen;
int ret;
- optlen = strlen(optarg) + 1;
- devopt = calloc(1, sizeof(*devopt) + optlen);
+ arglen = strlen(arg) + 1;
+ devopt = calloc(1, sizeof(*devopt) + arglen);
if (devopt == NULL) {
EAL_LOG(ERR, "Unable to allocate device option");
return -ENOMEM;
}
devopt->type = type;
- ret = strlcpy(devopt->arg, optarg, optlen);
+ ret = strlcpy(devopt->arg, arg, arglen);
if (ret < 0) {
EAL_LOG(ERR, "Unable to copy device option");
free(devopt);
diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index 918f49bf4f..30db654e49 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -258,32 +258,31 @@ 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);
}
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");
@@ -291,13 +290,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);
}
@@ -317,7 +316,7 @@ thread_get_name(rte_thread_t id, char *name, size_t len)
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;
@@ -327,30 +326,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 */
- header = malloc(trace_mem_sz(trace->buff_len));
+ header = malloc(trace_mem_sz(t->buff_len));
if (header == NULL) {
trace_crit("trace mem malloc attempt failed");
header = NULL;
@@ -359,14 +358,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 */
@@ -375,11 +374,11 @@ found:
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
@@ -394,7 +393,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;
@@ -402,37 +401,36 @@ 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]);
- }
- trace->nb_trace_mem_list = 0;
- rte_spinlock_unlock(&trace->lock);
+ 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]);
+ t->nb_trace_mem_list = 0;
+ rte_spinlock_unlock(&t->lock);
}
void
diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index 058aaf4209..34cf92a2ef 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -1043,9 +1043,9 @@ free_unlock:
/* 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.47.3
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-02-20 14:55:43.576906103 +0000
+++ 0005-eal-fix-variable-shadowing.patch 2026-02-20 14:55:43.152190193 +0000
@@ -1 +1 @@
-From 68c2dde1d441cda8e5656e46b018f7a39e47a669 Mon Sep 17 00:00:00 2001
+From 3e835a35215852d610f3197cf71a6f3d8c0c7d3a Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 68c2dde1d441cda8e5656e46b018f7a39e47a669 ]
+
@@ -22 +23,0 @@
-Cc: stable at dpdk.org
@@ -34 +35 @@
-index 9ac2509c7c..485655865d 100644
+index 6f1a9ffc56..bf4ff858c9 100644
@@ -37 +38 @@
-@@ -340,21 +340,21 @@ int
+@@ -188,21 +188,21 @@ int
@@ -65,2 +66,2 @@
-@@ -430,21 +430,21 @@ eal_clean_saved_args(void)
- #endif /* !RTE_EXEC_ENV_WINDOWS */
+@@ -267,21 +267,21 @@ error:
+ #endif
@@ -93 +94 @@
-index be041c45bb..a76dff0017 100644
+index 918f49bf4f..30db654e49 100644
@@ -96 +97 @@
-@@ -270,33 +270,32 @@ trace_point_dump(FILE *f, struct trace_point *tp)
+@@ -258,32 +258,31 @@ trace_point_dump(FILE *f, struct trace_point *tp)
@@ -129 +129,0 @@
- RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_trace_dump, 20.05)
@@ -139 +139 @@
-@@ -304,13 +303,13 @@ rte_trace_dump(FILE *f)
+@@ -291,13 +290,13 @@ rte_trace_dump(FILE *f)
@@ -157 +157 @@
-@@ -331,7 +330,7 @@ RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_trace_mem_per_thread_alloc, 20.05)
+@@ -317,7 +316,7 @@ thread_get_name(rte_thread_t id, char *name, size_t len)
@@ -166 +166 @@
-@@ -341,30 +340,30 @@ __rte_trace_mem_per_thread_alloc(void)
+@@ -327,30 +326,30 @@ __rte_trace_mem_per_thread_alloc(void)
@@ -199,7 +199,7 @@
- /* 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 */
+- header = malloc(trace_mem_sz(trace->buff_len));
++ header = malloc(trace_mem_sz(t->buff_len));
+ if (header == NULL) {
+ trace_crit("trace mem malloc attempt failed");
+ header = NULL;
+@@ -359,14 +358,14 @@ __rte_trace_mem_per_thread_alloc(void)
@@ -223 +223 @@
-@@ -392,11 +391,11 @@ found:
+@@ -375,11 +374,11 @@ found:
@@ -238 +238 @@
-@@ -411,7 +410,7 @@ trace_mem_per_thread_free_unlocked(struct thread_mem_meta *meta)
+@@ -394,7 +393,7 @@ trace_mem_per_thread_free_unlocked(struct thread_mem_meta *meta)
@@ -247 +247 @@
-@@ -419,37 +418,36 @@ trace_mem_per_thread_free(void)
+@@ -402,37 +401,36 @@ trace_mem_per_thread_free(void)
@@ -299 +299 @@
- RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_trace_point_emit_field, 20.05)
+ void
@@ -301 +301 @@
-index 13a56e490e..39240c261c 100644
+index 058aaf4209..34cf92a2ef 100644
@@ -304 +304 @@
-@@ -1044,9 +1044,9 @@ free_unlock:
+@@ -1043,9 +1043,9 @@ free_unlock:
More information about the stable
mailing list