bus/fslmc: fix shadowed variables in queue storage macros
PATCH 1/1 bus/fslmc: fix shadowed variables in queue storage macros
The queue storage allocation and free macros declare local variables named ret and i, which shadow local variables in rte_dpaa2_create_dpci_device() and trigger -Wshadow warnings.
Rename the macro-local variables to avoid shadowing without changing behavior.
Bugzilla ID: 1744
--- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +14 -14
@@ -204,33 +204,33 @@ struct swp_active_dqs {#define dpaa2_queue_storage_alloc (q, num) \ ({ \ - int ret = 0, i; \ + int qs_ret = 0, qs_idx; \ \ - for (i = 0; i < (num); i++) { \ - (q)->q_storage[i] = rte_zmalloc(NULL, \ + for (qs_idx = 0; qs_idx < (num); qs_idx++) { \ + (q)->q_storage[qs_idx] = rte_zmalloc(NULL, \ sizeof(struct queue_storage_info_t), \ RTE_CACHE_LINE_SIZE); \ - if (!(q)->q_storage[i]) { \ - ret = -ENOBUFS; \ + if (!(q)->q_storage[qs_idx]) { \ + qs_ret = -ENOBUFS; \ break; \ } \ - ret = dpaa2_alloc_dq_storage((q)->q_storage[i]); \ - if (ret) \ + qs_ret = dpaa2_alloc_dq_storage((q)->q_storage[qs_idx]); \ + if (qs_ret) \ break; \ } \ - ret; \ + qs_ret; \ })#define dpaa2_queue_storage_free (q, num) \ ({ \ if (q) { \ - int i; \ + int qs_idx; \ \ - for (i = 0; i < (num); i++) { \ - if ((q)->q_storage[i]) { \ - dpaa2_free_dq_storage((q)->q_storage[i]); \ - rte_free((q)->q_storage[i]); \ - (q)->q_storage[i] = NULL; \ + for (qs_idx = 0; qs_idx < (num); qs_idx++) { \ + if ((q)->q_storage[qs_idx]) { \ + dpaa2_free_dq_storage((q)->q_storage[qs_idx]); \ + rte_free((q)->q_storage[qs_idx]); \ + (q)->q_storage[qs_idx] = NULL; \ } \ } \ } \
Signature · 1 line
2.34.1
Quoted 42 lines · On Sat, 4 Apr 2026 12:19:11 -0500 Weijun Pan <[email protected]> wrote:
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +9
-12@@ -204,33 +204,33 @@ struct swp_active_dqs {#define dpaa2_queue_storage_alloc (q, num) \ ({ \ - int ret = 0, i; \ + int qs_ret = 0, qs_idx; \ \ - for (i = 0; i < (num); i++) { \ - (q)->q_storage[i] = rte_zmalloc(NULL, \ + for (qs_idx = 0; qs_idx < (num); qs_idx++) { \ + (q)->q_storage[qs_idx] = rte_zmalloc(NULL, \ sizeof(struct queue_storage_info_t), \ RTE_CACHE_LINE_SIZE); \ - if (!(q)->q_storage[i]) { \ - ret = -ENOBUFS; \ + if (!(q)->q_storage[qs_idx]) { \ + qs_ret = -ENOBUFS; \ break; \ } \ - ret = dpaa2_alloc_dq_storage((q)->q_storage[i]); \ - if (ret) \ + qs_ret = dpaa2_alloc_dq_storage((q)->q_storage[qs_idx]); \ + if (qs_ret) \ break; \ } \ - ret; \ + qs_ret; \ })#define dpaa2_queue_storage_free (q, num) \ ({ \ if (q) { \ - int i; \ + int qs_idx; \ \ - for (i = 0; i < (num); i++) { \ - if ((q)->q_storage[i]) { \ - dpaa2_free_dq_storage((q)->q_storage[i]); \
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h struct swp_active_dqs { · line 236
Quoted 10 lines
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +5
-2-rte_free ((q)->q_storage[i]); \ - (q)->q_storage[i] =NULL ; \ +for (qs_idx =0 ; qs_idx < (num); qs_idx++) { \ +if ((q)->q_storage[qs_idx]) { \ +dpaa2_free_dq_storage ((q)->q_storage[qs_idx]); \ +rte_free ((q)->q_storage[qs_idx]); \ + (q)->q_storage[qs_idx] =NULL ; \ } \ } \ } \
Why are these not inline functions.
Macros with lower case names are likely place fore confusion like this?
07/04/2026 16:09, Stephen Hemminger:
Quoted 2 lines
Why are these not inline functions.
Macros with lower case names are likely place fore confusion like this?
Hemant, Sachin, Weijun, please could you consider this comment?
Quoted 6 lines · Thomas Monjalon
07/04/2026 16:09, Stephen Hemminger:
Quoted 2 lines
Why are these not inline functions.
Macros with lower case names are likely place fore confusion like this?Hemant, Sachin, Weijun, please could you consider this comment?
Besides, I understand the intention behind bz 1744 is to re-enable Wshadow. But after applying this fix, I still see many warnings after re-enabling:
$ git diff
drivers/bus/fslmc/meson.build +0 -2
@@ -6,8 +6,6 @@ if not is_linux reason = 'only supported on Linux' endif -cflags += no_shadow_cflag - deps += ['common_dpaax', 'eventdev', 'kvargs'] sources = files( 'fslmc_bus.c',
$ ./devtools/test-meson-builds.sh
...
../../../git/pub/dpdk.org/main/drivers/bus/fslmc/qbman/qbman_portal.c:
In function ‘qbman_swp_enqueue_multiple_cinh_read_direct’:
../../../git/pub/dpdk.org/main/drivers/bus/fslmc/qbman/qbman_portal.c:1092:47:
error: declaration of ‘d’ shadows a parameter [-Werror=shadow]
1092 | struct qbman_eq_desc *d = (struct
qbman_eq_desc *)p;
| ^
../../../git/pub/dpdk.org/main/drivers/bus/fslmc/qbman/qbman_portal.c:1047:45:
note: shadowed declaration is here
1047 | const struct qbman_eq_desc *d,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
../../../git/pub/dpdk.org/main/drivers/bus/fslmc/qbman/qbman_portal.c:
In function ‘qbman_swp_enqueue_multiple_cinh_direct’:
../../../git/pub/dpdk.org/main/drivers/bus/fslmc/qbman/qbman_portal.c:1161:47:
error: declaration of ‘d’ shadows a parameter [-Werror=shadow]
1161 | struct qbman_eq_desc *d = (struct
qbman_eq_desc *)p;
| ^Signature · 1 line
David Marchand
Thanks for the feedback.
I will prepare a v2 for this patch. For the queue storage helpers, I will replace the macros with static inline functions, based on Stephen's suggestion. Thanks,
Weijun
________________________________
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, June 10, 2026 9:15 AM
To: Weijun Pan <[email protected]>; Hemant Agrawal <[email protected]>; Weijun Pan <[email protected]>
Cc: [email protected] <[email protected]>; Sachin Saxena <[email protected]>; Jun Yang <[email protected]>; [email protected] <[email protected]>; Stephen Hemminger <[email protected]>
Subject: Re: [PATCH] bus/fslmc: fix shadowed variables in queue storage macros
07/04/2026 16:09, Stephen Hemminger:
Quoted 2 lines
Why are these not inline functions.
Macros with lower case names are likely place fore confusion like this?
Hemant, Sachin, Weijun, please could you consider this comment?