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
PATCH 1/1 raw/ifpga: replace printf calls with logging
The ifpga rawdev driver uses printf() directly for runtime messages. DPDK drivers should use the logging framework instead of printing to standard output.
Replace the remaining direct printf() calls in ifpga_rawdev.c with the driver logging macros.
--- drivers/raw/ifpga/ifpga_rawdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/raw/ifpga/ifpga_rawdev.c +3 -3
@@ -434,7 +434,7 @@ static int set_surprise_link_check_aer(uint32_t aer_new0, aer_new1;if (!ifpga_rdev || !ifpga_rdev->rawdev) { -printf ("\n device does not exist\n" ); +IFPGA_RAWDEV_PMD_ERR ("device does not exist" );return -EFAULT ; }
@@ -491,7 +491,7 @@ static int set_surprise_link_check_aer(if (fd !=-1 )close (fd); -printf (">>>>>>Set AER %x,%x %x,%x\n" , +IFPGA_RAWDEV_PMD_INFO (">>>>>>Set AER %x,%x %x,%x" , ifpga_rdev->aer_old[0 ], ifpga_rdev->aer_old[1 ], aer_new0, aer_new1);
@@ -527,7 +527,7 @@ ifpga_rawdev_gsd_handle(__rte_unused void *param) }if (gsd_enable) -printf (">>>>>>Pls Shutdown APP\n" ); +IFPGA_RAWDEV_PMD_WARN (">>>>>>Pls Shutdown APP" );rte_delay_us (100 *MS ); }
Signature · 1 line
2.34.1
PATCH v2 1/1 bus/fslmc: convert queue storage macros to inline functions
In reply to Weijun PanFrom: Weijun Pan <[email protected]>
The queue storage allocation and free helpers are implemented as macros which declare local variables in the caller scope. This can cause shadow warnings when -Wshadow is enabled.
Convert them to static inline functions to avoid macro-local variable scope issues without changing behavior.
Bugzilla ID: 1744
--- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 75 ++++++++++++++----------- 1 file changed, 42 insertions(+), 33 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +42 -33
@@ -202,39 +202,48 @@ struct swp_active_dqs {uint64_t reserved[7 ]; }; -#define dpaa2_queue_storage_alloc (q, num) \ -({ \ - int ret = 0, i; \ - \ - for (i = 0; i < (num); i++) { \ - (q)->q_storage[i] = rte_zmalloc(NULL, \ - sizeof(struct queue_storage_info_t), \ - RTE_CACHE_LINE_SIZE); \ - if (!(q)->q_storage[i]) { \ - ret = -ENOBUFS; \ - break; \ - } \ - ret = dpaa2_alloc_dq_storage((q)->q_storage[i]); \ - if (ret) \ - break; \ - } \ - ret; \ -}) - -#define dpaa2_queue_storage_free (q, num) \ -({ \ - if (q) { \ - int i; \ - \ - 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; \ - } \ - } \ - } \ -}) +int dpaa2_alloc_dq_storage (struct queue_storage_info_t *q_storage); +void dpaa2_free_dq_storage (struct queue_storage_info_t *q_storage); + +static inline int +dpaa2_queue_storage_alloc (struct dpaa2_queue *q,int num) +{ +int ret =0 , i; + +for (i =0 ; i < num; i++) { + q->q_storage[i] =rte_zmalloc (NULL , +sizeof (struct queue_storage_info_t ), +RTE_CACHE_LINE_SIZE ); +if (!q->q_storage[i]) { + ret = -ENOBUFS ; +break ; + } + + ret =dpaa2_alloc_dq_storage (q->q_storage[i]); +if (ret) +break ; + } + +return ret; +} + +static inline void +dpaa2_queue_storage_free (struct dpaa2_queue *q,int num) +{ +int i; + +if (!q) +return ; + +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 ; + } + } +} +#define NUM_MAX_SWP 64
Signature · 1 line
2.34.1
RE: [PATCH v2] bus/fslmc: convert queue storage macros to inline functions
Re: [PATCH v2] bus/fslmc: convert queue storage macros to inline functions
In reply to Weijun PanHello,
Thanks for working on this issue.
Quoted 11 lines · Weijun Pan
From: Weijun Pan <[email protected]>
The queue storage allocation and free helpers are implemented as macros which declare local variables in the caller scope. This can cause shadow warnings when -Wshadow is enabled.
Convert them to static inline functions to avoid macro-local variable scope issues without changing behavior.
Bugzilla ID: 1744
This bugzilla is about compiling with -Wshadow.
The proposed fix is partial.
As I reported in my previous mail, enabling -Wshadow after the current patch still shows many build warnings in drivers/bus/fslmc/qbman/qbman_portal.c.
https://inbox.dpdk.org/dev/CAJFAV8w-VQJb6jM0KgAVP1rJKyUUwiBA6_seOCDwMX47rZmYyA@mail.gmail.com/
Could you work on a complete fix so the bz can be closed?
Quoted 3 lines
Fixes 12d98eceb8ac ("bus/fslmc: enhance QBMAN DQ storage logic")
Afaics, nothing is broken in the current code, why do we *need* to backport the change?
Quoted 1 line
Signed-off-by Weijun Pan <[email protected]>
Signature · 1 line
David Marchand