Fix building much of DPDK with -Wshadow
Subsystems (7)
cover Fix building much of DPDK with -Wshadow
As flagged in bugs #1742, #1743 and others, much of DPDK fails to build when -Wshadow flag is passed to the build. This patchset fixes many issues of this nature, but not all, in the hopes we can move towards enabling that warning flag globally for DPDK in future. This patchset fixes the following components in DPDK:
* all libraries
* Intel drivers
* testpmd
The following build now works on my system after this set is applied:
meson setup -Denable_drivers=net/intel/* -Denable_apps=test-pmd --werror -Dc_args=-Wshadow build-shadow && ninja -C build-shadow
Bruce Richardson (19):
eal: fix variable shadowing
ethdev: fix variable shadowing issues
eventdev: fix variable shadowing issues
net: remove shadowed variable
graph: fix variable shadowing errors
pipeline: fix variable shadowing
table: fix issues with variable shadowing
power: rename variable to eliminate shadowing
pcapng: rename variable to fix shadowing
telemetry: make socket handler typedef private
bbdev: fix variable shadowing
bus/pci: remove shadowed variables
net/intel: rename function param to avoid shadow warnings net/e1000: fix build with shadow warnings enabled net/i40e: fix build with shadow warnings enabled net/ice: fix build with shadow warnings enabled net/cpfl: fix build with shadow warnings enabled net/ixgbe: fix build with shadow warnings enabled app/test-pmd: fix build with shadow warnings enabled
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 +- drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- drivers/net/intel/common/rx.h | 6 +- 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 +- drivers/net/intel/e1000/igc_ethdev.c | 6 +- drivers/net/intel/i40e/i40e_ethdev.h | 10 +-- drivers/net/intel/ice/ice_ethdev.c | 6 +- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +- lib/bbdev/rte_bbdev.c | 2 +- lib/eal/common/eal_common_options.c | 12 +-- lib/eal/common/eal_common_trace.c | 89 +++++++++---------- lib/eal/common/malloc_heap.c | 2 +- lib/ethdev/ethdev_driver.c | 6 +- lib/ethdev/rte_ethdev.c | 1 - lib/eventdev/rte_event_eth_rx_adapter.c | 5 +- lib/eventdev/rte_event_eth_tx_adapter.c | 8 +- lib/graph/graph.c | 4 +- lib/graph/graph_private.h | 2 +- lib/net/net_crc_avx512.c | 4 +- lib/pcapng/rte_pcapng.c | 7 +- lib/pipeline/rte_swx_ctl.c | 11 ++- lib/pipeline/rte_swx_pipeline.c | 21 +++-- lib/pipeline/rte_swx_pipeline_internal.h | 10 +-- lib/power/rte_power_pmd_mgmt.c | 6 +- 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 +- lib/telemetry/rte_telemetry.h | 11 --- lib/telemetry/telemetry.c | 2 +- lib/telemetry/telemetry_internal.h | 11 +++ 42 files changed, 186 insertions(+), 215 deletions(-)
--
2.48.1
RFC PATCH 1/19 eal: fix variable shadowing
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
--- 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(-)
lib/eal/common/eal_common_options.c +6 -6
@@ -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; }
lib/eal/common/eal_common_trace.c +44 -45
196 lines not on this page · raw message
lib/eal/common/malloc_heap.c +1 -1
@@ -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
Signature · 1 line
2.48.1
RFC PATCH 2/19 ethdev: fix variable shadowing issues
In reply to Bruce RichardsonRemove unneeded extra variable definitions, and rename variables as necessary to ensure clean compile with -Wshadow warnings enabled.
--- lib/ethdev/ethdev_driver.c | 6 +++--- lib/ethdev/rte_ethdev.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
lib/ethdev/ethdev_driver.c +3 -3
@@ -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" );
lib/ethdev/rte_ethdev.c +0 -1
@@ -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);
Signature · 1 line
2.48.1
RFC PATCH 3/19 eventdev: fix variable shadowing issues
In reply to Bruce RichardsonRename a macro variable to avoid shadowing conflicts, and reduce the scope of another variable for the same reason.
--- 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(-)
lib/eventdev/rte_event_eth_rx_adapter.c +2 -3
@@ -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;
lib/eventdev/rte_event_eth_tx_adapter.c +4 -4
@@ -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)
Signature · 1 line
2.48.1
RFC PATCH 4/19 net: remove shadowed variable
In reply to Bruce RichardsonThe "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.
--- lib/net/net_crc_avx512.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/net/net_crc_avx512.c +1 -3
@@ -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 ) {
Signature · 1 line
2.48.1
RFC PATCH 5/19 graph: fix variable shadowing errors
In reply to Bruce RichardsonThe 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.
--- lib/graph/graph.c | 4 ++-- lib/graph/graph_private.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/graph/graph.c +2 -2
@@ -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);
lib/graph/graph_private.h +1 -1
@@ -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;
Signature · 1 line
2.48.1
Re: [RFC PATCH 05/19] graph: fix variable shadowing errors
Quoted 11 lines · On Thu, 6 Nov 2025 14:09:34 +0000 Bruce Richardson…
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_Tmakes sense as the comments says it is defined to be usable for compile-time evaluation.
* for the size calculations,RTE_MAX_Tis also useful as it explicitly encodes the type, making it clear that we are evaluating the size variables as "int" type, larger than theuin16_tsize is defined as.
Quoted 4 lines
Fixes b6ef3794b866 ("graph: move node clone name func into private as common")Signed-off-by Bruce Richardson <[email protected]>
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 <[email protected]>
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.
--- lib/eal/include/rte_common.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
lib/eal/include/rte_common.h +16 -3
@@ -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; \ })/**
Signature · 1 line
2.51.0
Re: [RFC PATCH 05/19] graph: fix variable shadowing errors
Quoted 27 lines · Stephen Hemminger
Quoted 11 lines · On Thu, 6 Nov 2025 14:09:34 +0000 Bruce Richardson…
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_Tmakes sense as the comments says it is defined to be usable for compile-time evaluation.
* for the size calculations,RTE_MAX_Tis also useful as it explicitly encodes the type, making it clear that we are evaluating the size variables as "int" type, larger than theuin16_tsize is defined as.Quoted 4 lines
Fixes b6ef3794b866 ("graph: move node clone name func into private as common")Signed-off-by Bruce Richardson <[email protected]>I had a patch series (not sent) for lots of these. This is how I addressed min/max
From
5c8d69c734f90a774f83aaf47bc6c61bb19f411eMon Sep 17 00:00:00 2001
From: Stephen Hemminger <[email protected]>
Date: Thu, 28 Aug 2025 09:24:54 -0700
Subject: [PATCH 06/13] eal: add more min/max helpers
Quoted 6 lines
Add
RTE_MIN3()to handle case of RTE_MIN(RTE_MIN(...)). Change name of local temporary variables inRTE_MAX()to allow for combinations of RTE_MIN(RTE_MAX(...)) without causing shadow declaration warnings.Signed-off-by Stephen Hemminger <[email protected]>
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
Quoted 44 lines
--- lib/eal/include/rte_common.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)lib/eal/include/rte_common.h +16
-3@@ -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; \ })/** Signature · 1 line
2.51.0
RFC PATCH 6/19 pipeline: fix variable shadowing
In reply to Bruce RichardsonRemove unnecessary inner variables and rename others in order to remove variable shadowing warnings from the code.
--- 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(-)
lib/pipeline/rte_swx_ctl.c +5 -6
@@ -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);
lib/pipeline/rte_swx_pipeline.c +10 -11
@@ -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;
lib/pipeline/rte_swx_pipeline_internal.h +5 -5
@@ -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 ; }
Signature · 1 line
2.48.1
RFC PATCH 7/19 table: fix issues with variable shadowing
In reply to Bruce RichardsonBuilding table library with -Wshadow reveals many warnings from shadowed variables. Fix these by removing definitions, or renaming variables as appropriate.
--- 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(-)
lib/table/rte_lru.h +19 -19
@@ -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 )
lib/table/rte_lru_arm64.h +7 -7
@@ -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
lib/table/rte_lru_x86.h +2 -2
@@ -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! */ \
lib/table/rte_swx_table_em.c +0 -2
@@ -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);
lib/table/rte_swx_table_learner.c +2 -2
@@ -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. */
lib/table/rte_table_hash_key16.c +1 -3
@@ -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);
lib/table/rte_table_hash_key32.c +1 -3
@@ -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);
lib/table/rte_table_hash_key8.c +1 -3
@@ -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
Re: [RFC PATCH 07/19] table: fix issues with variable shadowing
lib/table/rte_lru.h while (0) · line 44
Quoted 9 lines · On Thu, 6 Nov 2025 14:09:36 +0000 Bruce Richardson…
lib/table/rte_lru.h +0
-1@@ -41,33 +41,33 @@ while (0)#define lru_update (bucket, mru_val) \ do { \ - uint64_t x, pos, x0, x1, x2, mask; \
Why is this a macro? Prefer inline functions where there is checking on types etc.
Re: [RFC PATCH 07/19] table: fix issues with variable shadowing
Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Thu, 6 Nov 2025 14:09:36 +0000 Bruce Richardson…
lib/table/rte_lru.h +0
-0@@ -41,33 +41,33 @@ while (0)
Quoted 5 lines
lib/table/rte_lru.h while (0) · line 44
Quoted 3 lines
lib/table/rte_lru.h +0
-1#define lru_update (bucket, mru_val) \ do { \ - uint64_t x, pos, x0, x1, x2, mask; \Why is this a macro? Prefer inline functions where there is checking on types etc.
I asked myself the same question as I was working on this. :-) However, changing it to a function is beyond the scope of this patchset.
RFC PATCH 8/19 power: rename variable to eliminate shadowing
In reply to Bruce RichardsonThe "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".
--- lib/power/rte_power_pmd_mgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/rte_power_pmd_mgmt.c +3 -3
@@ -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 (); } }
Signature · 1 line
2.48.1
RFC PATCH 9/19 pcapng: rename variable to fix shadowing
In reply to Bruce RichardsonThe "len" variable is shadowed within a function, so rename inner use to the more descriptive "filter_len" to fix the issue.
--- lib/pcapng/rte_pcapng.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
lib/pcapng/rte_pcapng.c +3 -4
@@ -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 );
Signature · 1 line
2.48.1
Re: [RFC PATCH 09/19] pcapng: rename variable to fix shadowing
Quoted 7 lines · On Thu, 6 Nov 2025 14:09:38 +0000 Bruce Richardson…
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")Signed-off-by Bruce Richardson <[email protected]>
RFC PATCH 10/19 telemetry: make socket handler typedef private
In reply to Bruce RichardsonThe 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.
--- lib/telemetry/rte_telemetry.h | 11 ----------- lib/telemetry/telemetry.c | 2 +- lib/telemetry/telemetry_internal.h | 11 +++++++++++ 3 files changed, 12 insertions(+), 12 deletions(-)
lib/telemetry/rte_telemetry.h +0 -11
@@ -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. *
lib/telemetry/telemetry.c +1 -1
@@ -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 */
lib/telemetry/telemetry_internal.h +11 -0
@@ -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
Signature · 1 line
2.48.1
Re: [RFC PATCH 10/19] telemetry: make socket handler typedef private
Quoted 11 lines · Bruce Richardson
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")Signed-off-by Bruce Richardson <[email protected]>
RFC PATCH 11/19 bbdev: fix variable shadowing
In reply to Bruce RichardsonThe "ret" variable is declared twice in rte_bbdev_setup_queues function. The second declaration is unneeded so remove it.
--- lib/bbdev/rte_bbdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bbdev/rte_bbdev.c +1 -1
@@ -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",
Signature · 1 line
2.48.1
RFC PATCH 12/19 bus/pci: remove shadowed variables
In reply to Bruce RichardsonRemove 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.
--- drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/bus/pci/linux/pci.c +0 -1
@@ -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);
drivers/bus/pci/linux/pci_vfio.c +1 -1
@@ -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" );
Signature · 1 line
2.48.1
RFC PATCH 13/19 net/intel: rename function param to avoid shadow warnings
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/common/rx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/common/rx.h +3 -3
@@ -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;
Signature · 1 line
2.48.1
RFC PATCH 14/19 net/e1000: fix build with shadow warnings enabled
In reply to Bruce RichardsonVariable "ret" was shadowed within the close function, so rename outer variable to "retval" to clear the warnings.
--- drivers/net/intel/e1000/igc_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/e1000/igc_ethdev.c +3 -3
@@ -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
Signature · 1 line
2.48.1
RFC PATCH 15/19 net/i40e: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe local variables defined with the I40E_WRITE_GLB_REG macro are shadowing other variables. Rename the vars to start with "_" to avoid this shadowing.
--- drivers/net/intel/i40e/i40e_ethdev.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +5 -5
@@ -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 )
Signature · 1 line
2.48.1
RFC PATCH 16/19 net/ice: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/ice/ice_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +3 -3
@@ -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
Signature · 1 line
2.48.1
RFC PATCH 17/19 net/cpfl: fix build with shadow warnings enabled
In reply to Bruce RichardsonRemove unnecessary variable definitions to ensure compiling with -Wshadow enabled.
--- 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(-)
drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c +0 -2
@@ -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],
drivers/net/intel/cpfl/cpfl_flow_parser.c +3 -3
@@ -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 ) {
drivers/net/intel/cpfl/cpfl_fxp_rule.h +0 -2
@@ -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,
drivers/net/intel/cpfl/cpfl_representor.h +1 -1
@@ -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);
Signature · 1 line
2.48.1
RFC PATCH 18/19 net/ixgbe: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/intel/ixgbe/ixgbe_fdir.c +3 -4
@@ -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_infostruct 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 );
Signature · 1 line
2.48.1
RFC PATCH 19/19 app/test-pmd: fix build with shadow warnings enabled
In reply to Bruce RichardsonRename or remove shadowed variables so as to build cleanly with -Wshadow.
--- 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(-)
app/test-pmd/cmdline_flow.c +21 -21
@@ -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 ;
app/test-pmd/config.c +5 -10
@@ -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_DESCportid_t port_id, -#else - __rte_unused portid_t port_id, -#endifuint16_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 ;
app/test-pmd/parameters.c +1 -3
@@ -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 );
app/test-pmd/testpmd.c +1 -1
@@ -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",
Signature · 1 line
2.48.1
v2 cover build DPDK with -Wshadow
In reply to Bruce RichardsonAs flagged in bugs #1742, #1743 and others, much of DPDK fails to build when -Wshadow flag is passed to the build. This patchset fixes many issues of this nature, but not all, in the hopes we can move towards enabling that warning flag for all components for DPDK in future. This patchset fixes the following components in DPDK:
* all libraries
* Intel net drivers
* all apps in the "app" folder
For the rest of the drivers and example applications, any component which does not build successfully with the shadow warning enabled has it explicitly disabled via cflags. Then the last patch adds -Wshadow to the global DPDK build, which should prevent any regressions in components which are already working.
At that point, we should not have any regressions and we can, over time, reduce the number of components needing the -Wno-shadow flag.
RFC v2:
* take patch from Stephen for RTE_MIN/MAX fixes
* add additional fixes to clear clang warnings - it's a lot stricter than gcc in this regard, and flags more issues.
* extend app cleanup to all apps, not just testpmd
* add per-component disabling, and add global enable flag at the end.
Bruce Richardson (32):
eal: fix variable shadowing
ethdev: fix variable shadowing issues
eventdev: fix variable shadowing issues
net: remove shadowed variable
pipeline: fix variable shadowing
table: fix issues with variable shadowing
power: rename variable to eliminate shadowing
pcapng: rename variable to fix shadowing
telemetry: make socket handler typedef private
bbdev: fix variable shadowing
bus/pci: remove shadowed variables
net/intel: rename function param to avoid shadow warnings net/e1000: fix build with shadow warnings enabled net/i40e: fix build with shadow warnings enabled net/ice: fix build with shadow warnings enabled net/cpfl: fix build with shadow warnings enabled net/ixgbe: fix build with shadow warnings enabled app/test-pmd: fix build with shadow warnings enabled app/graph: fix build with shadow warnings enabled app/pdump: fix warning about shadowed variable app/test-bbdev: use RTE_MAX3 to remove variable shadowing app/test-compress-perf: fix variable shadowing app/test-crypto-perf: fix shadowed variable app/test-dma-perf: renamed shadowed variable app/test-eventdev: fix build with shadow warnings enabled app/test-flow-perf: remove unneeded variable app/test-security-perf: fix build with shadow warnings app/test-pipeline: remove unnecessary variable
drivers: disable variable shadowing warnings for drivers app/test: disable shadowing warnings for unit tests
examples: ignore variable shadowing warnings
build: enable shadowed variable warnings
Stephen Hemminger (1):
eal: add more min/max helpers
app/graph/conn.c | 134 +++++++++--------- app/pdump/main.c | 12 +- app/test-bbdev/test_bbdev_perf.c | 7 +- app/test-compress-perf/main.c | 122 ++++++++-------- .../cperf_test_pmd_cyclecount.c | 6 +- app/test-dma-perf/main.c | 8 +- app/test-eventdev/evt_main.c | 6 +- app/test-eventdev/test_atomic_queue.c | 6 +- app/test-eventdev/test_perf_common.c | 4 +- app/test-flow-perf/main.c | 1 - app/test-pipeline/main.c | 1 - app/test-pmd/cmdline_flow.c | 42 +++--- app/test-pmd/config.c | 15 +- app/test-pmd/parameters.c | 38 +++-- app/test-pmd/testpmd.c | 2 +- app/test-security-perf/test_security_perf.c | 42 +++--- app/test/meson.build | 1 + app/test/test_cryptodev_security_ipsec.c | 13 +- config/meson.build | 6 + drivers/baseband/fpga_5gnr_fec/meson.build | 2 + drivers/bus/fslmc/meson.build | 2 + drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- drivers/bus/pci/windows/pci.c | 1 - drivers/common/cnxk/meson.build | 1 + drivers/common/qat/meson.build | 1 + drivers/compress/nitrox/meson.build | 2 + drivers/crypto/cnxk/meson.build | 1 + drivers/crypto/octeontx/meson.build | 1 + drivers/crypto/openssl/meson.build | 1 + drivers/crypto/scheduler/meson.build | 1 + drivers/dma/dpaa2/meson.build | 2 + drivers/event/cnxk/meson.build | 1 + drivers/event/dlb2/meson.build | 2 + drivers/event/sw/meson.build | 1 + drivers/net/axgbe/meson.build | 2 +- drivers/net/bnxt/meson.build | 1 + drivers/net/bonding/meson.build | 1 + drivers/net/cnxk/meson.build | 1 + drivers/net/cxgbe/meson.build | 1 + drivers/net/dpaa/meson.build | 1 + drivers/net/dpaa2/meson.build | 1 + drivers/net/ena/meson.build | 2 + drivers/net/enetfec/meson.build | 2 + drivers/net/enic/meson.build | 2 + drivers/net/failsafe/meson.build | 1 + drivers/net/intel/common/rx.h | 6 +- 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 +- drivers/net/intel/e1000/igc_ethdev.c | 6 +- drivers/net/intel/i40e/i40e_ethdev.h | 10 +- drivers/net/intel/ice/ice_ethdev.c | 6 +- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +- drivers/net/mlx5/meson.build | 1 + drivers/net/ntnic/meson.build | 3 + drivers/net/pfe/meson.build | 3 + drivers/net/qede/meson.build | 3 + drivers/net/txgbe/meson.build | 1 + drivers/net/zxdh/meson.build | 3 + drivers/raw/ifpga/meson.build | 2 + drivers/vdpa/mlx5/meson.build | 1 + examples/bbdev_app/meson.build | 1 + examples/bond/meson.build | 1 + examples/dma/meson.build | 1 + examples/ethtool/meson.build | 1 + examples/eventdev_pipeline/meson.build | 1 + examples/flow_filtering/meson.build | 1 + examples/ip_pipeline/meson.build | 1 + examples/ipsec-secgw/meson.build | 1 + examples/l2fwd-crypto/meson.build | 1 + examples/l2fwd-event/meson.build | 1 + examples/l2fwd-jobstats/meson.build | 1 + examples/l2fwd-keepalive/meson.build | 1 + examples/l3fwd-graph/meson.build | 1 + examples/l3fwd-power/meson.build | 1 + examples/l3fwd/meson.build | 1 + .../client_server_mp/mp_server/meson.build | 1 + examples/packet_ordering/meson.build | 1 + examples/ptpclient/meson.build | 1 + examples/qos_sched/meson.build | 1 + .../server_node_efd/efd_server/meson.build | 1 + examples/vhost/meson.build | 1 + .../vm_power_manager/guest_cli/meson.build | 1 + examples/vm_power_manager/meson.build | 1 + examples/vmdq/meson.build | 1 + lib/bbdev/rte_bbdev.c | 2 +- lib/eal/common/eal_common_options.c | 22 +-- lib/eal/common/eal_common_trace.c | 89 ++++++------ lib/eal/common/malloc_heap.c | 2 +- lib/eal/include/rte_common.h | 31 +++- lib/ethdev/ethdev_driver.c | 6 +- lib/ethdev/rte_ethdev.c | 1 - lib/eventdev/rte_event_eth_rx_adapter.c | 5 +- lib/eventdev/rte_event_eth_tx_adapter.c | 8 +- lib/net/net_crc_avx512.c | 4 +- lib/pcapng/rte_pcapng.c | 7 +- lib/pipeline/rte_swx_ctl.c | 11 +- lib/pipeline/rte_swx_pipeline.c | 21 ++- lib/pipeline/rte_swx_pipeline_internal.h | 10 +- lib/power/rte_power_pmd_mgmt.c | 6 +- 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 +- lib/telemetry/rte_telemetry.h | 11 -- lib/telemetry/telemetry.c | 2 +- lib/telemetry/telemetry_internal.h | 11 ++ 113 files changed, 489 insertions(+), 425 deletions(-)
--
2.48.1
RFC PATCH v2 1/33 eal: add more min/max helpers
From: Stephen Hemminger <[email protected]>
Add RTE_MIN3() to handle case of RTE_MIN(RTE_MIN(...)), and similarly add RTE_MAX3(). Change name of local temporary variables in RTE_MAX() to allow for combinations of RTE_MIN(RTE_MAX(...)) without causing shadow declaration warnings.
--- lib/eal/include/rte_common.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
lib/eal/include/rte_common.h +28 -3
@@ -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,21 @@ __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; \ + }) + +/** +* Macro to return the maximum of three numbers +*/ +#define RTE_MAX3 (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); \ })/**
Signature · 1 line
2.48.1
Re: [RFC PATCH v2 01/33] eal: add more min/max helpers
Quoted 9 lines · Bruce Richardson
From: Stephen Hemminger <[email protected]>
Add
RTE_MIN3()to handle case of RTE_MIN(RTE_MIN(...)), and similarly addRTE_MAX3(). Change name of local temporary variables inRTE_MAX()to allow for combinations of RTE_MIN(RTE_MAX(...)) without causing shadow declaration warnings.Signed-off-by Stephen Hemminger <[email protected]>Signed-off-by Bruce Richardson <[email protected]>
Morten Brørup
Acked-byRE: [RFC PATCH v2 01/33] eal: add more min/max helpers
Quoted 9 lines
From: fengchengwen [mailto:[email protected]]
Acked-by Chengwen Feng <[email protected]>Quoted 4 lines · Bruce Richardson
From: Stephen Hemminger <[email protected]>
Add
RTE_MIN3()to handle case of RTE_MIN(RTE_MIN(...)), and similarly addRTE_MAX3().
Do we need RTE_MIN3_T()/RTE_MAX3_T() macros too?
Quoted 3 lines
Quoted 3 lines
Change name of local temporary variables in
RTE_MAX()to allow for combinations of RTE_MIN(RTE_MAX(...)) without causing shadow declaration warnings.
Consider making the local temporary variables in RTE_MIN() more unique too, in case the macro is combined with some other macro also using _a and _b.
<feature creep>
Maybe an RTE_MINMAX(min,max,val) would be useful?
Same about RTE_MINMAX_T(min,max,val,type)?
</feature creep>
Quoted 3 lines
Quoted 3 lines
Signed-off-by Stephen Hemminger <[email protected]>Signed-off-by Bruce Richardson <[email protected]>
With or without suggested additions,
Re: [RFC PATCH v2 01/33] eal: add more min/max helpers
Quoted 10 lines · Morten Brørup
Quoted 9 lines
From: fengchengwen [mailto:[email protected]]
Acked-by Chengwen Feng <[email protected]>Quoted 4 lines · Bruce Richardson
From: Stephen Hemminger <[email protected]>
Add
RTE_MIN3()to handle case of RTE_MIN(RTE_MIN(...)), and similarly addRTE_MAX3().
Quoted 8 lines
Do we need RTE_MIN3_T()/RTE_MAX3_T() macros too?
Quoted 3 lines
Quoted 3 lines
Change name of local temporary variables in
RTE_MAX()to allow for combinations of RTE_MIN(RTE_MAX(...)) without causing shadow declaration warnings.Consider making the local temporary variables in
RTE_MIN()more unique too, in case the macro is combined with some other macro also using _a and _b.
Yes, that's possible. If I remember, I'll try and tweak this again if I do a new version of the set.
Quoted 5 lines
<feature creep>
Maybe anRTE_MINMAX(min,max,val)would be useful?
Same aboutRTE_MINMAX_T(min,max,val,type)?
</feature creep>
Not sure that is worth doing.
Also, the naming gets weird and confusing, is the "max" parameter the parameter that would be passed to the MAX macro, i.e. the minimum value, or the actual maximum value you want to clamp. Therefore, if we were to have such an API, I'd avoid min-max in macro name entirely, and call it "RTE_BOUND" for example.
Again, though, I don't think it's a high priority addition and won't do in a new version of this set.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Signed-off-by Stephen Hemminger <[email protected]>Signed-off-by Bruce Richardson <[email protected]>With or without suggested additions,
Acked-by Morten Brørup <[email protected]>
RFC PATCH v2 2/33 eal: fix variable shadowing
In reply to Bruce RichardsonFix 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
--- drivers/bus/pci/windows/pci.c | 1 - lib/eal/common/eal_common_options.c | 22 +++---- lib/eal/common/eal_common_trace.c | 89 ++++++++++++++--------------- lib/eal/common/malloc_heap.c | 2 +- 4 files changed, 56 insertions(+), 58 deletions(-)
drivers/bus/pci/windows/pci.c +0 -1
@@ -433,7 +433,6 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)rte_pci_add_device (dev); }else {struct rte_pci_device *dev2 =NULL ; -int ret; TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);
lib/eal/common/eal_common_options.c +11 -11
@@ -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; }
@@ -429,21 +429,21 @@ eal_clean_saved_args(void)#endif /* !RTE_EXEC_ENV_WINDOWS */ 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);
lib/eal/common/eal_common_trace.c +44 -45
196 lines not on this page · raw message
lib/eal/common/malloc_heap.c +1 -1
@@ -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
Signature · 1 line
2.48.1
Re: [RFC PATCH v2 02/33] eal: fix variable shadowing
Quoted 19 lines · Bruce Richardson
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 ofaligned_end, and just use the already-defined local variable in the last block of code in the function.Bugzilla ID: 1742
Bugzilla ID: 1743Fixes 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 <[email protected]>
RFC PATCH v2 3/33 ethdev: fix variable shadowing issues
In reply to Bruce RichardsonRemove unneeded extra variable definitions, and rename variables as necessary to ensure clean compile with -Wshadow warnings enabled.
--- lib/ethdev/ethdev_driver.c | 6 +++--- lib/ethdev/rte_ethdev.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
lib/ethdev/ethdev_driver.c +3 -3
@@ -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" );
lib/ethdev/rte_ethdev.c +0 -1
@@ -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);
Signature · 1 line
2.48.1
Re: [RFC PATCH v2 03/33] ethdev: fix variable shadowing issues
Quoted 8 lines · Bruce Richardson
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")Signed-off-by Bruce Richardson <[email protected]>
Re: [RFC PATCH v2 03/33] ethdev: fix variable shadowing issues
In reply to Bruce RichardsonQuoted 8 lines · Bruce Richardson
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")Signed-off-by Bruce Richardson <[email protected]>
RFC PATCH v2 4/33 eventdev: fix variable shadowing issues
In reply to Bruce RichardsonRename a macro variable to avoid shadowing conflicts, and reduce the scope of another variable for the same reason.
--- 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(-)
lib/eventdev/rte_event_eth_rx_adapter.c +2 -3
@@ -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;
lib/eventdev/rte_event_eth_tx_adapter.c +4 -4
@@ -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)
Signature · 1 line
2.48.1
RFC PATCH v2 5/33 net: remove shadowed variable
In reply to Bruce RichardsonThe "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.
--- lib/net/net_crc_avx512.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/net/net_crc_avx512.c +1 -3
@@ -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 ) {
Signature · 1 line
2.48.1
RFC PATCH v2 6/33 pipeline: fix variable shadowing
In reply to Bruce RichardsonRemove unnecessary inner variables and rename others in order to remove variable shadowing warnings from the code.
--- 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(-)
lib/pipeline/rte_swx_ctl.c +5 -6
@@ -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);
lib/pipeline/rte_swx_pipeline.c +10 -11
@@ -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;
lib/pipeline/rte_swx_pipeline_internal.h +5 -5
@@ -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 ; }
Signature · 1 line
2.48.1
RFC PATCH v2 7/33 table: fix issues with variable shadowing
In reply to Bruce RichardsonBuilding table library with -Wshadow reveals many warnings from shadowed variables. Fix these by removing defintions, or renaming variables as appropriate.
--- 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(-)
lib/table/rte_lru.h +19 -19
@@ -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 )
lib/table/rte_lru_arm64.h +7 -7
@@ -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
lib/table/rte_lru_x86.h +2 -2
@@ -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! */ \
lib/table/rte_swx_table_em.c +0 -2
@@ -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);
lib/table/rte_swx_table_learner.c +2 -2
@@ -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. */
lib/table/rte_table_hash_key16.c +1 -3
@@ -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);
lib/table/rte_table_hash_key32.c +1 -3
@@ -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);
lib/table/rte_table_hash_key8.c +1 -3
@@ -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);
Signature · 1 line
2.48.1
RFC PATCH v2 8/33 power: rename variable to eliminate shadowing
In reply to Bruce RichardsonThe "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".
--- lib/power/rte_power_pmd_mgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/rte_power_pmd_mgmt.c +3 -3
@@ -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 (); } }
Signature · 1 line
2.48.1
RFC PATCH v2 9/33 pcapng: rename variable to fix shadowing
In reply to Bruce RichardsonThe "len" variable is shadowed within a function, so rename inner use to the more descriptive "filter_len" to fix the issue.
--- lib/pcapng/rte_pcapng.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
lib/pcapng/rte_pcapng.c +3 -4
@@ -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 );
Signature · 1 line
2.48.1
RFC PATCH v2 10/33 telemetry: make socket handler typedef private
In reply to Bruce RichardsonThe 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.
--- lib/telemetry/rte_telemetry.h | 11 ----------- lib/telemetry/telemetry.c | 2 +- lib/telemetry/telemetry_internal.h | 11 +++++++++++ 3 files changed, 12 insertions(+), 12 deletions(-)
lib/telemetry/rte_telemetry.h +0 -11
@@ -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. *
lib/telemetry/telemetry.c +1 -1
@@ -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 */
lib/telemetry/telemetry_internal.h +11 -0
@@ -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
Signature · 1 line
2.48.1
Re: [RFC PATCH v2 10/33] telemetry: make socket handler typedef private
Quoted 11 lines · Bruce Richardson
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")Signed-off-by Bruce Richardson <[email protected]>
RFC PATCH v2 11/33 bbdev: fix variable shadowing
In reply to Bruce RichardsonThe "ret" variable is declared twice in rte_bbdev_setup_queues function. The second declaration is unneeded so remove it.
--- lib/bbdev/rte_bbdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bbdev/rte_bbdev.c +1 -1
@@ -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",
Signature · 1 line
2.48.1
RFC PATCH v2 12/33 bus/pci: remove shadowed variables
In reply to Bruce RichardsonRemove 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.
--- drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/bus/pci/linux/pci.c +0 -1
@@ -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);
drivers/bus/pci/linux/pci_vfio.c +1 -1
@@ -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" );
Signature · 1 line
2.48.1
Re: [RFC PATCH v2 12/33] bus/pci: remove shadowed variables
Quoted 9 lines · Bruce Richardson
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")Signed-off-by Bruce Richardson <[email protected]>
RFC PATCH v2 13/33 net/intel: rename function param to avoid shadow warnings
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/common/rx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/common/rx.h +3 -3
@@ -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;
Signature · 1 line
2.48.1
RFC PATCH v2 14/33 net/e1000: fix build with shadow warnings enabled
In reply to Bruce RichardsonVariable "ret" was shadowed within the close function, so rename outer variable to "retval" to clear the warnings.
--- drivers/net/intel/e1000/igc_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/e1000/igc_ethdev.c +3 -3
@@ -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
Signature · 1 line
2.48.1
RFC PATCH v2 15/33 net/i40e: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe local variables defined with the I40E_WRITE_GLB_REG macro are shadowing other variables. Rename the vars to start with "_" to avoid this shadowing.
--- drivers/net/intel/i40e/i40e_ethdev.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +5 -5
@@ -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 )
Signature · 1 line
2.48.1
RFC PATCH v2 16/33 net/ice: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/ice/ice_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +3 -3
@@ -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
Signature · 1 line
2.48.1
RFC PATCH v2 17/33 net/cpfl: fix build with shadow warnings enabled
In reply to Bruce RichardsonRemove unnecessary variable definitions to ensure compiling with -Wshadow enabled.
--- 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(-)
drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c +0 -2
@@ -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],
drivers/net/intel/cpfl/cpfl_flow_parser.c +3 -3
@@ -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 ) {
drivers/net/intel/cpfl/cpfl_fxp_rule.h +0 -2
@@ -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,
drivers/net/intel/cpfl/cpfl_representor.h +1 -1
@@ -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);
Signature · 1 line
2.48.1
RFC PATCH v2 18/33 net/ixgbe: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/intel/ixgbe/ixgbe_fdir.c +3 -4
@@ -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_infostruct 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 );
Signature · 1 line
2.48.1
RFC PATCH v2 19/33 app/test-pmd: fix build with shadow warnings enabled
In reply to Bruce RichardsonRename or remove shadowed variables so as to build cleanly with -Wshadow.
--- app/test-pmd/cmdline_flow.c | 42 ++++++++++++++++++------------------- app/test-pmd/config.c | 15 +++++-------- app/test-pmd/parameters.c | 38 ++++++++++++++++----------------- app/test-pmd/testpmd.c | 2 +- 4 files changed, 45 insertions(+), 52 deletions(-)
app/test-pmd/cmdline_flow.c +21 -21
@@ -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 ;
app/test-pmd/config.c +5 -10
@@ -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_DESCportid_t port_id, -#else - __rte_unused portid_t port_id, -#endifuint16_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 ;
app/test-pmd/parameters.c +18 -20
@@ -777,42 +777,42 @@ parse_ringnuma_config(const char *q_arg) }static int -parse_event_printing_config (const char *optarg,int enable) +parse_event_printing_config (const char *event_arg,int enable) {uint32_t mask =0 ; -if (!strcmp (optarg,"unknown" )) +if (!strcmp (event_arg,"unknown" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_UNKNOWN ; -else if (!strcmp (optarg,"intr_lsc" )) +else if (!strcmp (event_arg,"intr_lsc" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_LSC ; -else if (!strcmp (optarg,"queue_state" )) +else if (!strcmp (event_arg,"queue_state" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_QUEUE_STATE ; -else if (!strcmp (optarg,"intr_reset" )) +else if (!strcmp (event_arg,"intr_reset" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_RESET ; -else if (!strcmp (optarg,"vf_mbox" )) +else if (!strcmp (event_arg,"vf_mbox" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_VF_MBOX ; -else if (!strcmp (optarg,"ipsec" )) +else if (!strcmp (event_arg,"ipsec" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_IPSEC ; -else if (!strcmp (optarg,"macsec" )) +else if (!strcmp (event_arg,"macsec" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_MACSEC ; -else if (!strcmp (optarg,"intr_rmv" )) +else if (!strcmp (event_arg,"intr_rmv" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_RMV ; -else if (!strcmp (optarg,"dev_probed" )) +else if (!strcmp (event_arg,"dev_probed" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_NEW ; -else if (!strcmp (optarg,"dev_released" )) +else if (!strcmp (event_arg,"dev_released" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_DESTROY ; -else if (!strcmp (optarg,"flow_aged" )) +else if (!strcmp (event_arg,"flow_aged" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_FLOW_AGED ; -else if (!strcmp (optarg,"err_recovering" )) +else if (!strcmp (event_arg,"err_recovering" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_ERR_RECOVERING ; -else if (!strcmp (optarg,"recovery_success" )) +else if (!strcmp (event_arg,"recovery_success" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_RECOVERY_SUCCESS ; -else if (!strcmp (optarg,"recovery_failed" )) +else if (!strcmp (event_arg,"recovery_failed" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_RECOVERY_FAILED ; -else if (!strcmp (optarg,"all" )) +else if (!strcmp (event_arg,"all" )) mask = ~UINT32_C (0 );else { -fprintf (stderr,"Invalid event: %s\n" , optarg); +fprintf (stderr,"Invalid event: %s\n" , event_arg);return -1 ; }if (enable)
@@ -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 );
app/test-pmd/testpmd.c +1 -1
@@ -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",
Signature · 1 line
2.48.1
RFC PATCH v2 20/33 app/graph: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe global variable "conn" conflicted with the local parameter to each function in the graph conn.c file. To prevent shadowing, use "c" as the name for the local connection variable throughout the file.
--- app/graph/conn.c | 134 +++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 67 deletions(-)
app/graph/conn.c +67 -67
@@ -20,12 +20,12 @@#define MSG_CMD_TOO_LONG "Command too long."static int -data_event_handle (struct conn *conn,int fd_client) +data_event_handle (struct conn *c,int fd_client) {ssize_t len, i, rc =0 ;/* Read input message */ - len =read (fd_client, conn->buf, conn->buf_size); + len =read (fd_client, c->buf, c->buf_size);if (len ==-1 ) {if ((errno ==EAGAIN ) || (errno ==EWOULDBLOCK ))return 0 ;
@@ -38,37 +38,37 @@ data_event_handle(struct conn *conn, int fd_client)/* Handle input messages */ for (i =0 ; i < len; i++) { -if (conn->buf[i] =='\n' ) { +if (c->buf[i] =='\n' ) {size_t n; - conn->msg_in[conn->msg_in_len] =0 ; - conn->msg_out[0 ] =0 ; + c->msg_in[c->msg_in_len] =0 ; + c->msg_out[0 ] =0 ; - conn->msg_handle (conn->msg_in, conn->msg_out, conn->msg_out_len_max, - conn->msg_handle_arg); + c->msg_handle (c->msg_in, c->msg_out, c->msg_out_len_max, + c->msg_handle_arg); - n =strlen (conn->msg_out); + n =strlen (c->msg_out);if (n) { - rc =write (fd_client, conn->msg_out, n); + rc =write (fd_client, c->msg_out, n);if (rc ==-1 ) goto exit; } - conn->msg_in_len =0 ; - }else if (conn->msg_in_len < conn->msg_in_len_max) { - conn->msg_in[conn->msg_in_len] = conn->buf[i]; - conn->msg_in_len++; + c->msg_in_len =0 ; + }else if (c->msg_in_len < c->msg_in_len_max) { + c->msg_in[c->msg_in_len] = c->buf[i]; + c->msg_in_len++; }else { rc =write (fd_client,MSG_CMD_TOO_LONG ,strlen (MSG_CMD_TOO_LONG ));if (rc ==-1 ) goto exit; - conn->msg_in_len =0 ; + c->msg_in_len =0 ; } }/* Write prompt */ - rc =write (fd_client, conn->prompt,strlen (conn->prompt)); + rc =write (fd_client, c->prompt,strlen (c->prompt)); rc = (rc ==-1 ) ?-1 :0 ; exit:
@@ -76,11 +76,11 @@ data_event_handle(struct conn *conn, int fd_client) }static int -control_event_handle (struct conn *conn,int fd_client) +control_event_handle (struct conn *c,int fd_client) {int rc; - rc =epoll_ctl (conn->fd_client_group,EPOLL_CTL_DEL , fd_client,NULL ); + rc =epoll_ctl (c->fd_client_group,EPOLL_CTL_DEL , fd_client,NULL );if (rc ==-1 ) goto exit;
@@ -99,7 +99,7 @@ conn_init(struct conn_params *p) {int fd_server, fd_client_group, rc;struct sockaddr_in server_address; -struct conn *conn =NULL ; +struct conn *c =NULL ;int reuse =1 ;memset (&server_address,0 ,sizeof (server_address));
@@ -115,20 +115,20 @@ conn_init(struct conn_params *p) goto exit;/* Memory allocation */ - conn =calloc (1 ,sizeof (struct conn )); -if (conn ==NULL ) + c =calloc (1 ,sizeof (struct conn )); +if (c ==NULL ) goto exit; - conn->welcome =calloc (1 ,CONN_WELCOME_LEN_MAX +1 ); - conn->prompt =calloc (1 ,CONN_PROMPT_LEN_MAX +1 ); - conn->buf =calloc (1 , p->buf_size); - conn->msg_in =calloc (1 , p->msg_in_len_max +1 ); - conn->msg_out =calloc (1 , p->msg_out_len_max +1 ); + c->welcome =calloc (1 ,CONN_WELCOME_LEN_MAX +1 ); + c->prompt =calloc (1 ,CONN_PROMPT_LEN_MAX +1 ); + c->buf =calloc (1 , p->buf_size); + c->msg_in =calloc (1 , p->msg_in_len_max +1 ); + c->msg_out =calloc (1 , p->msg_out_len_max +1 ); -if ((conn->welcome ==NULL ) || (conn->prompt ==NULL ) || (conn->buf ==NULL ) || - (conn->msg_in ==NULL ) || (conn->msg_out ==NULL )) { -conn_free (conn); - conn =NULL ; +if ((c->welcome ==NULL ) || (c->prompt ==NULL ) || (c->buf ==NULL ) || + (c->msg_in ==NULL ) || (c->msg_out ==NULL )) { +conn_free (c); + c =NULL ; goto exit; }
@@ -138,8 +138,8 @@ conn_init(struct conn_params *p) fd_server =socket (AF_INET ,SOCK_STREAM |SOCK_NONBLOCK ,0 );if (fd_server ==-1 ) { -conn_free (conn); - conn =NULL ; +conn_free (c); + c =NULL ; goto exit; }
@@ -161,47 +161,47 @@ conn_init(struct conn_params *p) goto free;/* Fill in */ -rte_strscpy (conn->welcome, p->welcome,CONN_WELCOME_LEN_MAX ); -rte_strscpy (conn->prompt, p->prompt,CONN_PROMPT_LEN_MAX ); - conn->buf_size = p->buf_size; - conn->msg_in_len_max = p->msg_in_len_max; - conn->msg_out_len_max = p->msg_out_len_max; - conn->msg_in_len =0 ; - conn->fd_server = fd_server; - conn->fd_client_group = fd_client_group; - conn->msg_handle = p->msg_handle; - conn->msg_handle_arg = p->msg_handle_arg; +rte_strscpy (c->welcome, p->welcome,CONN_WELCOME_LEN_MAX ); +rte_strscpy (c->prompt, p->prompt,CONN_PROMPT_LEN_MAX ); + c->buf_size = p->buf_size; + c->msg_in_len_max = p->msg_in_len_max; + c->msg_out_len_max = p->msg_out_len_max; + c->msg_in_len =0 ; + c->fd_server = fd_server; + c->fd_client_group = fd_client_group; + c->msg_handle = p->msg_handle; + c->msg_handle_arg = p->msg_handle_arg; exit: -return conn; +return c; free: -conn_free (conn); +conn_free (c);close (fd_server); - conn =NULL ; -return conn; + c =NULL ; +return c; }void -conn_free (struct conn *conn) +conn_free (struct conn *c) { -if (conn ==NULL ) +if (c ==NULL )return ; -if (conn->fd_client_group) -close (conn->fd_client_group); +if (c->fd_client_group) +close (c->fd_client_group); -if (conn->fd_server) -close (conn->fd_server); +if (c->fd_server) +close (c->fd_server); -free (conn->msg_out); -free (conn->msg_in); -free (conn->prompt); -free (conn->welcome); -free (conn); +free (c->msg_out); +free (c->msg_in); +free (c->prompt); +free (c->welcome); +free (c); }int -conn_req_poll (struct conn *conn) +conn_req_poll (struct conn *c) {struct sockaddr_in client_address;socklen_t client_address_length;
@@ -209,12 +209,12 @@ conn_req_poll(struct conn *conn)int fd_client, rc;/* Check input arguments */ -if (conn ==NULL ) +if (c ==NULL )return -1 ;/* Server socket */ client_address_length =sizeof (client_address); - fd_client =accept4 (conn->fd_server, (struct sockaddr *)&client_address, + fd_client =accept4 (c->fd_server, (struct sockaddr *)&client_address, &client_address_length,SOCK_NONBLOCK );if (fd_client ==-1 ) {if ((errno ==EAGAIN ) || (errno ==EWOULDBLOCK ))
@@ -227,20 +227,20 @@ conn_req_poll(struct conn *conn) event.events =EPOLLIN |EPOLLRDHUP |EPOLLHUP ; event.data.fd = fd_client; - rc =epoll_ctl (conn->fd_client_group,EPOLL_CTL_ADD , fd_client, &event); + rc =epoll_ctl (c->fd_client_group,EPOLL_CTL_ADD , fd_client, &event);if (rc ==-1 ) {close (fd_client); goto exit; }/* Client */ - rc =write (fd_client, conn->welcome,strlen (conn->welcome)); + rc =write (fd_client, c->welcome,strlen (c->welcome));if (rc ==-1 ) {close (fd_client); goto exit; } - rc =write (fd_client, conn->prompt,strlen (conn->prompt)); + rc =write (fd_client, c->prompt,strlen (c->prompt));if (rc ==-1 ) {close (fd_client); goto exit;
@@ -253,17 +253,17 @@ conn_req_poll(struct conn *conn) }int -conn_msg_poll (struct conn *conn) +conn_msg_poll (struct conn *c) {int fd_client, rc, rc_data =0 , rc_control =0 ;struct epoll_event event;/* Check input arguments */ -if (conn ==NULL ) +if (c ==NULL )return -1 ;/* Client group */ - rc =epoll_wait (conn->fd_client_group, &event,1 ,0 ); + rc =epoll_wait (c->fd_client_group, &event,1 ,0 );if ((rc ==-1 ) || rc ==0 )return rc;
@@ -271,11 +271,11 @@ conn_msg_poll(struct conn *conn)/* Data available */ if (event.events &EPOLLIN ) - rc_data =data_event_handle (conn, fd_client); + rc_data =data_event_handle (c, fd_client);/* Control events */ if (event.events & (EPOLLRDHUP |EPOLLERR |EPOLLHUP )) - rc_control =control_event_handle (conn, fd_client); + rc_control =control_event_handle (c, fd_client);if (rc_data || rc_control)return -1 ;
Signature · 1 line
2.48.1
RFC PATCH v2 21/33 app/pdump: fix warning about shadowed variable
In reply to Bruce RichardsonThe variable name "optarg" is a standard global variable in getopt, so use of that name for function parameters causes shadowing warnings. Rename the variable to avoid these issues.
--- app/pdump/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/pdump/main.c +6 -6
@@ -247,7 +247,7 @@ parse_uint_value(const char *key, const char *value, void *extra_args) }static int -parse_pdump (const char *optarg) +parse_pdump (const char *arg) {struct rte_kvargs *kvlist;int ret =0 , cnt1, cnt2;
@@ -257,9 +257,9 @@ parse_pdump(const char *optarg) pt = &pdump_t[num_tuples];/* initial check for invalid arguments */ - kvlist =rte_kvargs_parse (optarg, valid_pdump_arguments); + kvlist =rte_kvargs_parse (arg, valid_pdump_arguments);if (kvlist ==NULL ) { -printf ("--pdump=\"%s\": invalid argument passed\n" , optarg); +printf ("--pdump=\"%s\": invalid argument passed\n" , arg);return -1 ; }
@@ -268,7 +268,7 @@ parse_pdump(const char *optarg) cnt2 =rte_kvargs_count (kvlist,PDUMP_PCI_ARG );if (!((cnt1 ==1 && cnt2 ==0 ) || (cnt1 ==0 && cnt2 ==1 ))) {printf ("--pdump=\"%s\": must have either port or " -"device_id argument\n" , optarg); +"device_id argument\n" , arg); ret =-1 ; goto free_kvlist; }else if (cnt1 ==1 ) {
@@ -290,7 +290,7 @@ parse_pdump(const char *optarg)/* queue parsing and validation */ cnt1 =rte_kvargs_count (kvlist,PDUMP_QUEUE_ARG );if (cnt1 !=1 ) { -printf ("--pdump=\"%s\": must have queue argument\n" , optarg); +printf ("--pdump=\"%s\": must have queue argument\n" , arg); ret =-1 ; goto free_kvlist; }
@@ -303,7 +303,7 @@ parse_pdump(const char *optarg) cnt2 =rte_kvargs_count (kvlist,PDUMP_TX_DEV_ARG );if (cnt1 ==0 && cnt2 ==0 ) {printf ("--pdump=\"%s\": must have either rx-dev or " -"tx-dev argument\n" , optarg); +"tx-dev argument\n" , arg); ret =-1 ; goto free_kvlist; }else if (cnt1 ==1 && cnt2 ==1 ) {
Signature · 1 line
2.48.1
RFC PATCH v2 22/33 app/test-bbdev: use RTE_MAX3 to remove variable shadowing
In reply to Bruce RichardsonNested use of RTE_MAX leads to variable shadowing for the internal variables, so use RTE_MAX3 rather than two nested calls.
--- app/test-bbdev/test_bbdev_perf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
app/test-bbdev/test_bbdev_perf.c +3 -4
@@ -552,12 +552,11 @@ create_mempools(struct active_device *ad, int socket_id, &test_vector.entries[DATA_HARQ_OUTPUT ];/* allocate ops mempool */ - ops_pool_size =optimal_mempool_size (RTE_MAX ( + ops_pool_size =optimal_mempool_size (RTE_MAX3 (/* Ops used plus 1 reference op */ -RTE_MAX ((unsigned int )(ad->nb_queues * num_ops +1 ), + (unsigned int )(ad->nb_queues * num_ops +1 ),/* Minimal cache size plus 1 reference op */ - (unsigned int )(1.5 *rte_lcore_count () * -OPS_CACHE_SIZE +1 )), + (unsigned int )(1.5 *rte_lcore_count () *OPS_CACHE_SIZE +1 ),OPS_POOL_SIZE_MIN ));if (org_op_type ==RTE_BBDEV_OP_NONE )
Signature · 1 line
2.48.1
RFC PATCH v2 23/33 app/test-compress-perf: fix variable shadowing
In reply to Bruce RichardsonRename the parameter to 3 functions to avoid shadowing a global variable of the same name.
--- app/test-compress-perf/main.c | 122 +++++++++++++++++----------------- 1 file changed, 61 insertions(+), 61 deletions(-)
app/test-compress-perf/main.c +61 -61
@@ -53,33 +53,33 @@ static const struct cperf_test cperf_testmap[] = {static struct comp_test_data *test_data;static int -comp_perf_check_capabilities (struct comp_test_data *test_data,uint8_t cdev_id) +comp_perf_check_capabilities (struct comp_test_data *td,uint8_t cdev_id) {const struct rte_compressdev_capabilities *cap; - cap =rte_compressdev_capability_get (cdev_id, test_data->test_algo); + cap =rte_compressdev_capability_get (cdev_id, td->test_algo);if (cap ==NULL ) {RTE_LOG (ERR ,USER1 ,"Compress device does not support %u algorithm\n" , - test_data->test_algo); + td->test_algo);return -1 ; }uint64_t comp_flags = cap->comp_feature_flags;/* Algorithm type */ -switch (test_data->test_algo) { +switch (td->test_algo) {case RTE_COMP_ALGO_DEFLATE :/* Huffman encoding */ -if (test_data->huffman_enc ==RTE_COMP_HUFFMAN_FIXED && +if (td->huffman_enc ==RTE_COMP_HUFFMAN_FIXED && (comp_flags &RTE_COMP_FF_HUFFMAN_FIXED ) ==0 ) {RTE_LOG (ERR ,USER1 ,"Compress device does not supported Fixed Huffman\n" );return -1 ; } -if (test_data->huffman_enc ==RTE_COMP_HUFFMAN_DYNAMIC && +if (td->huffman_enc ==RTE_COMP_HUFFMAN_DYNAMIC && (comp_flags &RTE_COMP_FF_HUFFMAN_DYNAMIC ) ==0 ) {RTE_LOG (ERR ,USER1 ,"Compress device does not supported Dynamic Huffman\n" );
@@ -88,14 +88,14 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)break ;case RTE_COMP_ALGO_LZ4 :/* LZ4 flags */ -if ((test_data->lz4_flags &RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM ) && +if ((td->lz4_flags &RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM ) && (comp_flags &RTE_COMP_FF_LZ4_BLOCK_WITH_CHECKSUM ) ==0 ) {RTE_LOG (ERR ,USER1 ,"Compress device does not support LZ4 block with checksum\n" );return -1 ; } -if ((test_data->lz4_flags & +if ((td->lz4_flags &RTE_COMP_LZ4_FLAG_BLOCK_INDEPENDENCE ) && (comp_flags &RTE_COMP_FF_LZ4_BLOCK_INDEPENDENCE ) ==0 ) { RTE_LOG(ERR, USER1,
@@ -111,8 +111,8 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) }/* Window size */ -if (test_data->window_sz !=-1 ) { -if (param_range_check (test_data->window_sz, &cap->window_size) +if (td->window_sz !=-1 ) { +if (param_range_check (td->window_sz, &cap->window_size) <0 ) {RTE_LOG (ERR ,USER1 , "Compress device does not support "
@@ -121,18 +121,18 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) } }else /* Set window size to PMD maximum if none was specified */ - test_data->window_sz = cap->window_size.max; + td->window_sz = cap->window_size.max;/* Check if chained mbufs is supported */ -if (test_data->max_sgl_segs >1 && +if (td->max_sgl_segs >1 && (comp_flags &RTE_COMP_FF_OOP_SGL_IN_SGL_OUT ) ==0 ) {RTE_LOG (INFO ,USER1 ,"Compress device does not support " "chained mbufs. Max SGL segments set to 1\n" ); - test_data->max_sgl_segs =1 ; + td->max_sgl_segs =1 ; }/* Level 0 support */ -if (test_data->level_lst.min ==0 && +if (td->level_lst.min ==0 && (comp_flags &RTE_COMP_FF_NONCOMPRESSED_BLOCKS ) ==0 ) {RTE_LOG (ERR ,USER1 ,"Compress device does not support " "level 0 (no compression)\n" );
@@ -143,19 +143,19 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) }static int -comp_perf_initialize_compressdev (struct comp_test_data *test_data, +comp_perf_initialize_compressdev (struct comp_test_data *td,uint8_t *enabled_cdevs) {uint8_t enabled_cdev_count, nb_lcores, cdev_id;unsigned int i, j;int ret; - enabled_cdev_count =rte_compressdev_devices_get (test_data->driver_name, + enabled_cdev_count =rte_compressdev_devices_get (td->driver_name, enabled_cdevs,RTE_COMPRESS_MAX_DEVS );if (enabled_cdev_count ==0 ) {RTE_LOG (ERR ,USER1 ,"No compress devices type %s available," " please check the list of specified devices in EAL section\n" , - test_data->driver_name); + td->driver_name);return -EINVAL ; }
@@ -186,13 +186,13 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,* 2 queue pairs will be set up per device but one queue pair * will left unused in the last one device */ - test_data->nb_qps = (nb_lcores % enabled_cdev_count) ? + td->nb_qps = (nb_lcores % enabled_cdev_count) ? (nb_lcores / enabled_cdev_count) +1 : nb_lcores / enabled_cdev_count;for (i =0 ; i < enabled_cdev_count && i <RTE_COMPRESS_MAX_DEVS ; i++, - nb_lcores -= test_data->nb_qps) { + nb_lcores -= td->nb_qps) { cdev_id = enabled_cdevs[i];struct rte_compressdev_info cdev_info;
@@ -200,7 +200,7 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,rte_compressdev_info_get (cdev_id, &cdev_info);if (cdev_info.max_nb_queue_pairs && - test_data->nb_qps > cdev_info.max_nb_queue_pairs) { + td->nb_qps > cdev_info.max_nb_queue_pairs) {RTE_LOG (ERR ,USER1 ,"Number of needed queue pairs is higher " "than the maximum number of queue pairs "
@@ -211,25 +211,25 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,return -EINVAL ; } -if (comp_perf_check_capabilities (test_data, cdev_id) <0 ) +if (comp_perf_check_capabilities (td, cdev_id) <0 )return -EINVAL ;/* Configure compressdev */ struct rte_compressdev_config config = { .socket_id = socket_id, - .nb_queue_pairs = nb_lcores > test_data->nb_qps - ? test_data->nb_qps : nb_lcores, + .nb_queue_pairs = nb_lcores > td->nb_qps + ? td->nb_qps : nb_lcores, .max_nb_priv_xforms =NUM_MAX_XFORMS , .max_nb_streams =0 }; - test_data->nb_qps = config.nb_queue_pairs; + td->nb_qps = config.nb_queue_pairs;if (rte_compressdev_configure (cdev_id, &config) <0 ) {RTE_LOG (ERR ,USER1 ,"Device configuration failed\n" );return -EINVAL ; } -for (j =0 ; j < test_data->nb_qps; j++) { +for (j =0 ; j < td->nb_qps; j++) { ret =rte_compressdev_queue_pair_setup (cdev_id, j,NUM_MAX_INFLIGHT_OPS , socket_id);if (ret <0 ) {
@@ -253,9 +253,9 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data, }static int -comp_perf_dump_input_data (struct comp_test_data *test_data) +comp_perf_dump_input_data (struct comp_test_data *td) { -FILE *f =fopen (test_data->input_file,"r" ); +FILE *f =fopen (td->input_file,"r" );int ret =-1 ;size_t actual_file_sz, remaining_data;uint8_t *data =NULL ;
@@ -274,34 +274,34 @@ comp_perf_dump_input_data(struct comp_test_data *test_data)* input data size = file size */ -if (test_data->input_data_sz ==0 ) - test_data->input_data_sz = actual_file_sz; +if (td->input_data_sz ==0 ) + td->input_data_sz = actual_file_sz; -if (test_data->input_data_sz <=0 || actual_file_sz <=0 || +if (td->input_data_sz <=0 || actual_file_sz <=0 ||fseek (f,0 ,SEEK_SET ) !=0 ) {RTE_LOG (ERR ,USER1 ,"Size of input could not be calculated\n" ); goto end; } -if (!(test_data->test_op &COMPRESS ) && - test_data->input_data_sz > - (size_t ) test_data->seg_sz * (size_t ) test_data->max_sgl_segs) { +if (!(td->test_op &COMPRESS ) && + td->input_data_sz > + (size_t ) td->seg_sz * (size_t ) td->max_sgl_segs) {RTE_LOG (ERR ,USER1 ,"Size of input must be less than total segments\n" ); goto end; } - test_data->input_data =rte_zmalloc_socket (NULL , - test_data->input_data_sz,0 ,rte_socket_id ()); + td->input_data =rte_zmalloc_socket (NULL , + td->input_data_sz,0 ,rte_socket_id ()); -if (test_data->input_data ==NULL ) { +if (td->input_data ==NULL ) {RTE_LOG (ERR ,USER1 ,"Memory to hold the data from the input " "file could not be allocated\n" ); goto end; } - remaining_data = test_data->input_data_sz; - data = test_data->input_data; + remaining_data = td->input_data_sz; + data = td->input_data;while (remaining_data >0 ) {size_t data_to_read =RTE_MIN (remaining_data, actual_file_sz);
@@ -320,15 +320,15 @@ comp_perf_dump_input_data(struct comp_test_data *test_data) }printf ("\n" ); -if (test_data->input_data_sz > actual_file_sz) +if (td->input_data_sz > actual_file_sz)RTE_LOG (INFO ,USER1 ,"%zu bytes read from file %s, extending the file %.2f times\n" , - test_data->input_data_sz, test_data->input_file, - (double )test_data->input_data_sz/actual_file_sz); + td->input_data_sz, td->input_file, + (double )td->input_data_sz/actual_file_sz);else RTE_LOG (INFO ,USER1 ,"%zu bytes read from file %s\n" , - test_data->input_data_sz, test_data->input_file); + td->input_data_sz, td->input_file); ret =0 ;
@@ -338,15 +338,15 @@ comp_perf_dump_input_data(struct comp_test_data *test_data) }static int -comp_perf_dump_dictionary_data (struct comp_test_data *test_data) +comp_perf_dump_dictionary_data (struct comp_test_data *td) { -FILE *f =fopen (test_data->dictionary_file,"r" ); +FILE *f =fopen (td->dictionary_file,"r" );int ret =-1 ;if (f ==NULL ) {RTE_LOG (ERR ,USER1 ,"Dictionary file not specified\n" ); - test_data->dictionary_data_sz =0 ; - test_data->dictionary_data =NULL ; + td->dictionary_data_sz =0 ; + td->dictionary_data =NULL ; ret =0 ; goto end; }
@@ -367,40 +367,40 @@ comp_perf_dump_dictionary_data(struct comp_test_data *test_data)size_t actual_file_sz = (size_t )file_sz; -if (test_data->dictionary_data_sz ==0 ) - test_data->dictionary_data_sz = actual_file_sz; +if (td->dictionary_data_sz ==0 ) + td->dictionary_data_sz = actual_file_sz;if (fseek (f,0 ,SEEK_SET ) !=0 ) {RTE_LOG (ERR ,USER1 ,"Size of input could not be calculated\n" ); goto end; } - test_data->dictionary_data =rte_zmalloc_socket (NULL , - test_data->dictionary_data_sz,0 ,rte_socket_id ()); + td->dictionary_data =rte_zmalloc_socket (NULL , + td->dictionary_data_sz,0 ,rte_socket_id ()); -if (test_data->dictionary_data ==NULL ) { +if (td->dictionary_data ==NULL ) {RTE_LOG (ERR ,USER1 ,"Memory to hold the data from the dictionary " "file could not be allocated\n" ); goto end; } -size_t remaining_data = test_data->dictionary_data_sz; -uint8_t *data = test_data->dictionary_data; +size_t remaining_data = td->dictionary_data_sz; +uint8_t *data = td->dictionary_data;while (remaining_data >0 ) {size_t data_to_read =RTE_MIN (remaining_data, actual_file_sz);if (fread (data, data_to_read,1 , f) !=1 ) {RTE_LOG (ERR ,USER1 ,"Input file could not be read\n" ); -if (test_data->dictionary_data) -rte_free (test_data->dictionary_data); +if (td->dictionary_data) +rte_free (td->dictionary_data); goto end; }if (fseek (f,0 ,SEEK_SET ) !=0 ) {RTE_LOG (ERR ,USER1 ,"Size of input could not be calculated\n" ); -if (test_data->dictionary_data) -rte_free (test_data->dictionary_data); +if (td->dictionary_data) +rte_free (td->dictionary_data); goto end; } remaining_data -= data_to_read;
@@ -408,15 +408,15 @@ comp_perf_dump_dictionary_data(struct comp_test_data *test_data) }printf ("\n" ); -if (test_data->dictionary_data_sz > actual_file_sz) +if (td->dictionary_data_sz > actual_file_sz)RTE_LOG (INFO ,USER1 ,"%zu bytes read from file %s, extending the file %.2f times\n" , - test_data->dictionary_data_sz, test_data->dictionary_file, - (double )test_data->dictionary_data_sz/actual_file_sz); + td->dictionary_data_sz, td->dictionary_file, + (double )td->dictionary_data_sz/actual_file_sz);else RTE_LOG (INFO ,USER1 ,"%zu bytes read from file %s\n" , - test_data->dictionary_data_sz, test_data->dictionary_file); + td->dictionary_data_sz, td->dictionary_file); ret =0 ;
Signature · 1 line
2.48.1
RFC PATCH v2 24/33 app/test-crypto-perf: fix shadowed variable
In reply to Bruce RichardsonThe global variable iv_offset was shadowed by a local var. Rename the local variable to a shorter form to solve the issue.
--- app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
app/test-crypto-perf/cperf_test_pmd_cyclecount.c +2 -4
@@ -111,15 +111,13 @@ cperf_pmd_cyclecount_test_constructor(struct rte_mempool *sess_mp, ctx->test_vector = test_vector;/* IV goes at the end of the crypto operation */ -uint16_t iv_offset =sizeof (struct rte_crypto_op ) + -sizeof (struct rte_crypto_sym_op ); +uint16_t iv_ofs =sizeof (struct rte_crypto_op ) +sizeof (struct rte_crypto_sym_op );if (*sess !=NULL ) { ctx->sess = *sess; ctx->sess_owner = false; }else { - ctx->sess = op_fns->sess_create (sess_mp, dev_id, options, test_vector, - iv_offset); + ctx->sess = op_fns->sess_create (sess_mp, dev_id, options, test_vector, iv_ofs);if (ctx->sess ==NULL ) goto err; *sess = ctx->sess;
Signature · 1 line
2.48.1
RFC PATCH v2 25/33 app/test-dma-perf: renamed shadowed variable
In reply to Bruce RichardsonRename second instance of variable named "i" in load_configs() to avoid shadowing warnings.
--- app/test-dma-perf/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
app/test-dma-perf/main.c +4 -4
@@ -436,9 +436,9 @@ load_configs(const char *path) nb_vp++;char lc_dma[RTE_DEV_NAME_MAX_LEN ]; -int i =0 ; +int dma_id =0 ;while (1 ) { -snprintf (lc_dma,RTE_DEV_NAME_MAX_LEN ,"lcore_dma%d" , i); +snprintf (lc_dma,RTE_DEV_NAME_MAX_LEN ,"lcore_dma%d" , dma_id); lcore_dma =rte_cfgfile_get_entry (cfgfile, section_name, lc_dma);if (lcore_dma ==NULL )break ;
@@ -451,13 +451,13 @@ load_configs(const char *path) }if (rte_kvargs_process (kvlist,NULL , populate_dma_dev_config, - (void *)&test_case->dma_config[i]) <0 ) { + (void *)&test_case->dma_config[dma_id]) <0 ) {printf ("rte_kvargs_process() error\n" );rte_kvargs_free (kvlist); test_case->is_valid = false;break ; } - i++; + dma_id++; test_case->num_worker++;rte_kvargs_free (kvlist); }
Signature · 1 line
2.48.1
Re: [RFC PATCH v2 25/33] app/test-dma-perf: renamed shadowed variable
Quoted 4 lines · Bruce Richardson
Rename second instance of variable named "i" in
load_configs()to avoid shadowing warnings.Signed-off-by Bruce Richardson <[email protected]>
RFC PATCH v2 26/33 app/test-eventdev: fix build with shadow warnings enabled
In reply to Bruce RichardsonRename or remove shadowed variables to give a clean build with -Wshadow.
--- app/test-eventdev/evt_main.c | 6 +++--- app/test-eventdev/test_atomic_queue.c | 6 +++--- app/test-eventdev/test_perf_common.c | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-)
app/test-eventdev/evt_main.c +3 -3
@@ -30,11 +30,11 @@ signal_handler(int signum) }static inline void -evt_options_dump_all (struct evt_test *test,struct evt_options *opts) +evt_options_dump_all (struct evt_test *t,struct evt_options *opts) {evt_options_dump (opts); -if (test->ops.opt_dump) - test->ops.opt_dump (opts); +if (t->ops.opt_dump) + t->ops.opt_dump (opts); }int
app/test-eventdev/test_atomic_queue.c +3 -3
@@ -34,7 +34,7 @@ static inline void atomic_queue_process_stage_1(struct test_order *const t, struct rte_event *const ev, uint32_t nb_flows, - rte_spinlock_t *atomic_locks, + rte_spinlock_t *atomic_lks, uint32_t *const expected_flow_seq, RTE_ATOMIC(uint64_t) * const outstand_pkts, uint32_t port)
@@ -42,7 +42,7 @@ atomic_queue_process_stage_1(struct test_order *const t,const uint32_t flow = *order_mbuf_flow_id (t, ev->mbuf);const uint32_t seq = *order_mbuf_seqn (t, ev->mbuf); -atomic_lock_verify (atomic_locks,1 , flow, nb_flows, t, port); +atomic_lock_verify (atomic_lks,1 , flow, nb_flows, t, port);/* compare the seqn against expected value */ if (seq != expected_flow_seq[flow]) {
@@ -58,7 +58,7 @@ atomic_queue_process_stage_1(struct test_order *const t, ev->op =RTE_EVENT_OP_RELEASE ; -atomic_spinlock_unlock (atomic_locks,1 , flow, nb_flows); +atomic_spinlock_unlock (atomic_lks,1 , flow, nb_flows); } static int
app/test-eventdev/test_perf_common.c +1 -3
@@ -2131,12 +2131,10 @@ perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)void *sess;struct prod_data *p = &t->prod[port];uint32_t flow_id; -uint8_t cdev_id;for (flow_id =0 ; flow_id < t->nb_flows; flow_id++) { sess = p->ca.crypto_sess[flow_id]; - cdev_id = p->ca.cdev_id; -rte_cryptodev_sym_session_free (cdev_id, sess); +rte_cryptodev_sym_session_free (p->ca.cdev_id, sess); } rte_event_crypto_adapter_queue_pair_del(
Signature · 1 line
2.48.1
RFC PATCH v2 27/33 app/test-flow-perf: remove unneeded variable
In reply to Bruce RichardsonRemove an unnecessary second definition of a char * variable called "token" when processing commandline args.
--- app/test-flow-perf/main.c | 1 - 1 file changed, 1 deletion(-)
app/test-flow-perf/main.c +0 -1
@@ -916,7 +916,6 @@ args_parse(int argc, char **argv)if (strcmp (lgopts[opt_idx].name,"port-id" ) ==0 ) {uint16_t port_idx =0 ; -char *token; token =strtok (optarg,"," );while (token !=NULL ) {
Signature · 1 line
2.48.1
RFC PATCH v2 28/33 app/test-security-perf: fix build with shadow warnings
In reply to Bruce RichardsonRename variables to eliminate variable shadowing.
NOTE: The test-security-perf app reuses code from "dpdk-test" app, so some changes are made there too.
--- app/test-security-perf/test_security_perf.c | 42 ++++++++++----------- app/test/test_cryptodev_security_ipsec.c | 13 +++---- 2 files changed, 26 insertions(+), 29 deletions(-)
app/test-security-perf/test_security_perf.c +21 -21
@@ -43,7 +43,7 @@ struct test_ctx {bool is_inbound; }; -static struct test_ctx ctx; +static struct test_ctx test_ctx;static int cryptodev_init (struct test_ctx *ctx,uint8_t nb_lcores)
@@ -355,7 +355,7 @@ test_security_session_perf(void *arg) nb_sessions += (nb_sess_total - nb_sessions * nb_lcores); ret =sec_conf_init (conf, &sess_conf, &ipsec_xform, - &ctx.td[ctx.td_idx]); + &test_ctx.td[test_ctx.td_idx]);if (ret) {RTE_LOG (ERR ,USER1 ,"Could not initialize session conf\n" );return EXIT_FAILURE ;
@@ -447,14 +447,14 @@ args_parse(int argc, char **argv)if (strcmp (lgopts[opt_idx].name,"nb-sess" ) ==0 ) { n =atoi (optarg);if (n >=0 ) - ctx.nb_sess = n; + test_ctx.nb_sess = n;else rte_exit (EXIT_FAILURE ,"nb-sess should be >= 0\n" ); -printf ("nb-sess %d / " , ctx.nb_sess); +printf ("nb-sess %d / " , test_ctx.nb_sess); }else if (strcmp (lgopts[opt_idx].name,"inbound" ) ==0 ) { - ctx.is_inbound = true; + test_ctx.is_inbound = true;printf ("inbound / " ); }
@@ -482,7 +482,7 @@ main(int argc, char **argv)unsigned long i;int ret; -memset (&ctx,0 ,sizeof (struct test_ctx )); +memset (&test_ctx,0 ,sizeof (struct test_ctx ));memset (&flags,0 ,sizeof (flags)); ret =rte_eal_init (argc, argv);
@@ -498,18 +498,18 @@ main(int argc, char **argv)return -EINVAL ; } - ctx.nb_sess =DEF_NB_SESSIONS +RTE_MEMPOOL_CACHE_MAX_SIZE * nb_lcores; + test_ctx.nb_sess =DEF_NB_SESSIONS +RTE_MEMPOOL_CACHE_MAX_SIZE * nb_lcores;if (argc >1 )args_parse (argc, argv); - ctx.nb_lcores = nb_lcores; + test_ctx.nb_lcores = nb_lcores; - ret =cryptodev_init (&ctx, nb_lcores); + ret =cryptodev_init (&test_ctx, nb_lcores);if (ret) goto exit; - ret =mempool_init (&ctx, nb_lcores); + ret =mempool_init (&test_ctx, nb_lcores);if (ret) goto cryptodev_fini;
@@ -521,19 +521,19 @@ main(int argc, char **argv) &flags, &td_outb[i], 1); -if (ctx.is_inbound) +if (test_ctx.is_inbound)test_ipsec_td_in_from_out (&td_outb[i], &td_inb[i]); } - ctx.td = td_outb; -if (ctx.is_inbound) - ctx.td = td_inb; + test_ctx.td = td_outb; +if (test_ctx.is_inbound) + test_ctx.td = td_inb; -for (ctx.td_idx =0 ; ctx.td_idx <RTE_DIM (sec_alg_list); ctx.td_idx++) { +for (test_ctx.td_idx =0 ; test_ctx.td_idx <RTE_DIM (sec_alg_list); test_ctx.td_idx++) {printf ("\n\n Algorithm combination:" ); -test_sec_alg_display (sec_alg_list[ctx.td_idx].param1, - sec_alg_list[ctx.td_idx].param2); +test_sec_alg_display (sec_alg_list[test_ctx.td_idx].param1, + sec_alg_list[test_ctx.td_idx].param2);printf (" ----------------------" ); printf("\n%20s%20s%20s%20s%20s%20s\n\n",
@@ -545,7 +545,7 @@ main(int argc, char **argv) i =0 ;RTE_LCORE_FOREACH_WORKER (lcore_id) {rte_eal_remote_launch (test_security_session_perf, - &ctx.lconf[i], + &test_ctx.lconf[i], lcore_id); i++; }
@@ -556,12 +556,12 @@ main(int argc, char **argv) } -cryptodev_fini (&ctx); -mempool_fini (&ctx); +cryptodev_fini (&test_ctx); +mempool_fini (&test_ctx);return EXIT_SUCCESS ; cryptodev_fini: -cryptodev_fini (&ctx); +cryptodev_fini (&test_ctx); exit:return EXIT_FAILURE ;
app/test/test_cryptodev_security_ipsec.c +5 -8
@@ -264,11 +264,10 @@ test_ipsec_td_prepare(const struct crypto_param *param1, {struct ipsec_test_data *td; -int i;memset (td_array,0 , nb_td *sizeof (*td)); -for (i =0 ; i < nb_td; i++) { +for (int i =0 ; i < nb_td; i++) { td = &td_array[i];/* Prepare fields based on param */
@@ -339,7 +338,6 @@ test_ipsec_td_prepare(const struct crypto_param *param1,struct rte_tcp_hdr *tcp;int64_t payload_len;uint8_t *data; -int64_t i; payload_len =RTE_MIN (flags->plaintext_len,IPSEC_TEXT_MAX_LEN ); payload_len -=sizeof (struct rte_ipv6_hdr );
@@ -355,8 +353,8 @@ test_ipsec_td_prepare(const struct crypto_param *param1,/* TCP */ tcp = (struct rte_tcp_hdr *)(ip6 +1 ); data = (uint8_t *)(tcp +1 ); -for (i =0 ; i < payload_len; i++) - data[i] = i; +for (int64_t j =0 ; j < payload_len; j++) + data[j] = j; tcp->cksum =0 ; tcp->cksum =rte_ipv6_udptcp_cksum (ip6, tcp); td->input_text.len = payload_len + sizeof(struct rte_ipv6_hdr) +
@@ -366,7 +364,6 @@ test_ipsec_td_prepare(const struct crypto_param *param1,struct rte_tcp_hdr *tcp;int64_t payload_len;uint8_t *data; -int64_t i; payload_len =RTE_MIN (flags->plaintext_len,IPSEC_TEXT_MAX_LEN ); payload_len -=sizeof (struct rte_ipv4_hdr );
@@ -384,8 +381,8 @@ test_ipsec_td_prepare(const struct crypto_param *param1,/* TCP */ tcp = (struct rte_tcp_hdr *)(ip +1 ); data = (uint8_t *)(tcp +1 ); -for (i =0 ; i < payload_len; i++) - data[i] = i; +for (int64_t j =0 ; j < payload_len; j++) + data[j] = j; tcp->cksum =0 ; tcp->cksum =rte_ipv4_udptcp_cksum (ip, tcp); td->input_text.len = payload_len + sizeof(struct rte_ipv4_hdr) +
Signature · 1 line
2.48.1
RFC PATCH v2 29/33 app/test-pipeline: remove unnecessary variable
In reply to Bruce RichardsonThe second definition of a variable called "ret" in the main function is unnecessary and causes variable shadowing warnings, so just eliminate it.
--- app/test-pipeline/main.c | 1 - 1 file changed, 1 deletion(-)
app/test-pipeline/main.c +0 -1
@@ -89,7 +89,6 @@ main(int argc, char **argv)/* Close ports */ for (i =0 ; i < app.n_ports; i++) {uint16_t port; -int ret; port = app.ports[i];printf ("Closing port %d..." , port);
Signature · 1 line
2.48.1
RFC PATCH v2 30/33 drivers: disable variable shadowing warnings for drivers
In reply to Bruce RichardsonNot all drivers build cleanly with shadow warnings enabled, so disable them on a driver-by-driver basis for now.
--- config/meson.build | 5 +++++ drivers/baseband/fpga_5gnr_fec/meson.build | 2 ++ drivers/bus/fslmc/meson.build | 2 ++ drivers/common/cnxk/meson.build | 1 + drivers/common/qat/meson.build | 1 + drivers/compress/nitrox/meson.build | 2 ++ drivers/crypto/cnxk/meson.build | 1 + drivers/crypto/octeontx/meson.build | 1 + drivers/crypto/openssl/meson.build | 1 + drivers/crypto/scheduler/meson.build | 1 + drivers/dma/dpaa2/meson.build | 2 ++ drivers/event/cnxk/meson.build | 1 + drivers/event/dlb2/meson.build | 2 ++ drivers/event/sw/meson.build | 1 + drivers/net/axgbe/meson.build | 2 +- drivers/net/bnxt/meson.build | 1 + drivers/net/bonding/meson.build | 1 + drivers/net/cnxk/meson.build | 1 + drivers/net/cxgbe/meson.build | 1 + drivers/net/dpaa/meson.build | 1 + drivers/net/dpaa2/meson.build | 1 + drivers/net/ena/meson.build | 2 ++ drivers/net/enetfec/meson.build | 2 ++ drivers/net/enic/meson.build | 2 ++ drivers/net/failsafe/meson.build | 1 + drivers/net/mlx5/meson.build | 1 + drivers/net/ntnic/meson.build | 3 +++ drivers/net/pfe/meson.build | 3 +++ drivers/net/qede/meson.build | 3 +++ drivers/net/txgbe/meson.build | 1 + drivers/net/zxdh/meson.build | 3 +++ drivers/raw/ifpga/meson.build | 2 ++ drivers/vdpa/mlx5/meson.build | 1 + 33 files changed, 54 insertions(+), 1 deletion(-)
config/meson.build +5 -0
@@ -361,6 +361,11 @@ if cc.has_argument('-Wvla') endif endif +no_shadow_cflag = [] +if cc.has_argument('-Wno-shadow') + no_shadow_cflag = '-Wno-shadow' +endif + foreach arg: global_cflags if cc.has_argument(arg) add_project_arguments(arg, language: 'c')
drivers/baseband/fpga_5gnr_fec/meson.build +2 -0
@@ -3,6 +3,8 @@ deps += ['bus_vdev', 'ring', 'pci', 'bus_pci'] +cflags += no_shadow_cflag + sources = files('rte_fpga_5gnr_fec.c') headers = files('rte_pmd_fpga_5gnr_fec.h')
drivers/bus/fslmc/meson.build +2 -0
@@ -6,6 +6,8 @@ if not is_linux reason = 'only supported on Linux' endif +cflags += no_shadow_cflag + deps += ['common_dpaax', 'eventdev', 'kvargs'] sources = files( 'fslmc_bus.c',
drivers/common/cnxk/meson.build +1 -0
@@ -95,6 +95,7 @@ sources += files('cnxk_telemetry_bphy.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag if meson.is_cross_build() soc_type = meson.get_external_property('platform', '')
drivers/common/qat/meson.build +1 -0
@@ -104,6 +104,7 @@ if qat_compress endif cflags += no_wvla_cflag +cflags += no_shadow_cflag if qat_crypto foreach f: ['qat_sym.c', 'qat_sym_session.c',
drivers/compress/nitrox/meson.build +2 -0
@@ -8,6 +8,8 @@ endif deps += ['common_nitrox', 'bus_pci', 'compressdev'] +cflags += no_shadow_cflag + sources += files( 'nitrox_comp.c', 'nitrox_comp_reqmgr.c',
drivers/crypto/cnxk/meson.build +1 -0
@@ -34,6 +34,7 @@ deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev'] includes += include_directories('../../../lib/net', '../../event/cnxk') cflags += no_wvla_cflag +cflags += no_shadow_cflag if get_option('buildtype').contains('debug') cflags += [ '-DLA_IPSEC_DEBUG','-DCNXK_CRYPTODEV_DEBUG' ]
drivers/crypto/octeontx/meson.build +1 -0
@@ -34,3 +34,4 @@ includes += include_directories('../../mempool/octeontx') includes += include_directories('../../net/octeontx') cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/crypto/openssl/meson.build +1 -0
@@ -17,3 +17,4 @@ sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c') ext_deps += dep require_iova_in_mbuf = false cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/crypto/scheduler/meson.build +1 -0
@@ -24,3 +24,4 @@ headers = files( ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/dma/dpaa2/meson.build +2 -0
@@ -14,3 +14,5 @@ sources = files('dpaa2_qdma.c') if cc.has_argument('-Wno-pointer-arith') cflags += '-Wno-pointer-arith' endif + +cflags += no_shadow_cflag
drivers/event/cnxk/meson.build +1 -0
@@ -301,6 +301,7 @@ endif endif cflags += no_wvla_cflag +cflags += no_shadow_cflag extra_flags = ['-flax-vector-conversions', '-Wno-strict-aliasing'] if cc.get_id() == 'clang'
drivers/event/dlb2/meson.build +2 -0
@@ -29,6 +29,8 @@ headers = files('rte_pmd_dlb2.h') deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci'] +cflags += no_shadow_cflag + dlb_pmd_defines = ['-DDLB2_BYPASS_FENCE_ON_PP', '-DDLB_HW_CREDITS_CHECKS', '-DDLB_SW_CREDITS_CHECKS', '-DDLB_TYPE_CHECK'] dlb_pmd_default = ['0','1','1','1']
drivers/event/sw/meson.build +1 -0
@@ -11,3 +11,4 @@ sources = files( deps += ['hash', 'bus_vdev'] require_iova_in_mbuf = false cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/net/axgbe/meson.build +1 -1
@@ -15,7 +15,7 @@ sources = files( 'axgbe_rxtx.c', ) -cflags += '-Wno-cast-qual' +cflags += ['-Wno-cast-qual', no_shadow_cflag] if arch_subdir == 'x86' sources += files('axgbe_rxtx_vec_sse.c')
drivers/net/bnxt/meson.build +1 -0
@@ -13,6 +13,7 @@ if dpdk_conf.get('RTE_IOVA_IN_MBUF') == 0 endif cflags += no_wvla_cflag +cflags += no_shadow_cflag headers = files('rte_pmd_bnxt.h') cflags_options = [
drivers/net/bonding/meson.build +1 -0
@@ -26,3 +26,4 @@ headers = files('rte_eth_bond.h', 'rte_eth_bond_8023ad.h') require_iova_in_mbuf = false cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/net/cnxk/meson.build +1 -0
@@ -328,6 +328,7 @@ deps += ['bus_pci', 'cryptodev', 'eventdev', 'security'] deps += ['common_cnxk', 'mempool_cnxk'] cflags += no_wvla_cflag +cflags += no_shadow_cflag # Allow implicit vector conversions and strict aliasing warning extra_flags = ['-flax-vector-conversions', '-Wno-strict-aliasing']
drivers/net/cxgbe/meson.build +1 -0
@@ -25,3 +25,4 @@ sources = files( includes += include_directories('base') cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/net/dpaa/meson.build +1 -0
@@ -18,6 +18,7 @@ sources = files( ) cflags += no_wvla_cflag +cflags += no_shadow_cflag if cc.has_argument('-Wno-pointer-arith') cflags += '-Wno-pointer-arith'
drivers/net/dpaa2/meson.build +1 -0
@@ -29,3 +29,4 @@ includes += include_directories('base', 'mc') headers = files('rte_pmd_dpaa2.h') cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/net/ena/meson.build +2 -0
@@ -17,3 +17,5 @@ sources = files( deps += ['timer'] includes += include_directories('base', 'base/ena_defs') + +cflags += no_shadow_cflag
drivers/net/enetfec/meson.build +2 -0
@@ -11,3 +11,5 @@ sources = files( 'enet_uio.c', 'enet_rxtx.c', ) + +cflags += no_shadow_cflag
drivers/net/enic/meson.build +2 -0
@@ -29,6 +29,8 @@ sources = files( deps += ['hash'] includes += include_directories('base') +cflags += no_shadow_cflag + if dpdk_conf.has('RTE_ARCH_X86_64') cflags += '-DENIC_RXTX_VEC' sources_avx2 += files('enic_rxtx_vec_avx2.c')
drivers/net/failsafe/meson.build +1 -0
@@ -8,6 +8,7 @@ if is_windows endif cflags += no_wvla_cflag +cflags += no_shadow_cflag cflags += '-D_DEFAULT_SOURCE' cflags += '-D_XOPEN_SOURCE=700' cflags += '-pedantic'
drivers/net/mlx5/meson.build +1 -0
@@ -90,6 +90,7 @@ if get_option('buildtype').contains('debug') else cflags += [ '-UPEDANTIC' ] endif +cflags += no_shadow_cflag require_iova_in_mbuf = false
drivers/net/ntnic/meson.build +3 -0
@@ -128,3 +128,6 @@ sources = files( 'ntnic_ethdev.c', 'rte_pmd_ntnic.c', ) + +# Suppress shadow warnings for this driver due to extensive variable shadowing +cflags += no_shadow_cflag
drivers/net/pfe/meson.build +3 -0
@@ -18,4 +18,7 @@ if cc.has_argument('-Wno-pointer-arith') cflags += '-Wno-pointer-arith' endif +# Suppress shadow warnings for this driver +cflags += no_shadow_cflag + includes += include_directories('base')
drivers/net/qede/meson.build +3 -0
@@ -22,3 +22,6 @@ sources = files( if cc.has_argument('-Wno-format-nonliteral') cflags += '-Wno-format-nonliteral' endif + +# Suppress shadow warnings for this driver +cflags += no_shadow_cflag
drivers/net/txgbe/meson.build +1 -0
@@ -24,6 +24,7 @@ sources = files( deps += ['hash', 'security'] cflags += no_wvla_cflag +cflags += no_shadow_cflag if arch_subdir == 'x86' sources += files('txgbe_rxtx_vec_sse.c')
drivers/net/zxdh/meson.build +3 -0
@@ -20,3 +20,6 @@ sources = files( 'zxdh_mtr.c', 'zxdh_flow.c', ) + +# Suppress shadow warnings for this driver +cflags += no_shadow_cflag
drivers/raw/ifpga/meson.build +2 -0
@@ -19,6 +19,8 @@ endif ext_deps += rtdep +cflags += no_shadow_cflag + subdir('base') deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
drivers/vdpa/mlx5/meson.build +1 -0
@@ -24,6 +24,7 @@ sources = files( ) cflags += no_wvla_cflag +cflags += no_shadow_cflag cflags_options = [ '-std=c11',
Signature · 1 line
2.48.1
RFC PATCH v2 31/33 app/test: disable shadowing warnings for unit tests
In reply to Bruce RichardsonThe dpdk-test binary has multiple issues with variable shadowing. For now, explicitly ignore shadowing warnings in this app.
--- app/test/meson.build | 1 + 1 file changed, 1 insertion(+)
app/test/meson.build +1 -0
@@ -256,6 +256,7 @@ foreach d:optional_deps endforeach cflags += no_wvla_cflag +cflags += no_shadow_cflag extra_flags = [ # Strict-aliasing rules are violated by uint8_t[] to context size casts.
Signature · 1 line
2.48.1
RFC PATCH v2 32/33 examples: ignore variable shadowing warnings
In reply to Bruce RichardsonFor examples which don't compile with -Wshadow, explicitly disable those warnings.
--- examples/bbdev_app/meson.build | 1 + examples/bond/meson.build | 1 + examples/dma/meson.build | 1 + examples/ethtool/meson.build | 1 + examples/eventdev_pipeline/meson.build | 1 + examples/flow_filtering/meson.build | 1 + examples/ip_pipeline/meson.build | 1 + examples/ipsec-secgw/meson.build | 1 + examples/l2fwd-crypto/meson.build | 1 + examples/l2fwd-event/meson.build | 1 + examples/l2fwd-jobstats/meson.build | 1 + examples/l2fwd-keepalive/meson.build | 1 + examples/l3fwd-graph/meson.build | 1 + examples/l3fwd-power/meson.build | 1 + examples/l3fwd/meson.build | 1 + examples/multi_process/client_server_mp/mp_server/meson.build | 1 + examples/packet_ordering/meson.build | 1 + examples/ptpclient/meson.build | 1 + examples/qos_sched/meson.build | 1 + examples/server_node_efd/efd_server/meson.build | 1 + examples/vhost/meson.build | 1 + examples/vm_power_manager/guest_cli/meson.build | 1 + examples/vm_power_manager/meson.build | 1 + examples/vmdq/meson.build | 1 + 24 files changed, 24 insertions(+)
examples/bbdev_app/meson.build +1 -0
@@ -11,3 +11,4 @@ allow_experimental_apis = true sources = files( 'main.c', ) +cflags += no_shadow_cflag
examples/bond/meson.build +1 -0
@@ -11,6 +11,7 @@ allow_experimental_apis = true sources = files( 'main.c', ) +cflags += no_shadow_cflag cmd_h = custom_target('commands_hdr', output: 'commands.h',
examples/dma/meson.build +1 -0
@@ -13,3 +13,4 @@ deps += ['argparse', 'dmadev'] sources = files( 'dmafwd.c', ) +cflags += no_shadow_cflag
examples/ethtool/meson.build +1 -0
@@ -17,6 +17,7 @@ sources = files( 'ethtool-app/main.c', ) includes = include_directories('lib', 'ethtool-app') +cflags += no_shadow_cflag deps += 'bus_pci' if dpdk_conf.has('RTE_NET_IXGBE')
examples/eventdev_pipeline/meson.build +1 -0
@@ -13,3 +13,4 @@ sources = files( 'pipeline_worker_generic.c', 'pipeline_worker_tx.c', ) +cflags += no_shadow_cflag
examples/flow_filtering/meson.build +1 -0
@@ -25,3 +25,4 @@ sources = files( # The code snippets are not utilized. cflags += '-Wno-unused-function' +cflags += no_shadow_cflag
examples/ip_pipeline/meson.build +1 -0
@@ -28,3 +28,4 @@ sources = files( 'thread.c', 'tmgr.c', ) +cflags += no_shadow_cflag
examples/ipsec-secgw/meson.build +1 -0
@@ -25,6 +25,7 @@ sources = files( ) cflags += no_wvla_cflag +cflags += no_shadow_cflag app_cflags = ['-Wno-address-of-packed-member'] foreach flag:app_cflags
examples/l2fwd-crypto/meson.build +1 -0
@@ -15,3 +15,4 @@ sources = files( 'main.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/l2fwd-event/meson.build +1 -0
@@ -17,3 +17,4 @@ sources = files( 'l2fwd_event_internal_port.c', 'l2fwd_poll.c', ) +cflags += no_shadow_cflag
examples/l2fwd-jobstats/meson.build +1 -0
@@ -12,3 +12,4 @@ sources = files( 'main.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/l2fwd-keepalive/meson.build +1 -0
@@ -19,3 +19,4 @@ sources = files( 'main.c', 'shm.c', ) +cflags += no_shadow_cflag
examples/l3fwd-graph/meson.build +1 -0
@@ -11,3 +11,4 @@ sources = files( 'main.c', ) allow_experimental_apis = true +cflags += no_shadow_cflag
examples/l3fwd-power/meson.build +1 -0
@@ -13,3 +13,4 @@ sources = files( 'perf_core.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/l3fwd/meson.build +1 -0
@@ -22,3 +22,4 @@ if dpdk_conf.has('RTE_LIB_EVENTDEV') deps += 'eventdev' endif cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/multi_process/client_server_mp/mp_server/meson.build +1 -0
@@ -14,3 +14,4 @@ sources = files( 'init.c', 'main.c', ) +cflags += no_shadow_cflag
examples/packet_ordering/meson.build +1 -0
@@ -11,3 +11,4 @@ deps += 'reorder' sources = files( 'main.c', ) +cflags += no_shadow_cflag
examples/ptpclient/meson.build +1 -0
@@ -10,3 +10,4 @@ allow_experimental_apis = true sources = files( 'ptpclient.c', ) +cflags += no_shadow_cflag
examples/qos_sched/meson.build +1 -0
@@ -18,3 +18,4 @@ sources = files( 'stats.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/server_node_efd/efd_server/meson.build +1 -0
@@ -10,3 +10,4 @@ allow_experimental_apis = true deps += 'efd' sources += files('args.c', 'init.c', 'main.c') includes += include_directories('../shared') +cflags += no_shadow_cflag
examples/vhost/meson.build +1 -0
@@ -19,3 +19,4 @@ sources = files( 'virtio_net.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/vm_power_manager/guest_cli/meson.build +1 -0
@@ -13,6 +13,7 @@ sources = files( 'parse.c', 'vm_power_cli_guest.c', ) +cflags += no_shadow_cflag allow_experimental_apis = true
examples/vm_power_manager/meson.build +1 -0
@@ -29,6 +29,7 @@ sources = files( 'power_manager.c', 'vm_power_cli.c', ) +cflags += no_shadow_cflag # If we're on X86, pull in the x86 code for the branch monitor algo. if dpdk_conf.has('RTE_ARCH_X86_64')
examples/vmdq/meson.build +1 -0
@@ -10,3 +10,4 @@ allow_experimental_apis = true sources = files( 'main.c', ) +cflags += no_shadow_cflag
Signature · 1 line
2.48.1
Re: [RFC PATCH v2 32/33] examples: ignore variable shadowing warnings
Quoted 4 lines · Bruce Richardson
For examples which don't compile with -Wshadow, explicitly disable those warnings.
Signed-off-by Bruce Richardson <[email protected]>
RFC PATCH v2 33/33 build: enable shadowed variable warnings
In reply to Bruce RichardsonEnable -Wshadow globally for DPDK builds.
--- config/meson.build | 1 + 1 file changed, 1 insertion(+)
config/meson.build +1 -0
@@ -329,6 +329,7 @@ global_cflags = [ '-Wnested-externs', '-Wold-style-definition', '-Wpointer-arith', + '-Wshadow', '-Wsign-compare', '-Wstrict-prototypes', '-Wundef',
Signature · 1 line
2.48.1
Re: [RFC PATCH v2 33/33] build: enable shadowed variable warnings
Quoted 3 lines · Bruce Richardson
Enable -Wshadow globally for DPDK builds.
Signed-off-by Bruce Richardson <[email protected]>
Re: [RFC PATCH v2 00/33] build DPDK with -Wshadow
In reply to Bruce RichardsonQuoted 179 lines · On Fri, 7 Nov 2025 15:49:56 +0000 Bruce Richardson…
As flagged in bugs #1742, #1743 and others, much of DPDK fails to build when -Wshadow flag is passed to the build. This patchset fixes many issues of this nature, but not all, in the hopes we can move towards enabling that warning flag for all components for DPDK in future. This patchset fixes the following components in DPDK:
* all libraries
* Intel net drivers
* all apps in the "app" folderFor the rest of the drivers and example applications, any component which does not build successfully with the shadow warning enabled has it explicitly disabled via cflags. Then the last patch adds -Wshadow to the global DPDK build, which should prevent any regressions in components which are already working.
At that point, we should not have any regressions and we can, over time, reduce the number of components needing the -Wno-shadow flag.
RFC v2:
* take patch from Stephen for RTE_MIN/MAX fixes
* add additional fixes to clear clang warnings - it's a lot stricter than gcc in this regard, and flags more issues.
* extend app cleanup to all apps, not just testpmd
* add per-component disabling, and add global enable flag at the end.Bruce Richardson (32):
eal: fix variable shadowing
ethdev: fix variable shadowing issues
eventdev: fix variable shadowing issues
net: remove shadowed variable
pipeline: fix variable shadowing
table: fix issues with variable shadowing
power: rename variable to eliminate shadowing
pcapng: rename variable to fix shadowing
telemetry: make socket handler typedef private
bbdev: fix variable shadowing
bus/pci: remove shadowed variables
net/intel: rename function param to avoid shadow warnings net/e1000: fix build with shadow warnings enabled net/i40e: fix build with shadow warnings enabled net/ice: fix build with shadow warnings enabled net/cpfl: fix build with shadow warnings enabled net/ixgbe: fix build with shadow warnings enabled app/test-pmd: fix build with shadow warnings enabled app/graph: fix build with shadow warnings enabled app/pdump: fix warning about shadowed variable app/test-bbdev: useRTE_MAX3to remove variable shadowing app/test-compress-perf: fix variable shadowing app/test-crypto-perf: fix shadowed variable app/test-dma-perf: renamed shadowed variable app/test-eventdev: fix build with shadow warnings enabled app/test-flow-perf: remove unneeded variable app/test-security-perf: fix build with shadow warnings app/test-pipeline: remove unnecessary variable
drivers: disable variable shadowing warnings for drivers app/test: disable shadowing warnings for unit tests
examples: ignore variable shadowing warnings
build: enable shadowed variable warningsStephen Hemminger (1):
eal: add more min/max helpersapp/graph/conn.c | 134 +++++++++--------- app/pdump/main.c | 12 +- app/test-bbdev/test_bbdev_perf.c | 7 +- app/test-compress-perf/main.c | 122 ++++++++-------- .../cperf_test_pmd_cyclecount.c | 6 +- app/test-dma-perf/main.c | 8 +- app/test-eventdev/evt_main.c | 6 +- app/test-eventdev/test_atomic_queue.c | 6 +- app/test-eventdev/test_perf_common.c | 4 +- app/test-flow-perf/main.c | 1 - app/test-pipeline/main.c | 1 - app/test-pmd/cmdline_flow.c | 42 +++--- app/test-pmd/config.c | 15 +- app/test-pmd/parameters.c | 38 +++-- app/test-pmd/testpmd.c | 2 +- app/test-security-perf/test_security_perf.c | 42 +++--- app/test/meson.build | 1 + app/test/test_cryptodev_security_ipsec.c | 13 +- config/meson.build | 6 + drivers/baseband/fpga_5gnr_fec/meson.build | 2 + drivers/bus/fslmc/meson.build | 2 + drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- drivers/bus/pci/windows/pci.c | 1 - drivers/common/cnxk/meson.build | 1 + drivers/common/qat/meson.build | 1 + drivers/compress/nitrox/meson.build | 2 + drivers/crypto/cnxk/meson.build | 1 + drivers/crypto/octeontx/meson.build | 1 + drivers/crypto/openssl/meson.build | 1 + drivers/crypto/scheduler/meson.build | 1 + drivers/dma/dpaa2/meson.build | 2 + drivers/event/cnxk/meson.build | 1 + drivers/event/dlb2/meson.build | 2 + drivers/event/sw/meson.build | 1 + drivers/net/axgbe/meson.build | 2 +- drivers/net/bnxt/meson.build | 1 + drivers/net/bonding/meson.build | 1 + drivers/net/cnxk/meson.build | 1 + drivers/net/cxgbe/meson.build | 1 + drivers/net/dpaa/meson.build | 1 + drivers/net/dpaa2/meson.build | 1 + drivers/net/ena/meson.build | 2 + drivers/net/enetfec/meson.build | 2 + drivers/net/enic/meson.build | 2 + drivers/net/failsafe/meson.build | 1 + drivers/net/intel/common/rx.h | 6 +- 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 +- drivers/net/intel/e1000/igc_ethdev.c | 6 +- drivers/net/intel/i40e/i40e_ethdev.h | 10 +- drivers/net/intel/ice/ice_ethdev.c | 6 +- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +- drivers/net/mlx5/meson.build | 1 + drivers/net/ntnic/meson.build | 3 + drivers/net/pfe/meson.build | 3 + drivers/net/qede/meson.build | 3 + drivers/net/txgbe/meson.build | 1 + drivers/net/zxdh/meson.build | 3 + drivers/raw/ifpga/meson.build | 2 + drivers/vdpa/mlx5/meson.build | 1 + examples/bbdev_app/meson.build | 1 + examples/bond/meson.build | 1 + examples/dma/meson.build | 1 + examples/ethtool/meson.build | 1 + examples/eventdev_pipeline/meson.build | 1 + examples/flow_filtering/meson.build | 1 + examples/ip_pipeline/meson.build | 1 + examples/ipsec-secgw/meson.build | 1 + examples/l2fwd-crypto/meson.build | 1 + examples/l2fwd-event/meson.build | 1 + examples/l2fwd-jobstats/meson.build | 1 + examples/l2fwd-keepalive/meson.build | 1 + examples/l3fwd-graph/meson.build | 1 + examples/l3fwd-power/meson.build | 1 + examples/l3fwd/meson.build | 1 + .../client_server_mp/mp_server/meson.build | 1 + examples/packet_ordering/meson.build | 1 + examples/ptpclient/meson.build | 1 + examples/qos_sched/meson.build | 1 + .../server_node_efd/efd_server/meson.build | 1 + examples/vhost/meson.build | 1 + .../vm_power_manager/guest_cli/meson.build | 1 + examples/vm_power_manager/meson.build | 1 + examples/vmdq/meson.build | 1 + lib/bbdev/rte_bbdev.c | 2 +- lib/eal/common/eal_common_options.c | 22 +-- lib/eal/common/eal_common_trace.c | 89 ++++++------ lib/eal/common/malloc_heap.c | 2 +- lib/eal/include/rte_common.h | 31 +++- lib/ethdev/ethdev_driver.c | 6 +- lib/ethdev/rte_ethdev.c | 1 - lib/eventdev/rte_event_eth_rx_adapter.c | 5 +- lib/eventdev/rte_event_eth_tx_adapter.c | 8 +- lib/net/net_crc_avx512.c | 4 +- lib/pcapng/rte_pcapng.c | 7 +- lib/pipeline/rte_swx_ctl.c | 11 +- lib/pipeline/rte_swx_pipeline.c | 21 ++- lib/pipeline/rte_swx_pipeline_internal.h | 10 +- lib/power/rte_power_pmd_mgmt.c | 6 +- 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 +- lib/telemetry/rte_telemetry.h | 11 -- lib/telemetry/telemetry.c | 2 +- lib/telemetry/telemetry_internal.h | 11 ++ 113 files changed, 489 insertions(+), 425 deletions(-)
Quoted 3 lines
--
2.48.1
Thanks we may want to wait this series until 26.03 release
Re: [RFC PATCH v2 00/33] build DPDK with -Wshadow
Quoted 182 lines · Stephen Hemminger
Quoted 179 lines · On Fri, 7 Nov 2025 15:49:56 +0000 Bruce Richardson…
As flagged in bugs #1742, #1743 and others, much of DPDK fails to build when -Wshadow flag is passed to the build. This patchset fixes many issues of this nature, but not all, in the hopes we can move towards enabling that warning flag for all components for DPDK in future. This patchset fixes the following components in DPDK:
* all libraries
* Intel net drivers
* all apps in the "app" folderFor the rest of the drivers and example applications, any component which does not build successfully with the shadow warning enabled has it explicitly disabled via cflags. Then the last patch adds -Wshadow to the global DPDK build, which should prevent any regressions in components which are already working.
At that point, we should not have any regressions and we can, over time, reduce the number of components needing the -Wno-shadow flag.
RFC v2:
* take patch from Stephen for RTE_MIN/MAX fixes
* add additional fixes to clear clang warnings - it's a lot stricter than gcc in this regard, and flags more issues.
* extend app cleanup to all apps, not just testpmd
* add per-component disabling, and add global enable flag at the end.Bruce Richardson (32):
eal: fix variable shadowing
ethdev: fix variable shadowing issues
eventdev: fix variable shadowing issues
net: remove shadowed variable
pipeline: fix variable shadowing
table: fix issues with variable shadowing
power: rename variable to eliminate shadowing
pcapng: rename variable to fix shadowing
telemetry: make socket handler typedef private
bbdev: fix variable shadowing
bus/pci: remove shadowed variables
net/intel: rename function param to avoid shadow warnings net/e1000: fix build with shadow warnings enabled net/i40e: fix build with shadow warnings enabled net/ice: fix build with shadow warnings enabled net/cpfl: fix build with shadow warnings enabled net/ixgbe: fix build with shadow warnings enabled app/test-pmd: fix build with shadow warnings enabled app/graph: fix build with shadow warnings enabled app/pdump: fix warning about shadowed variable app/test-bbdev: useRTE_MAX3to remove variable shadowing app/test-compress-perf: fix variable shadowing app/test-crypto-perf: fix shadowed variable app/test-dma-perf: renamed shadowed variable app/test-eventdev: fix build with shadow warnings enabled app/test-flow-perf: remove unneeded variable app/test-security-perf: fix build with shadow warnings app/test-pipeline: remove unnecessary variable
drivers: disable variable shadowing warnings for drivers app/test: disable shadowing warnings for unit tests
examples: ignore variable shadowing warnings
build: enable shadowed variable warningsStephen Hemminger (1):
eal: add more min/max helpersapp/graph/conn.c | 134 +++++++++--------- app/pdump/main.c | 12 +- app/test-bbdev/test_bbdev_perf.c | 7 +- app/test-compress-perf/main.c | 122 ++++++++-------- .../cperf_test_pmd_cyclecount.c | 6 +- app/test-dma-perf/main.c | 8 +- app/test-eventdev/evt_main.c | 6 +- app/test-eventdev/test_atomic_queue.c | 6 +- app/test-eventdev/test_perf_common.c | 4 +- app/test-flow-perf/main.c | 1 - app/test-pipeline/main.c | 1 - app/test-pmd/cmdline_flow.c | 42 +++--- app/test-pmd/config.c | 15 +- app/test-pmd/parameters.c | 38 +++-- app/test-pmd/testpmd.c | 2 +- app/test-security-perf/test_security_perf.c | 42 +++--- app/test/meson.build | 1 + app/test/test_cryptodev_security_ipsec.c | 13 +- config/meson.build | 6 + drivers/baseband/fpga_5gnr_fec/meson.build | 2 + drivers/bus/fslmc/meson.build | 2 + drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- drivers/bus/pci/windows/pci.c | 1 - drivers/common/cnxk/meson.build | 1 + drivers/common/qat/meson.build | 1 + drivers/compress/nitrox/meson.build | 2 + drivers/crypto/cnxk/meson.build | 1 + drivers/crypto/octeontx/meson.build | 1 + drivers/crypto/openssl/meson.build | 1 + drivers/crypto/scheduler/meson.build | 1 + drivers/dma/dpaa2/meson.build | 2 + drivers/event/cnxk/meson.build | 1 + drivers/event/dlb2/meson.build | 2 + drivers/event/sw/meson.build | 1 + drivers/net/axgbe/meson.build | 2 +- drivers/net/bnxt/meson.build | 1 + drivers/net/bonding/meson.build | 1 + drivers/net/cnxk/meson.build | 1 + drivers/net/cxgbe/meson.build | 1 + drivers/net/dpaa/meson.build | 1 + drivers/net/dpaa2/meson.build | 1 + drivers/net/ena/meson.build | 2 + drivers/net/enetfec/meson.build | 2 + drivers/net/enic/meson.build | 2 + drivers/net/failsafe/meson.build | 1 + drivers/net/intel/common/rx.h | 6 +- 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 +- drivers/net/intel/e1000/igc_ethdev.c | 6 +- drivers/net/intel/i40e/i40e_ethdev.h | 10 +- drivers/net/intel/ice/ice_ethdev.c | 6 +- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +- drivers/net/mlx5/meson.build | 1 + drivers/net/ntnic/meson.build | 3 + drivers/net/pfe/meson.build | 3 + drivers/net/qede/meson.build | 3 + drivers/net/txgbe/meson.build | 1 + drivers/net/zxdh/meson.build | 3 + drivers/raw/ifpga/meson.build | 2 + drivers/vdpa/mlx5/meson.build | 1 + examples/bbdev_app/meson.build | 1 + examples/bond/meson.build | 1 + examples/dma/meson.build | 1 + examples/ethtool/meson.build | 1 + examples/eventdev_pipeline/meson.build | 1 + examples/flow_filtering/meson.build | 1 + examples/ip_pipeline/meson.build | 1 + examples/ipsec-secgw/meson.build | 1 + examples/l2fwd-crypto/meson.build | 1 + examples/l2fwd-event/meson.build | 1 + examples/l2fwd-jobstats/meson.build | 1 + examples/l2fwd-keepalive/meson.build | 1 + examples/l3fwd-graph/meson.build | 1 + examples/l3fwd-power/meson.build | 1 + examples/l3fwd/meson.build | 1 + .../client_server_mp/mp_server/meson.build | 1 + examples/packet_ordering/meson.build | 1 + examples/ptpclient/meson.build | 1 + examples/qos_sched/meson.build | 1 + .../server_node_efd/efd_server/meson.build | 1 + examples/vhost/meson.build | 1 + .../vm_power_manager/guest_cli/meson.build | 1 + examples/vm_power_manager/meson.build | 1 + examples/vmdq/meson.build | 1 + lib/bbdev/rte_bbdev.c | 2 +- lib/eal/common/eal_common_options.c | 22 +-- lib/eal/common/eal_common_trace.c | 89 ++++++------ lib/eal/common/malloc_heap.c | 2 +- lib/eal/include/rte_common.h | 31 +++- lib/ethdev/ethdev_driver.c | 6 +- lib/ethdev/rte_ethdev.c | 1 - lib/eventdev/rte_event_eth_rx_adapter.c | 5 +- lib/eventdev/rte_event_eth_tx_adapter.c | 8 +- lib/net/net_crc_avx512.c | 4 +- lib/pcapng/rte_pcapng.c | 7 +- lib/pipeline/rte_swx_ctl.c | 11 +- lib/pipeline/rte_swx_pipeline.c | 21 ++- lib/pipeline/rte_swx_pipeline_internal.h | 10 +- lib/power/rte_power_pmd_mgmt.c | 6 +- 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 +- lib/telemetry/rte_telemetry.h | 11 -- lib/telemetry/telemetry.c | 2 +- lib/telemetry/telemetry_internal.h | 11 ++ 113 files changed, 489 insertions(+), 425 deletions(-)
Quoted 6 lines
Quoted 3 lines
--
2.48.1Thanks we may want to wait this series until 26.03 release
Series-Acked-by Stephen Hemminger <[email protected]>
Yes, absolutely, which is why it's still down as an RFC. I've also already marked it as deferred in patchwork.
However, I also wanted to get it out early so that it can be considered for early merge in 26.03 to avoid later problems with new shadowing issues being introduced in 26.03, and also to get build checks from the CI, since I can't test the build of every single driver on my system (thankfully there are only about a half a dozen which I can't build).
/Bruce
v3 cover build DPDK with Wshadow flag
In reply to Bruce RichardsonAs flagged in bugs #1742, #1743 and others, much of DPDK fails to build when -Wshadow flag is passed to the build. This patchset fixes many issues of this nature, but not all, in the hopes we can move towards enabling that warning flag for all components for DPDK in future. This patchset fixes the following components in DPDK:
* all libraries
* Intel net drivers
* all apps in the "app" folder
For the rest of the drivers and example applications, any component which does not build successfully with the shadow warning enabled has it explicitly disabled via cflags. Then the last patch adds -Wshadow to the global DPDK build, which should prevent any regressions in components which are already working.
At that point, we should not have any regressions and we can, over time, reduce the number of components needing the -Wno-shadow flag.
v3:
* rebase on 25.11 release.
RFC v2:
* take patch from Stephen for RTE_MIN/MAX fixes
* add additional fixes to clear clang warnings - it's a lot stricter than gcc in this regard, and flags more issues.
* extend app cleanup to all apps, not just testpmd
* add per-component disabling, and add global enable flag at the end.
Bruce Richardson (30):
eal: fix variable shadowing
ethdev: fix variable shadowing issues
eventdev: fix variable shadowing issues
net: remove shadowed variable
pipeline: fix variable shadowing
table: fix issues with variable shadowing
power: rename variable to eliminate shadowing
pcapng: rename variable to fix shadowing
bbdev: fix variable shadowing
bus/pci: remove shadowed variables
net/intel: rename function param to avoid shadow warnings net/e1000: fix build with shadow warnings enabled net/i40e: fix build with shadow warnings enabled net/ice: fix build with shadow warnings enabled net/cpfl: fix build with shadow warnings enabled net/ixgbe: fix build with shadow warnings enabled app/testpmd: fix build with shadow warnings enabled app/graph: fix build with shadow warnings enabled app/pdump: fix warning about shadowed variable app/test-bbdev: remove shadow warning from next max calls app/test-compress-perf: rename local vars to fix shadowing app/test-crypto-perf: rename local vars to fix shadowing app/test-eventdev: fix build with shadow warnings enabled app/test-flow-perf: remove unneeded variable app/test-security-perf: fix build with shadow warnings app/test-pipeline: remove unnecessary variable
drivers: disable variable shadowing warnings for drivers app/test: disable shadowing warnings for unit tests
examples: ignore variable shadowing warnings
build: enable shadowed variable warnings
Stephen Hemminger (1):
eal: add more min/max helpers
app/graph/conn.c | 134 +++++++++--------- app/pdump/main.c | 12 +- app/test-bbdev/test_bbdev_perf.c | 7 +- app/test-compress-perf/main.c | 122 ++++++++-------- .../cperf_test_pmd_cyclecount.c | 6 +- app/test-eventdev/evt_main.c | 6 +- app/test-eventdev/test_atomic_queue.c | 6 +- app/test-eventdev/test_perf_common.c | 4 +- app/test-flow-perf/main.c | 1 - app/test-pipeline/main.c | 1 - app/test-pmd/cmdline_flow.c | 42 +++--- app/test-pmd/config.c | 15 +- app/test-pmd/parameters.c | 38 +++-- app/test-pmd/testpmd.c | 2 +- app/test-security-perf/test_security_perf.c | 42 +++--- app/test/meson.build | 1 + app/test/test_cryptodev_security_ipsec.c | 13 +- config/meson.build | 6 + drivers/baseband/fpga_5gnr_fec/meson.build | 2 + drivers/bus/fslmc/meson.build | 2 + drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- drivers/bus/pci/windows/pci.c | 1 - drivers/common/cnxk/meson.build | 1 + drivers/common/qat/meson.build | 1 + drivers/compress/nitrox/meson.build | 2 + drivers/crypto/cnxk/meson.build | 1 + drivers/crypto/octeontx/meson.build | 1 + drivers/crypto/openssl/meson.build | 1 + drivers/crypto/scheduler/meson.build | 1 + drivers/dma/dpaa2/meson.build | 2 + drivers/event/cnxk/meson.build | 1 + drivers/event/dlb2/meson.build | 2 + drivers/event/sw/meson.build | 1 + drivers/net/axgbe/meson.build | 2 +- drivers/net/bnxt/meson.build | 1 + drivers/net/bonding/meson.build | 1 + drivers/net/cnxk/meson.build | 1 + drivers/net/cxgbe/meson.build | 1 + drivers/net/dpaa/meson.build | 1 + drivers/net/dpaa2/meson.build | 1 + drivers/net/ena/meson.build | 2 + drivers/net/enetfec/meson.build | 2 + drivers/net/enic/meson.build | 2 + drivers/net/failsafe/meson.build | 1 + drivers/net/intel/common/rx.h | 6 +- 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 +- drivers/net/intel/e1000/igc_ethdev.c | 6 +- drivers/net/intel/i40e/i40e_ethdev.h | 10 +- drivers/net/intel/ice/ice_ethdev.c | 6 +- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +- drivers/net/mlx5/meson.build | 1 + drivers/net/ntnic/meson.build | 3 + drivers/net/pfe/meson.build | 3 + drivers/net/qede/meson.build | 3 + drivers/net/txgbe/meson.build | 1 + drivers/net/zxdh/meson.build | 3 + drivers/raw/ifpga/meson.build | 2 + drivers/vdpa/mlx5/meson.build | 1 + examples/bbdev_app/meson.build | 1 + examples/bond/meson.build | 1 + examples/dma/meson.build | 1 + examples/ethtool/meson.build | 1 + examples/eventdev_pipeline/meson.build | 1 + examples/flow_filtering/meson.build | 1 + examples/ip_pipeline/meson.build | 1 + examples/ipsec-secgw/meson.build | 1 + examples/l2fwd-crypto/meson.build | 1 + examples/l2fwd-event/meson.build | 1 + examples/l2fwd-jobstats/meson.build | 1 + examples/l2fwd-keepalive/meson.build | 1 + examples/l3fwd-graph/meson.build | 1 + examples/l3fwd-power/meson.build | 1 + examples/l3fwd/meson.build | 1 + .../client_server_mp/mp_server/meson.build | 1 + examples/packet_ordering/meson.build | 1 + examples/ptpclient/meson.build | 1 + examples/qos_sched/meson.build | 1 + .../server_node_efd/efd_server/meson.build | 1 + examples/vhost/meson.build | 1 + .../vm_power_manager/guest_cli/meson.build | 1 + examples/vm_power_manager/meson.build | 1 + examples/vmdq/meson.build | 1 + lib/bbdev/rte_bbdev.c | 2 +- lib/eal/common/eal_common_options.c | 22 +-- lib/eal/common/eal_common_trace.c | 89 ++++++------ lib/eal/common/malloc_heap.c | 2 +- lib/eal/include/rte_common.h | 31 +++- lib/ethdev/ethdev_driver.c | 6 +- lib/ethdev/rte_ethdev.c | 1 - lib/eventdev/rte_event_eth_rx_adapter.c | 5 +- lib/eventdev/rte_event_eth_tx_adapter.c | 8 +- lib/net/net_crc_avx512.c | 4 +- lib/pcapng/rte_pcapng.c | 7 +- lib/pipeline/rte_swx_ctl.c | 11 +- lib/pipeline/rte_swx_pipeline.c | 21 ++- lib/pipeline/rte_swx_pipeline_internal.h | 10 +- lib/power/rte_power_pmd_mgmt.c | 6 +- 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 +- 109 files changed, 473 insertions(+), 409 deletions(-)
--
2.51.0
PATCH v3 1/31 eal: add more min/max helpers
From: Stephen Hemminger <[email protected]>
Add RTE_MIN3() to handle case of RTE_MIN(RTE_MIN(...)), and similarly add RTE_MAX3(). Change name of local temporary variables in RTE_MAX() to allow for combinations of RTE_MIN(RTE_MAX(...)) without causing shadow declaration warnings.
--- lib/eal/include/rte_common.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
lib/eal/include/rte_common.h +28 -3
@@ -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,21 @@ __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; \ + }) + +/** +* Macro to return the maximum of three numbers +*/ +#define RTE_MAX3 (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); \ })/**
Signature · 1 line
2.51.0
PATCH v3 2/31 eal: fix variable shadowing
In reply to Bruce RichardsonFix 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
--- drivers/bus/pci/windows/pci.c | 1 - lib/eal/common/eal_common_options.c | 22 +++---- lib/eal/common/eal_common_trace.c | 89 ++++++++++++++--------------- lib/eal/common/malloc_heap.c | 2 +- 4 files changed, 56 insertions(+), 58 deletions(-)
drivers/bus/pci/windows/pci.c +0 -1
@@ -433,7 +433,6 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)rte_pci_add_device (dev); }else {struct rte_pci_device *dev2 =NULL ; -int ret; TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);
lib/eal/common/eal_common_options.c +11 -11
@@ -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; }
@@ -429,21 +429,21 @@ eal_clean_saved_args(void)#endif /* !RTE_EXEC_ENV_WINDOWS */ 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);
lib/eal/common/eal_common_trace.c +44 -45
196 lines not on this page · raw message
lib/eal/common/malloc_heap.c +1 -1
@@ -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
Signature · 1 line
2.51.0
PATCH v3 3/31 ethdev: fix variable shadowing issues
In reply to Bruce RichardsonRemove unneeded extra variable definitions, and rename variables as necessary to ensure clean compile with -Wshadow warnings enabled.
--- lib/ethdev/ethdev_driver.c | 6 +++--- lib/ethdev/rte_ethdev.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
lib/ethdev/ethdev_driver.c +3 -3
@@ -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" );
lib/ethdev/rte_ethdev.c +0 -1
@@ -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);
Signature · 1 line
2.51.0
PATCH v3 4/31 eventdev: fix variable shadowing issues
In reply to Bruce RichardsonRename a macro variable to avoid shadowing conflicts, and reduce the scope of another variable for the same reason.
--- 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(-)
lib/eventdev/rte_event_eth_rx_adapter.c +2 -3
@@ -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;
lib/eventdev/rte_event_eth_tx_adapter.c +4 -4
@@ -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)
Signature · 1 line
2.51.0
PATCH v3 5/31 net: remove shadowed variable
In reply to Bruce RichardsonThe "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.
--- lib/net/net_crc_avx512.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/net/net_crc_avx512.c +1 -3
@@ -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 ) {
Signature · 1 line
2.51.0
PATCH v3 6/31 pipeline: fix variable shadowing
In reply to Bruce RichardsonRemove unnecessary inner variables and rename others in order to remove variable shadowing warnings from the code.
--- 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(-)
lib/pipeline/rte_swx_ctl.c +5 -6
@@ -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);
lib/pipeline/rte_swx_pipeline.c +10 -11
@@ -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;
lib/pipeline/rte_swx_pipeline_internal.h +5 -5
@@ -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 ; }
Signature · 1 line
2.51.0
PATCH v3 7/31 table: fix issues with variable shadowing
In reply to Bruce RichardsonBuilding table library with -Wshadow reveals many warnings from shadowed variables. Fix these by removing definitions, or renaming variables as appropriate.
--- 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(-)
lib/table/rte_lru.h +19 -19
@@ -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 )
lib/table/rte_lru_arm64.h +7 -7
@@ -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
lib/table/rte_lru_x86.h +2 -2
@@ -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! */ \
lib/table/rte_swx_table_em.c +0 -2
@@ -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);
lib/table/rte_swx_table_learner.c +2 -2
@@ -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. */
lib/table/rte_table_hash_key16.c +1 -3
@@ -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);
lib/table/rte_table_hash_key32.c +1 -3
@@ -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);
lib/table/rte_table_hash_key8.c +1 -3
@@ -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);
Signature · 1 line
2.51.0
PATCH v3 8/31 power: rename variable to eliminate shadowing
In reply to Bruce RichardsonThe "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".
--- lib/power/rte_power_pmd_mgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/rte_power_pmd_mgmt.c +3 -3
@@ -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 (); } }
Signature · 1 line
2.51.0
PATCH v3 9/31 pcapng: rename variable to fix shadowing
In reply to Bruce RichardsonThe "len" variable is shadowed within a function, so rename inner use to the more descriptive "filter_len" to fix the issue.
--- lib/pcapng/rte_pcapng.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
lib/pcapng/rte_pcapng.c +3 -4
@@ -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 );
Signature · 1 line
2.51.0
PATCH v3 10/31 bbdev: fix variable shadowing
In reply to Bruce RichardsonThe "ret" variable is declared twice in rte_bbdev_setup_queues function. The second declaration is unneeded so remove it.
--- lib/bbdev/rte_bbdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bbdev/rte_bbdev.c +1 -1
@@ -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",
Signature · 1 line
2.51.0
PATCH v3 11/31 bus/pci: remove shadowed variables
In reply to Bruce RichardsonRemove 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.
--- drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/bus/pci/linux/pci.c +0 -1
@@ -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);
drivers/bus/pci/linux/pci_vfio.c +1 -1
@@ -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" );
Signature · 1 line
2.51.0
PATCH v3 12/31 net/intel: rename function param to avoid shadow warnings
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/common/rx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/common/rx.h +3 -3
@@ -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;
Signature · 1 line
2.51.0
PATCH v3 13/31 net/e1000: fix build with shadow warnings enabled
In reply to Bruce RichardsonVariable "ret" was shadowed within the close function, so rename outer variable to "retval" to clear the warnings.
--- drivers/net/intel/e1000/igc_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/e1000/igc_ethdev.c +3 -3
@@ -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
Signature · 1 line
2.51.0
PATCH v3 14/31 net/i40e: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe local variables defined with the I40E_WRITE_GLB_REG macro are shadowing other variables. Rename the vars to start with "_" to avoid this shadowing.
--- drivers/net/intel/i40e/i40e_ethdev.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +5 -5
@@ -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 )
Signature · 1 line
2.51.0
PATCH v3 15/31 net/ice: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/ice/ice_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +3 -3
@@ -999,9 +999,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
Signature · 1 line
2.51.0
PATCH v3 16/31 net/cpfl: fix build with shadow warnings enabled
In reply to Bruce RichardsonRemove unnecessary variable definitions to ensure compiling with -Wshadow enabled.
--- 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(-)
drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c +0 -2
@@ -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],
drivers/net/intel/cpfl/cpfl_flow_parser.c +3 -3
@@ -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 ) {
drivers/net/intel/cpfl/cpfl_fxp_rule.h +0 -2
@@ -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,
drivers/net/intel/cpfl/cpfl_representor.h +1 -1
@@ -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);
Signature · 1 line
2.51.0
RE: [PATCH v3 16/31] net/cpfl: fix build with shadow warnings enabled
Remove unnecessary variable definitions to ensure compiling with -Wshadow enabled.
--- 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(-)
drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c +0 -2
@@ -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],
drivers/net/intel/cpfl/cpfl_flow_parser.c +3 -3
@@ -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
drivers/net/intel/cpfl/cpfl_fxp_rule.h +0 -2
@@ -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,
drivers/net/intel/cpfl/cpfl_representor.h +1 -2
@@ -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); --
Looks good to me,
2.51.0
PATCH v3 17/31 net/ixgbe: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/intel/ixgbe/ixgbe_fdir.c +3 -4
@@ -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_infostruct 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 );
Signature · 1 line
2.51.0
PATCH v3 18/31 app/testpmd: fix build with shadow warnings enabled
In reply to Bruce RichardsonRename or remove shadowed variables so as to build cleanly with -Wshadow.
--- app/test-pmd/cmdline_flow.c | 42 ++++++++++++++++++------------------- app/test-pmd/config.c | 15 +++++-------- app/test-pmd/parameters.c | 38 ++++++++++++++++----------------- app/test-pmd/testpmd.c | 2 +- 4 files changed, 45 insertions(+), 52 deletions(-)
app/test-pmd/cmdline_flow.c +21 -21
@@ -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 ;
app/test-pmd/config.c +5 -10
@@ -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_DESCportid_t port_id, -#else - __rte_unused portid_t port_id, -#endifuint16_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 ;
app/test-pmd/parameters.c +18 -20
@@ -777,42 +777,42 @@ parse_ringnuma_config(const char *q_arg) }static int -parse_event_printing_config (const char *optarg,int enable) +parse_event_printing_config (const char *event_arg,int enable) {uint32_t mask =0 ; -if (!strcmp (optarg,"unknown" )) +if (!strcmp (event_arg,"unknown" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_UNKNOWN ; -else if (!strcmp (optarg,"intr_lsc" )) +else if (!strcmp (event_arg,"intr_lsc" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_LSC ; -else if (!strcmp (optarg,"queue_state" )) +else if (!strcmp (event_arg,"queue_state" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_QUEUE_STATE ; -else if (!strcmp (optarg,"intr_reset" )) +else if (!strcmp (event_arg,"intr_reset" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_RESET ; -else if (!strcmp (optarg,"vf_mbox" )) +else if (!strcmp (event_arg,"vf_mbox" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_VF_MBOX ; -else if (!strcmp (optarg,"ipsec" )) +else if (!strcmp (event_arg,"ipsec" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_IPSEC ; -else if (!strcmp (optarg,"macsec" )) +else if (!strcmp (event_arg,"macsec" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_MACSEC ; -else if (!strcmp (optarg,"intr_rmv" )) +else if (!strcmp (event_arg,"intr_rmv" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_RMV ; -else if (!strcmp (optarg,"dev_probed" )) +else if (!strcmp (event_arg,"dev_probed" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_NEW ; -else if (!strcmp (optarg,"dev_released" )) +else if (!strcmp (event_arg,"dev_released" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_DESTROY ; -else if (!strcmp (optarg,"flow_aged" )) +else if (!strcmp (event_arg,"flow_aged" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_FLOW_AGED ; -else if (!strcmp (optarg,"err_recovering" )) +else if (!strcmp (event_arg,"err_recovering" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_ERR_RECOVERING ; -else if (!strcmp (optarg,"recovery_success" )) +else if (!strcmp (event_arg,"recovery_success" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_RECOVERY_SUCCESS ; -else if (!strcmp (optarg,"recovery_failed" )) +else if (!strcmp (event_arg,"recovery_failed" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_RECOVERY_FAILED ; -else if (!strcmp (optarg,"all" )) +else if (!strcmp (event_arg,"all" )) mask = ~UINT32_C (0 );else { -fprintf (stderr,"Invalid event: %s\n" , optarg); +fprintf (stderr,"Invalid event: %s\n" , event_arg);return -1 ; }if (enable)
@@ -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 );
app/test-pmd/testpmd.c +1 -1
@@ -4660,7 +4660,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",
Signature · 1 line
2.51.0
PATCH v3 19/31 app/graph: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe global variable "conn" conflicted with the local parameter to each function in the graph conn.c file. To prevent shadowing, use "c" as the name for the local connection variable throughout the file.
--- app/graph/conn.c | 134 +++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 67 deletions(-)
app/graph/conn.c +67 -67
@@ -20,12 +20,12 @@#define MSG_CMD_TOO_LONG "Command too long."static int -data_event_handle (struct conn *conn,int fd_client) +data_event_handle (struct conn *c,int fd_client) {ssize_t len, i, rc =0 ;/* Read input message */ - len =read (fd_client, conn->buf, conn->buf_size); + len =read (fd_client, c->buf, c->buf_size);if (len ==-1 ) {if ((errno ==EAGAIN ) || (errno ==EWOULDBLOCK ))return 0 ;
@@ -38,37 +38,37 @@ data_event_handle(struct conn *conn, int fd_client)/* Handle input messages */ for (i =0 ; i < len; i++) { -if (conn->buf[i] =='\n' ) { +if (c->buf[i] =='\n' ) {size_t n; - conn->msg_in[conn->msg_in_len] =0 ; - conn->msg_out[0 ] =0 ; + c->msg_in[c->msg_in_len] =0 ; + c->msg_out[0 ] =0 ; - conn->msg_handle (conn->msg_in, conn->msg_out, conn->msg_out_len_max, - conn->msg_handle_arg); + c->msg_handle (c->msg_in, c->msg_out, c->msg_out_len_max, + c->msg_handle_arg); - n =strlen (conn->msg_out); + n =strlen (c->msg_out);if (n) { - rc =write (fd_client, conn->msg_out, n); + rc =write (fd_client, c->msg_out, n);if (rc ==-1 ) goto exit; } - conn->msg_in_len =0 ; - }else if (conn->msg_in_len < conn->msg_in_len_max) { - conn->msg_in[conn->msg_in_len] = conn->buf[i]; - conn->msg_in_len++; + c->msg_in_len =0 ; + }else if (c->msg_in_len < c->msg_in_len_max) { + c->msg_in[c->msg_in_len] = c->buf[i]; + c->msg_in_len++; }else { rc =write (fd_client,MSG_CMD_TOO_LONG ,strlen (MSG_CMD_TOO_LONG ));if (rc ==-1 ) goto exit; - conn->msg_in_len =0 ; + c->msg_in_len =0 ; } }/* Write prompt */ - rc =write (fd_client, conn->prompt,strlen (conn->prompt)); + rc =write (fd_client, c->prompt,strlen (c->prompt)); rc = (rc ==-1 ) ?-1 :0 ; exit:
@@ -76,11 +76,11 @@ data_event_handle(struct conn *conn, int fd_client) }static int -control_event_handle (struct conn *conn,int fd_client) +control_event_handle (struct conn *c,int fd_client) {int rc; - rc =epoll_ctl (conn->fd_client_group,EPOLL_CTL_DEL , fd_client,NULL ); + rc =epoll_ctl (c->fd_client_group,EPOLL_CTL_DEL , fd_client,NULL );if (rc ==-1 ) goto exit;
@@ -99,7 +99,7 @@ conn_init(struct conn_params *p) {int fd_server, fd_client_group, rc;struct sockaddr_in server_address; -struct conn *conn =NULL ; +struct conn *c =NULL ;int reuse =1 ;memset (&server_address,0 ,sizeof (server_address));
@@ -115,20 +115,20 @@ conn_init(struct conn_params *p) goto exit;/* Memory allocation */ - conn =calloc (1 ,sizeof (struct conn )); -if (conn ==NULL ) + c =calloc (1 ,sizeof (struct conn )); +if (c ==NULL ) goto exit; - conn->welcome =calloc (1 ,CONN_WELCOME_LEN_MAX +1 ); - conn->prompt =calloc (1 ,CONN_PROMPT_LEN_MAX +1 ); - conn->buf =calloc (1 , p->buf_size); - conn->msg_in =calloc (1 , p->msg_in_len_max +1 ); - conn->msg_out =calloc (1 , p->msg_out_len_max +1 ); + c->welcome =calloc (1 ,CONN_WELCOME_LEN_MAX +1 ); + c->prompt =calloc (1 ,CONN_PROMPT_LEN_MAX +1 ); + c->buf =calloc (1 , p->buf_size); + c->msg_in =calloc (1 , p->msg_in_len_max +1 ); + c->msg_out =calloc (1 , p->msg_out_len_max +1 ); -if ((conn->welcome ==NULL ) || (conn->prompt ==NULL ) || (conn->buf ==NULL ) || - (conn->msg_in ==NULL ) || (conn->msg_out ==NULL )) { -conn_free (conn); - conn =NULL ; +if ((c->welcome ==NULL ) || (c->prompt ==NULL ) || (c->buf ==NULL ) || + (c->msg_in ==NULL ) || (c->msg_out ==NULL )) { +conn_free (c); + c =NULL ; goto exit; }
@@ -138,8 +138,8 @@ conn_init(struct conn_params *p) fd_server =socket (AF_INET ,SOCK_STREAM |SOCK_NONBLOCK ,0 );if (fd_server ==-1 ) { -conn_free (conn); - conn =NULL ; +conn_free (c); + c =NULL ; goto exit; }
@@ -161,47 +161,47 @@ conn_init(struct conn_params *p) goto free;/* Fill in */ -rte_strscpy (conn->welcome, p->welcome,CONN_WELCOME_LEN_MAX ); -rte_strscpy (conn->prompt, p->prompt,CONN_PROMPT_LEN_MAX ); - conn->buf_size = p->buf_size; - conn->msg_in_len_max = p->msg_in_len_max; - conn->msg_out_len_max = p->msg_out_len_max; - conn->msg_in_len =0 ; - conn->fd_server = fd_server; - conn->fd_client_group = fd_client_group; - conn->msg_handle = p->msg_handle; - conn->msg_handle_arg = p->msg_handle_arg; +rte_strscpy (c->welcome, p->welcome,CONN_WELCOME_LEN_MAX ); +rte_strscpy (c->prompt, p->prompt,CONN_PROMPT_LEN_MAX ); + c->buf_size = p->buf_size; + c->msg_in_len_max = p->msg_in_len_max; + c->msg_out_len_max = p->msg_out_len_max; + c->msg_in_len =0 ; + c->fd_server = fd_server; + c->fd_client_group = fd_client_group; + c->msg_handle = p->msg_handle; + c->msg_handle_arg = p->msg_handle_arg; exit: -return conn; +return c; free: -conn_free (conn); +conn_free (c);close (fd_server); - conn =NULL ; -return conn; + c =NULL ; +return c; }void -conn_free (struct conn *conn) +conn_free (struct conn *c) { -if (conn ==NULL ) +if (c ==NULL )return ; -if (conn->fd_client_group) -close (conn->fd_client_group); +if (c->fd_client_group) +close (c->fd_client_group); -if (conn->fd_server) -close (conn->fd_server); +if (c->fd_server) +close (c->fd_server); -free (conn->msg_out); -free (conn->msg_in); -free (conn->prompt); -free (conn->welcome); -free (conn); +free (c->msg_out); +free (c->msg_in); +free (c->prompt); +free (c->welcome); +free (c); }int -conn_req_poll (struct conn *conn) +conn_req_poll (struct conn *c) {struct sockaddr_in client_address;socklen_t client_address_length;
@@ -209,12 +209,12 @@ conn_req_poll(struct conn *conn)int fd_client, rc;/* Check input arguments */ -if (conn ==NULL ) +if (c ==NULL )return -1 ;/* Server socket */ client_address_length =sizeof (client_address); - fd_client =accept4 (conn->fd_server, (struct sockaddr *)&client_address, + fd_client =accept4 (c->fd_server, (struct sockaddr *)&client_address, &client_address_length,SOCK_NONBLOCK );if (fd_client ==-1 ) {if ((errno ==EAGAIN ) || (errno ==EWOULDBLOCK ))
@@ -227,20 +227,20 @@ conn_req_poll(struct conn *conn) event.events =EPOLLIN |EPOLLRDHUP |EPOLLHUP ; event.data.fd = fd_client; - rc =epoll_ctl (conn->fd_client_group,EPOLL_CTL_ADD , fd_client, &event); + rc =epoll_ctl (c->fd_client_group,EPOLL_CTL_ADD , fd_client, &event);if (rc ==-1 ) {close (fd_client); goto exit; }/* Client */ - rc =write (fd_client, conn->welcome,strlen (conn->welcome)); + rc =write (fd_client, c->welcome,strlen (c->welcome));if (rc ==-1 ) {close (fd_client); goto exit; } - rc =write (fd_client, conn->prompt,strlen (conn->prompt)); + rc =write (fd_client, c->prompt,strlen (c->prompt));if (rc ==-1 ) {close (fd_client); goto exit;
@@ -253,17 +253,17 @@ conn_req_poll(struct conn *conn) }int -conn_msg_poll (struct conn *conn) +conn_msg_poll (struct conn *c) {int fd_client, rc, rc_data =0 , rc_control =0 ;struct epoll_event event;/* Check input arguments */ -if (conn ==NULL ) +if (c ==NULL )return -1 ;/* Client group */ - rc =epoll_wait (conn->fd_client_group, &event,1 ,0 ); + rc =epoll_wait (c->fd_client_group, &event,1 ,0 );if ((rc ==-1 ) || rc ==0 )return rc;
@@ -271,11 +271,11 @@ conn_msg_poll(struct conn *conn)/* Data available */ if (event.events &EPOLLIN ) - rc_data =data_event_handle (conn, fd_client); + rc_data =data_event_handle (c, fd_client);/* Control events */ if (event.events & (EPOLLRDHUP |EPOLLERR |EPOLLHUP )) - rc_control =control_event_handle (conn, fd_client); + rc_control =control_event_handle (c, fd_client);if (rc_data || rc_control)return -1 ;
Signature · 1 line
2.51.0
PATCH v3 20/31 app/pdump: fix warning about shadowed variable
In reply to Bruce RichardsonThe variable name "optarg" is a standard global variable in getopt, so use of that name for function parameters causes shadowing warnings. Rename the variable to avoid these issues.
--- app/pdump/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/pdump/main.c +6 -6
@@ -247,7 +247,7 @@ parse_uint_value(const char *key, const char *value, void *extra_args) }static int -parse_pdump (const char *optarg) +parse_pdump (const char *arg) {struct rte_kvargs *kvlist;int ret =0 , cnt1, cnt2;
@@ -257,9 +257,9 @@ parse_pdump(const char *optarg) pt = &pdump_t[num_tuples];/* initial check for invalid arguments */ - kvlist =rte_kvargs_parse (optarg, valid_pdump_arguments); + kvlist =rte_kvargs_parse (arg, valid_pdump_arguments);if (kvlist ==NULL ) { -printf ("--pdump=\"%s\": invalid argument passed\n" , optarg); +printf ("--pdump=\"%s\": invalid argument passed\n" , arg);return -1 ; }
@@ -268,7 +268,7 @@ parse_pdump(const char *optarg) cnt2 =rte_kvargs_count (kvlist,PDUMP_PCI_ARG );if (!((cnt1 ==1 && cnt2 ==0 ) || (cnt1 ==0 && cnt2 ==1 ))) {printf ("--pdump=\"%s\": must have either port or " -"device_id argument\n" , optarg); +"device_id argument\n" , arg); ret =-1 ; goto free_kvlist; }else if (cnt1 ==1 ) {
@@ -290,7 +290,7 @@ parse_pdump(const char *optarg)/* queue parsing and validation */ cnt1 =rte_kvargs_count (kvlist,PDUMP_QUEUE_ARG );if (cnt1 !=1 ) { -printf ("--pdump=\"%s\": must have queue argument\n" , optarg); +printf ("--pdump=\"%s\": must have queue argument\n" , arg); ret =-1 ; goto free_kvlist; }
@@ -303,7 +303,7 @@ parse_pdump(const char *optarg) cnt2 =rte_kvargs_count (kvlist,PDUMP_TX_DEV_ARG );if (cnt1 ==0 && cnt2 ==0 ) {printf ("--pdump=\"%s\": must have either rx-dev or " -"tx-dev argument\n" , optarg); +"tx-dev argument\n" , arg); ret =-1 ; goto free_kvlist; }else if (cnt1 ==1 && cnt2 ==1 ) {
Signature · 1 line
2.51.0
PATCH v3 21/31 app/test-bbdev: remove shadow warning from next max calls
In reply to Bruce RichardsonNested use of RTE_MAX leads to variable shadowing for the internal variables, so use RTE_MAX3 rather than two nested calls.
--- app/test-bbdev/test_bbdev_perf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
app/test-bbdev/test_bbdev_perf.c +3 -4
@@ -552,12 +552,11 @@ create_mempools(struct active_device *ad, int socket_id, &test_vector.entries[DATA_HARQ_OUTPUT ];/* allocate ops mempool */ - ops_pool_size =optimal_mempool_size (RTE_MAX ( + ops_pool_size =optimal_mempool_size (RTE_MAX3 (/* Ops used plus 1 reference op */ -RTE_MAX ((unsigned int )(ad->nb_queues * num_ops +1 ), + (unsigned int )(ad->nb_queues * num_ops +1 ),/* Minimal cache size plus 1 reference op */ - (unsigned int )(1.5 *rte_lcore_count () * -OPS_CACHE_SIZE +1 )), + (unsigned int )(1.5 *rte_lcore_count () *OPS_CACHE_SIZE +1 ),OPS_POOL_SIZE_MIN ));if (org_op_type ==RTE_BBDEV_OP_NONE )
Signature · 1 line
2.51.0
PATCH v3 22/31 app/test-compress-perf: rename local vars to fix shadowing
In reply to Bruce RichardsonRename the parameter to 3 functions to avoid shadowing a global variable of the same name.
--- app/test-compress-perf/main.c | 122 +++++++++++++++++----------------- 1 file changed, 61 insertions(+), 61 deletions(-)
app/test-compress-perf/main.c +61 -61
@@ -53,33 +53,33 @@ static const struct cperf_test cperf_testmap[] = {static struct comp_test_data *test_data;static int -comp_perf_check_capabilities (struct comp_test_data *test_data,uint8_t cdev_id) +comp_perf_check_capabilities (struct comp_test_data *td,uint8_t cdev_id) {const struct rte_compressdev_capabilities *cap; - cap =rte_compressdev_capability_get (cdev_id, test_data->test_algo); + cap =rte_compressdev_capability_get (cdev_id, td->test_algo);if (cap ==NULL ) {RTE_LOG (ERR ,USER1 ,"Compress device does not support %u algorithm\n" , - test_data->test_algo); + td->test_algo);return -1 ; }uint64_t comp_flags = cap->comp_feature_flags;/* Algorithm type */ -switch (test_data->test_algo) { +switch (td->test_algo) {case RTE_COMP_ALGO_DEFLATE :/* Huffman encoding */ -if (test_data->huffman_enc ==RTE_COMP_HUFFMAN_FIXED && +if (td->huffman_enc ==RTE_COMP_HUFFMAN_FIXED && (comp_flags &RTE_COMP_FF_HUFFMAN_FIXED ) ==0 ) {RTE_LOG (ERR ,USER1 ,"Compress device does not supported Fixed Huffman\n" );return -1 ; } -if (test_data->huffman_enc ==RTE_COMP_HUFFMAN_DYNAMIC && +if (td->huffman_enc ==RTE_COMP_HUFFMAN_DYNAMIC && (comp_flags &RTE_COMP_FF_HUFFMAN_DYNAMIC ) ==0 ) {RTE_LOG (ERR ,USER1 ,"Compress device does not supported Dynamic Huffman\n" );
@@ -88,14 +88,14 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)break ;case RTE_COMP_ALGO_LZ4 :/* LZ4 flags */ -if ((test_data->lz4_flags &RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM ) && +if ((td->lz4_flags &RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM ) && (comp_flags &RTE_COMP_FF_LZ4_BLOCK_WITH_CHECKSUM ) ==0 ) {RTE_LOG (ERR ,USER1 ,"Compress device does not support LZ4 block with checksum\n" );return -1 ; } -if ((test_data->lz4_flags & +if ((td->lz4_flags &RTE_COMP_LZ4_FLAG_BLOCK_INDEPENDENCE ) && (comp_flags &RTE_COMP_FF_LZ4_BLOCK_INDEPENDENCE ) ==0 ) { RTE_LOG(ERR, USER1,
@@ -111,8 +111,8 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) }/* Window size */ -if (test_data->window_sz !=-1 ) { -if (param_range_check (test_data->window_sz, &cap->window_size) +if (td->window_sz !=-1 ) { +if (param_range_check (td->window_sz, &cap->window_size) <0 ) {RTE_LOG (ERR ,USER1 , "Compress device does not support "
@@ -121,18 +121,18 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) } }else /* Set window size to PMD maximum if none was specified */ - test_data->window_sz = cap->window_size.max; + td->window_sz = cap->window_size.max;/* Check if chained mbufs is supported */ -if (test_data->max_sgl_segs >1 && +if (td->max_sgl_segs >1 && (comp_flags &RTE_COMP_FF_OOP_SGL_IN_SGL_OUT ) ==0 ) {RTE_LOG (INFO ,USER1 ,"Compress device does not support " "chained mbufs. Max SGL segments set to 1\n" ); - test_data->max_sgl_segs =1 ; + td->max_sgl_segs =1 ; }/* Level 0 support */ -if (test_data->level_lst.min ==0 && +if (td->level_lst.min ==0 && (comp_flags &RTE_COMP_FF_NONCOMPRESSED_BLOCKS ) ==0 ) {RTE_LOG (ERR ,USER1 ,"Compress device does not support " "level 0 (no compression)\n" );
@@ -143,19 +143,19 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id) }static int -comp_perf_initialize_compressdev (struct comp_test_data *test_data, +comp_perf_initialize_compressdev (struct comp_test_data *td,uint8_t *enabled_cdevs) {uint8_t enabled_cdev_count, nb_lcores, cdev_id;unsigned int i, j;int ret; - enabled_cdev_count =rte_compressdev_devices_get (test_data->driver_name, + enabled_cdev_count =rte_compressdev_devices_get (td->driver_name, enabled_cdevs,RTE_COMPRESS_MAX_DEVS );if (enabled_cdev_count ==0 ) {RTE_LOG (ERR ,USER1 ,"No compress devices type %s available," " please check the list of specified devices in EAL section\n" , - test_data->driver_name); + td->driver_name);return -EINVAL ; }
@@ -186,13 +186,13 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,* 2 queue pairs will be set up per device but one queue pair * will left unused in the last one device */ - test_data->nb_qps = (nb_lcores % enabled_cdev_count) ? + td->nb_qps = (nb_lcores % enabled_cdev_count) ? (nb_lcores / enabled_cdev_count) +1 : nb_lcores / enabled_cdev_count;for (i =0 ; i < enabled_cdev_count && i <RTE_COMPRESS_MAX_DEVS ; i++, - nb_lcores -= test_data->nb_qps) { + nb_lcores -= td->nb_qps) { cdev_id = enabled_cdevs[i];struct rte_compressdev_info cdev_info;
@@ -200,7 +200,7 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,rte_compressdev_info_get (cdev_id, &cdev_info);if (cdev_info.max_nb_queue_pairs && - test_data->nb_qps > cdev_info.max_nb_queue_pairs) { + td->nb_qps > cdev_info.max_nb_queue_pairs) {RTE_LOG (ERR ,USER1 ,"Number of needed queue pairs is higher " "than the maximum number of queue pairs "
@@ -211,25 +211,25 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,return -EINVAL ; } -if (comp_perf_check_capabilities (test_data, cdev_id) <0 ) +if (comp_perf_check_capabilities (td, cdev_id) <0 )return -EINVAL ;/* Configure compressdev */ struct rte_compressdev_config config = { .socket_id = socket_id, - .nb_queue_pairs = nb_lcores > test_data->nb_qps - ? test_data->nb_qps : nb_lcores, + .nb_queue_pairs = nb_lcores > td->nb_qps + ? td->nb_qps : nb_lcores, .max_nb_priv_xforms =NUM_MAX_XFORMS , .max_nb_streams =0 }; - test_data->nb_qps = config.nb_queue_pairs; + td->nb_qps = config.nb_queue_pairs;if (rte_compressdev_configure (cdev_id, &config) <0 ) {RTE_LOG (ERR ,USER1 ,"Device configuration failed\n" );return -EINVAL ; } -for (j =0 ; j < test_data->nb_qps; j++) { +for (j =0 ; j < td->nb_qps; j++) { ret =rte_compressdev_queue_pair_setup (cdev_id, j,NUM_MAX_INFLIGHT_OPS , socket_id);if (ret <0 ) {
@@ -253,9 +253,9 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data, }static int -comp_perf_dump_input_data (struct comp_test_data *test_data) +comp_perf_dump_input_data (struct comp_test_data *td) { -FILE *f =fopen (test_data->input_file,"r" ); +FILE *f =fopen (td->input_file,"r" );int ret =-1 ;size_t actual_file_sz, remaining_data;uint8_t *data =NULL ;
@@ -274,34 +274,34 @@ comp_perf_dump_input_data(struct comp_test_data *test_data)* input data size = file size */ -if (test_data->input_data_sz ==0 ) - test_data->input_data_sz = actual_file_sz; +if (td->input_data_sz ==0 ) + td->input_data_sz = actual_file_sz; -if (test_data->input_data_sz <=0 || actual_file_sz <=0 || +if (td->input_data_sz <=0 || actual_file_sz <=0 ||fseek (f,0 ,SEEK_SET ) !=0 ) {RTE_LOG (ERR ,USER1 ,"Size of input could not be calculated\n" ); goto end; } -if (!(test_data->test_op &COMPRESS ) && - test_data->input_data_sz > - (size_t ) test_data->seg_sz * (size_t ) test_data->max_sgl_segs) { +if (!(td->test_op &COMPRESS ) && + td->input_data_sz > + (size_t ) td->seg_sz * (size_t ) td->max_sgl_segs) {RTE_LOG (ERR ,USER1 ,"Size of input must be less than total segments\n" ); goto end; } - test_data->input_data =rte_zmalloc_socket (NULL , - test_data->input_data_sz,0 ,rte_socket_id ()); + td->input_data =rte_zmalloc_socket (NULL , + td->input_data_sz,0 ,rte_socket_id ()); -if (test_data->input_data ==NULL ) { +if (td->input_data ==NULL ) {RTE_LOG (ERR ,USER1 ,"Memory to hold the data from the input " "file could not be allocated\n" ); goto end; } - remaining_data = test_data->input_data_sz; - data = test_data->input_data; + remaining_data = td->input_data_sz; + data = td->input_data;while (remaining_data >0 ) {size_t data_to_read =RTE_MIN (remaining_data, actual_file_sz);
@@ -320,15 +320,15 @@ comp_perf_dump_input_data(struct comp_test_data *test_data) }printf ("\n" ); -if (test_data->input_data_sz > actual_file_sz) +if (td->input_data_sz > actual_file_sz)RTE_LOG (INFO ,USER1 ,"%zu bytes read from file %s, extending the file %.2f times\n" , - test_data->input_data_sz, test_data->input_file, - (double )test_data->input_data_sz/actual_file_sz); + td->input_data_sz, td->input_file, + (double )td->input_data_sz/actual_file_sz);else RTE_LOG (INFO ,USER1 ,"%zu bytes read from file %s\n" , - test_data->input_data_sz, test_data->input_file); + td->input_data_sz, td->input_file); ret =0 ;
@@ -338,15 +338,15 @@ comp_perf_dump_input_data(struct comp_test_data *test_data) }static int -comp_perf_dump_dictionary_data (struct comp_test_data *test_data) +comp_perf_dump_dictionary_data (struct comp_test_data *td) { -FILE *f =fopen (test_data->dictionary_file,"r" ); +FILE *f =fopen (td->dictionary_file,"r" );int ret =-1 ;if (f ==NULL ) {RTE_LOG (ERR ,USER1 ,"Dictionary file not specified\n" ); - test_data->dictionary_data_sz =0 ; - test_data->dictionary_data =NULL ; + td->dictionary_data_sz =0 ; + td->dictionary_data =NULL ; ret =0 ; goto end; }
@@ -367,40 +367,40 @@ comp_perf_dump_dictionary_data(struct comp_test_data *test_data)size_t actual_file_sz = (size_t )file_sz; -if (test_data->dictionary_data_sz ==0 ) - test_data->dictionary_data_sz = actual_file_sz; +if (td->dictionary_data_sz ==0 ) + td->dictionary_data_sz = actual_file_sz;if (fseek (f,0 ,SEEK_SET ) !=0 ) {RTE_LOG (ERR ,USER1 ,"Size of input could not be calculated\n" ); goto end; } - test_data->dictionary_data =rte_zmalloc_socket (NULL , - test_data->dictionary_data_sz,0 ,rte_socket_id ()); + td->dictionary_data =rte_zmalloc_socket (NULL , + td->dictionary_data_sz,0 ,rte_socket_id ()); -if (test_data->dictionary_data ==NULL ) { +if (td->dictionary_data ==NULL ) {RTE_LOG (ERR ,USER1 ,"Memory to hold the data from the dictionary " "file could not be allocated\n" ); goto end; } -size_t remaining_data = test_data->dictionary_data_sz; -uint8_t *data = test_data->dictionary_data; +size_t remaining_data = td->dictionary_data_sz; +uint8_t *data = td->dictionary_data;while (remaining_data >0 ) {size_t data_to_read =RTE_MIN (remaining_data, actual_file_sz);if (fread (data, data_to_read,1 , f) !=1 ) {RTE_LOG (ERR ,USER1 ,"Input file could not be read\n" ); -if (test_data->dictionary_data) -rte_free (test_data->dictionary_data); +if (td->dictionary_data) +rte_free (td->dictionary_data); goto end; }if (fseek (f,0 ,SEEK_SET ) !=0 ) {RTE_LOG (ERR ,USER1 ,"Size of input could not be calculated\n" ); -if (test_data->dictionary_data) -rte_free (test_data->dictionary_data); +if (td->dictionary_data) +rte_free (td->dictionary_data); goto end; } remaining_data -= data_to_read;
@@ -408,15 +408,15 @@ comp_perf_dump_dictionary_data(struct comp_test_data *test_data) }printf ("\n" ); -if (test_data->dictionary_data_sz > actual_file_sz) +if (td->dictionary_data_sz > actual_file_sz)RTE_LOG (INFO ,USER1 ,"%zu bytes read from file %s, extending the file %.2f times\n" , - test_data->dictionary_data_sz, test_data->dictionary_file, - (double )test_data->dictionary_data_sz/actual_file_sz); + td->dictionary_data_sz, td->dictionary_file, + (double )td->dictionary_data_sz/actual_file_sz);else RTE_LOG (INFO ,USER1 ,"%zu bytes read from file %s\n" , - test_data->dictionary_data_sz, test_data->dictionary_file); + td->dictionary_data_sz, td->dictionary_file); ret =0 ;
Signature · 1 line
2.51.0
PATCH v3 23/31 app/test-crypto-perf: rename local vars to fix shadowing
In reply to Bruce RichardsonThe global variable iv_offset was shadowed by a local var. Rename the local variable to a shorter form to solve the issue.
--- app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
app/test-crypto-perf/cperf_test_pmd_cyclecount.c +2 -4
@@ -111,15 +111,13 @@ cperf_pmd_cyclecount_test_constructor(struct rte_mempool *sess_mp, ctx->test_vector = test_vector;/* IV goes at the end of the crypto operation */ -uint16_t iv_offset =sizeof (struct rte_crypto_op ) + -sizeof (struct rte_crypto_sym_op ); +uint16_t iv_ofs =sizeof (struct rte_crypto_op ) +sizeof (struct rte_crypto_sym_op );if (*sess !=NULL ) { ctx->sess = *sess; ctx->sess_owner = false; }else { - ctx->sess = op_fns->sess_create (sess_mp, dev_id, options, test_vector, - iv_offset); + ctx->sess = op_fns->sess_create (sess_mp, dev_id, options, test_vector, iv_ofs);if (ctx->sess ==NULL ) goto err; *sess = ctx->sess;
Signature · 1 line
2.51.0
PATCH v3 24/31 app/test-eventdev: fix build with shadow warnings enabled
In reply to Bruce RichardsonRename or remove shadowed variables to give a clean build with -Wshadow.
--- app/test-eventdev/evt_main.c | 6 +++--- app/test-eventdev/test_atomic_queue.c | 6 +++--- app/test-eventdev/test_perf_common.c | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-)
app/test-eventdev/evt_main.c +3 -3
@@ -30,11 +30,11 @@ signal_handler(int signum) }static inline void -evt_options_dump_all (struct evt_test *test,struct evt_options *opts) +evt_options_dump_all (struct evt_test *t,struct evt_options *opts) {evt_options_dump (opts); -if (test->ops.opt_dump) - test->ops.opt_dump (opts); +if (t->ops.opt_dump) + t->ops.opt_dump (opts); }int
app/test-eventdev/test_atomic_queue.c +3 -3
@@ -34,7 +34,7 @@ static inline void atomic_queue_process_stage_1(struct test_order *const t, struct rte_event *const ev, uint32_t nb_flows, - rte_spinlock_t *atomic_locks, + rte_spinlock_t *atomic_lks, uint32_t *const expected_flow_seq, RTE_ATOMIC(uint64_t) * const outstand_pkts, uint32_t port)
@@ -42,7 +42,7 @@ atomic_queue_process_stage_1(struct test_order *const t,const uint32_t flow = *order_mbuf_flow_id (t, ev->mbuf);const uint32_t seq = *order_mbuf_seqn (t, ev->mbuf); -atomic_lock_verify (atomic_locks,1 , flow, nb_flows, t, port); +atomic_lock_verify (atomic_lks,1 , flow, nb_flows, t, port);/* compare the seqn against expected value */ if (seq != expected_flow_seq[flow]) {
@@ -58,7 +58,7 @@ atomic_queue_process_stage_1(struct test_order *const t, ev->op =RTE_EVENT_OP_RELEASE ; -atomic_spinlock_unlock (atomic_locks,1 , flow, nb_flows); +atomic_spinlock_unlock (atomic_lks,1 , flow, nb_flows); } static int
app/test-eventdev/test_perf_common.c +1 -3
@@ -2131,12 +2131,10 @@ perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)void *sess;struct prod_data *p = &t->prod[port];uint32_t flow_id; -uint8_t cdev_id;for (flow_id =0 ; flow_id < t->nb_flows; flow_id++) { sess = p->ca.crypto_sess[flow_id]; - cdev_id = p->ca.cdev_id; -rte_cryptodev_sym_session_free (cdev_id, sess); +rte_cryptodev_sym_session_free (p->ca.cdev_id, sess); } rte_event_crypto_adapter_queue_pair_del(
Signature · 1 line
2.51.0
PATCH v3 25/31 app/test-flow-perf: remove unneeded variable
In reply to Bruce RichardsonRemove an unnecessary second definition of a char * variable called "token" when processing commandline args.
--- app/test-flow-perf/main.c | 1 - 1 file changed, 1 deletion(-)
app/test-flow-perf/main.c +0 -1
@@ -916,7 +916,6 @@ args_parse(int argc, char **argv)if (strcmp (lgopts[opt_idx].name,"port-id" ) ==0 ) {uint16_t port_idx =0 ; -char *token; token =strtok (optarg,"," );while (token !=NULL ) {
Signature · 1 line
2.51.0
PATCH v3 26/31 app/test-security-perf: fix build with shadow warnings
In reply to Bruce RichardsonRename variables to eliminate variable shadowing.
NOTE: The test-security-perf app reuses code from "dpdk-test" app, so some changes are made there too.
--- app/test-security-perf/test_security_perf.c | 42 ++++++++++----------- app/test/test_cryptodev_security_ipsec.c | 13 +++---- 2 files changed, 26 insertions(+), 29 deletions(-)
app/test-security-perf/test_security_perf.c +21 -21
@@ -43,7 +43,7 @@ struct test_ctx {bool is_inbound; }; -static struct test_ctx ctx; +static struct test_ctx test_ctx;static int cryptodev_init (struct test_ctx *ctx,uint8_t nb_lcores)
@@ -355,7 +355,7 @@ test_security_session_perf(void *arg) nb_sessions += (nb_sess_total - nb_sessions * nb_lcores); ret =sec_conf_init (conf, &sess_conf, &ipsec_xform, - &ctx.td[ctx.td_idx]); + &test_ctx.td[test_ctx.td_idx]);if (ret) {RTE_LOG (ERR ,USER1 ,"Could not initialize session conf\n" );return EXIT_FAILURE ;
@@ -447,14 +447,14 @@ args_parse(int argc, char **argv)if (strcmp (lgopts[opt_idx].name,"nb-sess" ) ==0 ) { n =atoi (optarg);if (n >=0 ) - ctx.nb_sess = n; + test_ctx.nb_sess = n;else rte_exit (EXIT_FAILURE ,"nb-sess should be >= 0\n" ); -printf ("nb-sess %d / " , ctx.nb_sess); +printf ("nb-sess %d / " , test_ctx.nb_sess); }else if (strcmp (lgopts[opt_idx].name,"inbound" ) ==0 ) { - ctx.is_inbound = true; + test_ctx.is_inbound = true;printf ("inbound / " ); }
@@ -482,7 +482,7 @@ main(int argc, char **argv)unsigned long i;int ret; -memset (&ctx,0 ,sizeof (struct test_ctx )); +memset (&test_ctx,0 ,sizeof (struct test_ctx ));memset (&flags,0 ,sizeof (flags)); ret =rte_eal_init (argc, argv);
@@ -498,18 +498,18 @@ main(int argc, char **argv)return -EINVAL ; } - ctx.nb_sess =DEF_NB_SESSIONS +RTE_MEMPOOL_CACHE_MAX_SIZE * nb_lcores; + test_ctx.nb_sess =DEF_NB_SESSIONS +RTE_MEMPOOL_CACHE_MAX_SIZE * nb_lcores;if (argc >1 )args_parse (argc, argv); - ctx.nb_lcores = nb_lcores; + test_ctx.nb_lcores = nb_lcores; - ret =cryptodev_init (&ctx, nb_lcores); + ret =cryptodev_init (&test_ctx, nb_lcores);if (ret) goto exit; - ret =mempool_init (&ctx, nb_lcores); + ret =mempool_init (&test_ctx, nb_lcores);if (ret) goto cryptodev_fini;
@@ -521,19 +521,19 @@ main(int argc, char **argv) &flags, &td_outb[i], 1); -if (ctx.is_inbound) +if (test_ctx.is_inbound)test_ipsec_td_in_from_out (&td_outb[i], &td_inb[i]); } - ctx.td = td_outb; -if (ctx.is_inbound) - ctx.td = td_inb; + test_ctx.td = td_outb; +if (test_ctx.is_inbound) + test_ctx.td = td_inb; -for (ctx.td_idx =0 ; ctx.td_idx <RTE_DIM (sec_alg_list); ctx.td_idx++) { +for (test_ctx.td_idx =0 ; test_ctx.td_idx <RTE_DIM (sec_alg_list); test_ctx.td_idx++) {printf ("\n\n Algorithm combination:" ); -test_sec_alg_display (sec_alg_list[ctx.td_idx].param1, - sec_alg_list[ctx.td_idx].param2); +test_sec_alg_display (sec_alg_list[test_ctx.td_idx].param1, + sec_alg_list[test_ctx.td_idx].param2);printf (" ----------------------" ); printf("\n%20s%20s%20s%20s%20s%20s\n\n",
@@ -545,7 +545,7 @@ main(int argc, char **argv) i =0 ;RTE_LCORE_FOREACH_WORKER (lcore_id) {rte_eal_remote_launch (test_security_session_perf, - &ctx.lconf[i], + &test_ctx.lconf[i], lcore_id); i++; }
@@ -556,12 +556,12 @@ main(int argc, char **argv) } -cryptodev_fini (&ctx); -mempool_fini (&ctx); +cryptodev_fini (&test_ctx); +mempool_fini (&test_ctx);return EXIT_SUCCESS ; cryptodev_fini: -cryptodev_fini (&ctx); +cryptodev_fini (&test_ctx); exit:return EXIT_FAILURE ;
app/test/test_cryptodev_security_ipsec.c +5 -8
@@ -264,11 +264,10 @@ test_ipsec_td_prepare(const struct crypto_param *param1, {struct ipsec_test_data *td; -int i;memset (td_array,0 , nb_td *sizeof (*td)); -for (i =0 ; i < nb_td; i++) { +for (int i =0 ; i < nb_td; i++) { td = &td_array[i];/* Prepare fields based on param */
@@ -339,7 +338,6 @@ test_ipsec_td_prepare(const struct crypto_param *param1,struct rte_tcp_hdr *tcp;int64_t payload_len;uint8_t *data; -int64_t i; payload_len =RTE_MIN (flags->plaintext_len,IPSEC_TEXT_MAX_LEN ); payload_len -=sizeof (struct rte_ipv6_hdr );
@@ -355,8 +353,8 @@ test_ipsec_td_prepare(const struct crypto_param *param1,/* TCP */ tcp = (struct rte_tcp_hdr *)(ip6 +1 ); data = (uint8_t *)(tcp +1 ); -for (i =0 ; i < payload_len; i++) - data[i] = i; +for (int64_t j =0 ; j < payload_len; j++) + data[j] = j; tcp->cksum =0 ; tcp->cksum =rte_ipv6_udptcp_cksum (ip6, tcp); td->input_text.len = payload_len + sizeof(struct rte_ipv6_hdr) +
@@ -366,7 +364,6 @@ test_ipsec_td_prepare(const struct crypto_param *param1,struct rte_tcp_hdr *tcp;int64_t payload_len;uint8_t *data; -int64_t i; payload_len =RTE_MIN (flags->plaintext_len,IPSEC_TEXT_MAX_LEN ); payload_len -=sizeof (struct rte_ipv4_hdr );
@@ -384,8 +381,8 @@ test_ipsec_td_prepare(const struct crypto_param *param1,/* TCP */ tcp = (struct rte_tcp_hdr *)(ip +1 ); data = (uint8_t *)(tcp +1 ); -for (i =0 ; i < payload_len; i++) - data[i] = i; +for (int64_t j =0 ; j < payload_len; j++) + data[j] = j; tcp->cksum =0 ; tcp->cksum =rte_ipv4_udptcp_cksum (ip, tcp); td->input_text.len = payload_len + sizeof(struct rte_ipv4_hdr) +
Signature · 1 line
2.51.0
PATCH v3 27/31 app/test-pipeline: remove unnecessary variable
In reply to Bruce RichardsonThe second definition of a variable called "ret" in the main function is unnecessary and causes variable shadowing warnings, so just eliminate it.
--- app/test-pipeline/main.c | 1 - 1 file changed, 1 deletion(-)
app/test-pipeline/main.c +0 -1
@@ -89,7 +89,6 @@ main(int argc, char **argv)/* Close ports */ for (i =0 ; i < app.n_ports; i++) {uint16_t port; -int ret; port = app.ports[i];printf ("Closing port %d..." , port);
Signature · 1 line
2.51.0
PATCH v3 28/31 drivers: disable variable shadowing warnings for drivers
In reply to Bruce RichardsonNot all drivers build cleanly with shadow warnings enabled, so disable them on a driver-by-driver basis for now.
--- config/meson.build | 5 +++++ drivers/baseband/fpga_5gnr_fec/meson.build | 2 ++ drivers/bus/fslmc/meson.build | 2 ++ drivers/common/cnxk/meson.build | 1 + drivers/common/qat/meson.build | 1 + drivers/compress/nitrox/meson.build | 2 ++ drivers/crypto/cnxk/meson.build | 1 + drivers/crypto/octeontx/meson.build | 1 + drivers/crypto/openssl/meson.build | 1 + drivers/crypto/scheduler/meson.build | 1 + drivers/dma/dpaa2/meson.build | 2 ++ drivers/event/cnxk/meson.build | 1 + drivers/event/dlb2/meson.build | 2 ++ drivers/event/sw/meson.build | 1 + drivers/net/axgbe/meson.build | 2 +- drivers/net/bnxt/meson.build | 1 + drivers/net/bonding/meson.build | 1 + drivers/net/cnxk/meson.build | 1 + drivers/net/cxgbe/meson.build | 1 + drivers/net/dpaa/meson.build | 1 + drivers/net/dpaa2/meson.build | 1 + drivers/net/ena/meson.build | 2 ++ drivers/net/enetfec/meson.build | 2 ++ drivers/net/enic/meson.build | 2 ++ drivers/net/failsafe/meson.build | 1 + drivers/net/mlx5/meson.build | 1 + drivers/net/ntnic/meson.build | 3 +++ drivers/net/pfe/meson.build | 3 +++ drivers/net/qede/meson.build | 3 +++ drivers/net/txgbe/meson.build | 1 + drivers/net/zxdh/meson.build | 3 +++ drivers/raw/ifpga/meson.build | 2 ++ drivers/vdpa/mlx5/meson.build | 1 + 33 files changed, 54 insertions(+), 1 deletion(-)
config/meson.build +5 -0
@@ -361,6 +361,11 @@ if cc.has_argument('-Wvla') endif endif +no_shadow_cflag = [] +if cc.has_argument('-Wno-shadow') + no_shadow_cflag = '-Wno-shadow' +endif + foreach arg: global_cflags if cc.has_argument(arg) add_project_arguments(arg, language: 'c')
drivers/baseband/fpga_5gnr_fec/meson.build +2 -0
@@ -3,6 +3,8 @@ deps += ['bus_vdev', 'ring', 'pci', 'bus_pci'] +cflags += no_shadow_cflag + sources = files('rte_fpga_5gnr_fec.c') headers = files('rte_pmd_fpga_5gnr_fec.h')
drivers/bus/fslmc/meson.build +2 -0
@@ -6,6 +6,8 @@ if not is_linux reason = 'only supported on Linux' endif +cflags += no_shadow_cflag + deps += ['common_dpaax', 'eventdev', 'kvargs'] sources = files( 'fslmc_bus.c',
drivers/common/cnxk/meson.build +1 -0
@@ -95,6 +95,7 @@ sources += files('cnxk_telemetry_bphy.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag if meson.is_cross_build() soc_type = meson.get_external_property('platform', '')
drivers/common/qat/meson.build +1 -0
@@ -104,6 +104,7 @@ if qat_compress endif cflags += no_wvla_cflag +cflags += no_shadow_cflag if qat_crypto foreach f: ['qat_sym.c', 'qat_sym_session.c',
drivers/compress/nitrox/meson.build +2 -0
@@ -8,6 +8,8 @@ endif deps += ['common_nitrox', 'bus_pci', 'compressdev'] +cflags += no_shadow_cflag + sources += files( 'nitrox_comp.c', 'nitrox_comp_reqmgr.c',
drivers/crypto/cnxk/meson.build +1 -0
@@ -34,6 +34,7 @@ deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev'] includes += include_directories('../../../lib/net', '../../event/cnxk') cflags += no_wvla_cflag +cflags += no_shadow_cflag if get_option('buildtype').contains('debug') cflags += [ '-DLA_IPSEC_DEBUG','-DCNXK_CRYPTODEV_DEBUG' ]
drivers/crypto/octeontx/meson.build +1 -0
@@ -34,3 +34,4 @@ includes += include_directories('../../mempool/octeontx') includes += include_directories('../../net/octeontx') cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/crypto/openssl/meson.build +1 -0
@@ -17,3 +17,4 @@ sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c') ext_deps += dep require_iova_in_mbuf = false cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/crypto/scheduler/meson.build +1 -0
@@ -24,3 +24,4 @@ headers = files( ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/dma/dpaa2/meson.build +2 -0
@@ -14,3 +14,5 @@ sources = files('dpaa2_qdma.c') if cc.has_argument('-Wno-pointer-arith') cflags += '-Wno-pointer-arith' endif + +cflags += no_shadow_cflag
drivers/event/cnxk/meson.build +1 -0
@@ -301,6 +301,7 @@ endif endif cflags += no_wvla_cflag +cflags += no_shadow_cflag extra_flags = ['-flax-vector-conversions', '-Wno-strict-aliasing'] if cc.get_id() == 'clang'
drivers/event/dlb2/meson.build +2 -0
@@ -29,6 +29,8 @@ headers = files('rte_pmd_dlb2.h') deps += ['mbuf', 'mempool', 'ring', 'pci', 'bus_pci'] +cflags += no_shadow_cflag + dlb_pmd_defines = ['-DDLB2_BYPASS_FENCE_ON_PP', '-DDLB_HW_CREDITS_CHECKS', '-DDLB_SW_CREDITS_CHECKS', '-DDLB_TYPE_CHECK'] dlb_pmd_default = ['0','1','1','1']
drivers/event/sw/meson.build +1 -0
@@ -11,3 +11,4 @@ sources = files( deps += ['hash', 'bus_vdev'] require_iova_in_mbuf = false cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/net/axgbe/meson.build +1 -1
@@ -15,7 +15,7 @@ sources = files( 'axgbe_rxtx.c', ) -cflags += '-Wno-cast-qual' +cflags += ['-Wno-cast-qual', no_shadow_cflag] if arch_subdir == 'x86' sources += files('axgbe_rxtx_vec_sse.c')
drivers/net/bnxt/meson.build +1 -0
@@ -13,6 +13,7 @@ if dpdk_conf.get('RTE_IOVA_IN_MBUF') == 0 endif cflags += no_wvla_cflag +cflags += no_shadow_cflag headers = files('rte_pmd_bnxt.h') cflags_options = [
drivers/net/bonding/meson.build +1 -0
@@ -26,3 +26,4 @@ headers = files('rte_eth_bond.h', 'rte_eth_bond_8023ad.h') require_iova_in_mbuf = false cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/net/cnxk/meson.build +1 -0
@@ -328,6 +328,7 @@ deps += ['bus_pci', 'cryptodev', 'eventdev', 'security'] deps += ['common_cnxk', 'mempool_cnxk'] cflags += no_wvla_cflag +cflags += no_shadow_cflag # Allow implicit vector conversions and strict aliasing warning extra_flags = ['-flax-vector-conversions', '-Wno-strict-aliasing']
drivers/net/cxgbe/meson.build +1 -0
@@ -25,3 +25,4 @@ sources = files( includes += include_directories('base') cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/net/dpaa/meson.build +1 -0
@@ -18,6 +18,7 @@ sources = files( ) cflags += no_wvla_cflag +cflags += no_shadow_cflag if cc.has_argument('-Wno-pointer-arith') cflags += '-Wno-pointer-arith'
drivers/net/dpaa2/meson.build +1 -0
@@ -29,3 +29,4 @@ includes += include_directories('base', 'mc') headers = files('rte_pmd_dpaa2.h') cflags += no_wvla_cflag +cflags += no_shadow_cflag
drivers/net/ena/meson.build +2 -0
@@ -17,3 +17,5 @@ sources = files( deps += ['timer'] includes += include_directories('base', 'base/ena_defs') + +cflags += no_shadow_cflag
drivers/net/enetfec/meson.build +2 -0
@@ -11,3 +11,5 @@ sources = files( 'enet_uio.c', 'enet_rxtx.c', ) + +cflags += no_shadow_cflag
drivers/net/enic/meson.build +2 -0
@@ -29,6 +29,8 @@ sources = files( deps += ['hash'] includes += include_directories('base') +cflags += no_shadow_cflag + if dpdk_conf.has('RTE_ARCH_X86_64') cflags += '-DENIC_RXTX_VEC' sources_avx2 += files('enic_rxtx_vec_avx2.c')
drivers/net/failsafe/meson.build +1 -0
@@ -8,6 +8,7 @@ if is_windows endif cflags += no_wvla_cflag +cflags += no_shadow_cflag cflags += '-D_DEFAULT_SOURCE' cflags += '-D_XOPEN_SOURCE=700' cflags += '-pedantic'
drivers/net/mlx5/meson.build +1 -0
@@ -90,6 +90,7 @@ if get_option('buildtype').contains('debug') else cflags += [ '-UPEDANTIC' ] endif +cflags += no_shadow_cflag require_iova_in_mbuf = false
drivers/net/ntnic/meson.build +3 -0
@@ -128,3 +128,6 @@ sources = files( 'ntnic_ethdev.c', 'rte_pmd_ntnic.c', ) + +# Suppress shadow warnings for this driver due to extensive variable shadowing +cflags += no_shadow_cflag
drivers/net/pfe/meson.build +3 -0
@@ -18,4 +18,7 @@ if cc.has_argument('-Wno-pointer-arith') cflags += '-Wno-pointer-arith' endif +# Suppress shadow warnings for this driver +cflags += no_shadow_cflag + includes += include_directories('base')
drivers/net/qede/meson.build +3 -0
@@ -22,3 +22,6 @@ sources = files( if cc.has_argument('-Wno-format-nonliteral') cflags += '-Wno-format-nonliteral' endif + +# Suppress shadow warnings for this driver +cflags += no_shadow_cflag
drivers/net/txgbe/meson.build +1 -0
@@ -24,6 +24,7 @@ sources = files( deps += ['hash', 'security'] cflags += no_wvla_cflag +cflags += no_shadow_cflag if arch_subdir == 'x86' sources += files('txgbe_rxtx_vec_sse.c')
drivers/net/zxdh/meson.build +3 -0
@@ -20,3 +20,6 @@ sources = files( 'zxdh_mtr.c', 'zxdh_flow.c', ) + +# Suppress shadow warnings for this driver +cflags += no_shadow_cflag
drivers/raw/ifpga/meson.build +2 -0
@@ -19,6 +19,8 @@ endif ext_deps += rtdep +cflags += no_shadow_cflag + subdir('base') deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
drivers/vdpa/mlx5/meson.build +1 -0
@@ -24,6 +24,7 @@ sources = files( ) cflags += no_wvla_cflag +cflags += no_shadow_cflag cflags_options = [ '-std=c11',
Signature · 1 line
2.51.0
PATCH v3 29/31 app/test: disable shadowing warnings for unit tests
In reply to Bruce RichardsonThe dpdk-test binary has multiple issues with variable shadowing. For now, explicitly ignore shadowing warnings in this app.
--- app/test/meson.build | 1 + 1 file changed, 1 insertion(+)
app/test/meson.build +1 -0
@@ -256,6 +256,7 @@ foreach d:optional_deps endforeach cflags += no_wvla_cflag +cflags += no_shadow_cflag extra_flags = [ # Strict-aliasing rules are violated by uint8_t[] to context size casts.
Signature · 1 line
2.51.0
PATCH v3 30/31 examples: ignore variable shadowing warnings
In reply to Bruce RichardsonFor examples which don't compile with -Wshadow, explicitly disable those warnings.
--- examples/bbdev_app/meson.build | 1 + examples/bond/meson.build | 1 + examples/dma/meson.build | 1 + examples/ethtool/meson.build | 1 + examples/eventdev_pipeline/meson.build | 1 + examples/flow_filtering/meson.build | 1 + examples/ip_pipeline/meson.build | 1 + examples/ipsec-secgw/meson.build | 1 + examples/l2fwd-crypto/meson.build | 1 + examples/l2fwd-event/meson.build | 1 + examples/l2fwd-jobstats/meson.build | 1 + examples/l2fwd-keepalive/meson.build | 1 + examples/l3fwd-graph/meson.build | 1 + examples/l3fwd-power/meson.build | 1 + examples/l3fwd/meson.build | 1 + examples/multi_process/client_server_mp/mp_server/meson.build | 1 + examples/packet_ordering/meson.build | 1 + examples/ptpclient/meson.build | 1 + examples/qos_sched/meson.build | 1 + examples/server_node_efd/efd_server/meson.build | 1 + examples/vhost/meson.build | 1 + examples/vm_power_manager/guest_cli/meson.build | 1 + examples/vm_power_manager/meson.build | 1 + examples/vmdq/meson.build | 1 + 24 files changed, 24 insertions(+)
examples/bbdev_app/meson.build +1 -0
@@ -11,3 +11,4 @@ allow_experimental_apis = true sources = files( 'main.c', ) +cflags += no_shadow_cflag
examples/bond/meson.build +1 -0
@@ -11,6 +11,7 @@ allow_experimental_apis = true sources = files( 'main.c', ) +cflags += no_shadow_cflag cmd_h = custom_target('commands_hdr', output: 'commands.h',
examples/dma/meson.build +1 -0
@@ -13,3 +13,4 @@ deps += ['argparse', 'dmadev'] sources = files( 'dmafwd.c', ) +cflags += no_shadow_cflag
examples/ethtool/meson.build +1 -0
@@ -17,6 +17,7 @@ sources = files( 'ethtool-app/main.c', ) includes = include_directories('lib', 'ethtool-app') +cflags += no_shadow_cflag deps += 'bus_pci' if dpdk_conf.has('RTE_NET_IXGBE')
examples/eventdev_pipeline/meson.build +1 -0
@@ -13,3 +13,4 @@ sources = files( 'pipeline_worker_generic.c', 'pipeline_worker_tx.c', ) +cflags += no_shadow_cflag
examples/flow_filtering/meson.build +1 -0
@@ -25,3 +25,4 @@ sources = files( # The code snippets are not utilized. cflags += '-Wno-unused-function' +cflags += no_shadow_cflag
examples/ip_pipeline/meson.build +1 -0
@@ -28,3 +28,4 @@ sources = files( 'thread.c', 'tmgr.c', ) +cflags += no_shadow_cflag
examples/ipsec-secgw/meson.build +1 -0
@@ -25,6 +25,7 @@ sources = files( ) cflags += no_wvla_cflag +cflags += no_shadow_cflag app_cflags = ['-Wno-address-of-packed-member'] foreach flag:app_cflags
examples/l2fwd-crypto/meson.build +1 -0
@@ -15,3 +15,4 @@ sources = files( 'main.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/l2fwd-event/meson.build +1 -0
@@ -17,3 +17,4 @@ sources = files( 'l2fwd_event_internal_port.c', 'l2fwd_poll.c', ) +cflags += no_shadow_cflag
examples/l2fwd-jobstats/meson.build +1 -0
@@ -12,3 +12,4 @@ sources = files( 'main.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/l2fwd-keepalive/meson.build +1 -0
@@ -19,3 +19,4 @@ sources = files( 'main.c', 'shm.c', ) +cflags += no_shadow_cflag
examples/l3fwd-graph/meson.build +1 -0
@@ -11,3 +11,4 @@ sources = files( 'main.c', ) allow_experimental_apis = true +cflags += no_shadow_cflag
examples/l3fwd-power/meson.build +1 -0
@@ -13,3 +13,4 @@ sources = files( 'perf_core.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/l3fwd/meson.build +1 -0
@@ -22,3 +22,4 @@ if dpdk_conf.has('RTE_LIB_EVENTDEV') deps += 'eventdev' endif cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/multi_process/client_server_mp/mp_server/meson.build +1 -0
@@ -14,3 +14,4 @@ sources = files( 'init.c', 'main.c', ) +cflags += no_shadow_cflag
examples/packet_ordering/meson.build +1 -0
@@ -11,3 +11,4 @@ deps += 'reorder' sources = files( 'main.c', ) +cflags += no_shadow_cflag
examples/ptpclient/meson.build +1 -0
@@ -10,3 +10,4 @@ allow_experimental_apis = true sources = files( 'ptpclient.c', ) +cflags += no_shadow_cflag
examples/qos_sched/meson.build +1 -0
@@ -18,3 +18,4 @@ sources = files( 'stats.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/server_node_efd/efd_server/meson.build +1 -0
@@ -10,3 +10,4 @@ allow_experimental_apis = true deps += 'efd' sources += files('args.c', 'init.c', 'main.c') includes += include_directories('../shared') +cflags += no_shadow_cflag
examples/vhost/meson.build +1 -0
@@ -19,3 +19,4 @@ sources = files( 'virtio_net.c', ) cflags += no_wvla_cflag +cflags += no_shadow_cflag
examples/vm_power_manager/guest_cli/meson.build +1 -0
@@ -13,6 +13,7 @@ sources = files( 'parse.c', 'vm_power_cli_guest.c', ) +cflags += no_shadow_cflag allow_experimental_apis = true
examples/vm_power_manager/meson.build +1 -0
@@ -29,6 +29,7 @@ sources = files( 'power_manager.c', 'vm_power_cli.c', ) +cflags += no_shadow_cflag # If we're on X86, pull in the x86 code for the branch monitor algo. if dpdk_conf.has('RTE_ARCH_X86_64')
examples/vmdq/meson.build +1 -0
@@ -10,3 +10,4 @@ allow_experimental_apis = true sources = files( 'main.c', ) +cflags += no_shadow_cflag
Signature · 1 line
2.51.0
PATCH v3 31/31 build: enable shadowed variable warnings
In reply to Bruce RichardsonEnable -Wshadow globally for DPDK builds.
--- config/meson.build | 1 + 1 file changed, 1 insertion(+)
config/meson.build +1 -0
@@ -329,6 +329,7 @@ global_cflags = [ '-Wnested-externs', '-Wold-style-definition', '-Wpointer-arith', + '-Wshadow', '-Wsign-compare', '-Wstrict-prototypes', '-Wundef',
Signature · 1 line
2.51.0
Re: [PATCH v3 31/31] build: enable shadowed variable warnings
Quoted 6 lines · On Mon, 1 Dec 2025 11:44:48 +0000 Bruce Richardson…
Enable -Wshadow globally for DPDK builds.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Chengwen Feng <[email protected]>---
Since this was a big series and hard for humans to review; ran AI code review on it.
I'll review this DPDK patch series for fixing shadow variable warnings according to the AGENTS.md criteria. This is a 31-patch series from Bruce Richardson that enables -Wshadow warnings globally for DPDK.
---
## Patch Series Summary
This series adds helper macros (RTE_MIN3/RTE_MAX3), fixes shadow variable warnings across libraries, drivers, and apps, then enables -Wshadow globally. Components that don't build cleanly are explicitly excluded.
---
## Patch-by-Patch Review
### Patch 1/31: eal: add more min/max helpers
**Subject Line:** ✅ Good - 30 characters, correct prefix, lowercase, imperative
**Commit Message:**
- ✅ Describes the change well
- ✅ Proper Signed-off-by tags
- ✅ Has Acked-by tags
**Code Review:**
```c
#define RTE_MIN3(a, b, c) \
__extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
typeof (c) _c = (c); \
```⚠️ **Warning (style):** There's inconsistent spacing. The RTE_MAX macro is modified to use _ax/_bx, but RTE_MIN3 and RTE_MAX3 still use _a/_b/_c. This inconsistency could still cause shadowing if RTE_MIN3(RTE_MIN(...)) is used. Consider using unique names like _a3/_b3/_c3 for the triple variants.
⚠️ **Warning (style):** Extra blank line between RTE_MIN3 and the RTE_MAX definition comment:
```c
})
<-- extra blank line
/**
* Macro to return the minimum of two numbers
```DPDK style generally avoids double blank lines.
**Missing:** No Cc: [email protected] - this is a new feature, not a bug fix, so that's correct.
---
### Patch 2/31: eal: fix variable shadowing
**Subject Line:** ✅ Good - 27 characters
**Commit Message:**
- ✅ Has multiple Bugzilla ID: tags (correct format)
- ✅ Has Fixes: tags with 12-char SHA
- ✅ Has Cc: [email protected]
- ✅ Proper tag order
**Code Changes:**
- Renaming trace to t in tracing code - ✅ Reasonable
- Renaming args to out_args - ✅ Clear intent
- Renaming optarg to arg and optlen to arglen - ✅ Avoids conflict with getopt global
**Issue in drivers/bus/pci/windows/pci.c:**
```c
} else {
struct rte_pci_device *dev2 = NULL;
- int ret;
```This removes ret but it's used later in the block. Let me verify... Looking at the patch context, ret is already defined at the outer scope, so this is correct.
✅ **Good patch**
---
### Patch 3/31: ethdev: fix variable shadowing issues
**Subject Line:** ✅ 37 characters, correct prefix (ethdev: not lib/ethdev:)
**Code:**
```c - ethdev_bus_specific_init ethdev_bus_specific_init, + ethdev_bus_specific_init bus_specific_init, ```
✅ Renames parameter to avoid shadowing the type name - good practice.
✅ **Good patch**
---
### Patch 4/31: eventdev: fix variable shadowing issues
**Subject Line:** ✅ Good
**Code Review:**
```c
#define TXA_CHECK_OR_ERR_RET(id) \
do {\
- int ret; \
+ int _ret; \
```✅ Using _ret prefix for macro-local variables is the correct pattern.
```c - uint32_t n; ... + uint32_t n = rxa_eth_rx(rx_adapter, port, queue, nb_rx, ```
✅ Reduced scope by moving declaration to initialization point.
✅ **Good patch**
---
### Patch 5/31: net: remove shadowed variable
**Subject Line:** ✅ 30 characters
**Code:**
```c - __mmask16 mask; ... - 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); ```
✅ Cleanly eliminates unnecessary variable.
✅ **Good patch**
---
### Patch 6/31: pipeline: fix variable shadowing
**Subject Line:** ✅ Good
Multiple good fixes:
- Loop counter i shadowing → use inline for (uint32_t j = ...)
- Local n_bytes renamed to total_bytes
- Local name renamed contextually (action_name, pipeline_name)
✅ **Good patch**
---
### Patch 7/31: table: fix issues with variable shadowing
**Subject Line:** ✅ Good
**Macro variables renamed with underscore prefix:**
```c - uint64_t x, pos, x0, x1, x2, mask; + uint64_t _x, _pos, _x0, _x1, _x2, _mask; ```
✅ Correct pattern for macro-local variables.
✅ **Good patch**
---
### Patches 8-10: power, pcapng, bbdev fixes
All ✅ **Good patches** - simple renames, proper format.
---
### Patch 11/31: bus/pci: remove shadowed variables
**Subject Line:** ✅ Good
Both fixes are correct - removing duplicate ret declarations.
✅ **Good patch**
---
### Patches 12-17: Intel driver fixes (e1000, i40e, ice, cpfl, ixgbe)
All have proper format. Notable:
**Patch 14 (i40e):**
```c - struct rte_eth_dev *dev; + struct rte_eth_dev *_dev; ```
✅ Underscore prefix in macros is correct.
**Patch 15 (ice):**
```c - 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); ```
✅ Good - avoids nested RTE_MIN which causes shadowing.
---
### Patch 18/31: app/testpmd: fix build with shadow warnings enabled
**Subject Line:** ✅ 47 characters
Multiple good fixes including:
- geneve_opt vs generic opt
- event_arg vs optarg (getopt global)
- Removing unnecessary rss_hf variable
✅ **Good patch**
---
### Patches 19-27: Various app fixes
All ✅ **Good patches** with proper format and reasonable changes.
---
### Patch 28/31: drivers: disable variable shadowing warnings for drivers
**Subject Line:** ✅ Good
**Code:**
```python
no_shadow_cflag = []
if cc.has_argument('-Wno-shadow')
no_shadow_cflag = '-Wno-shadow'
endif
```⚠️ **Info:** This pattern is correct but many drivers are excluded. The list is quite long (33 drivers/components). This is acceptable as a pragmatic approach to enable the warning incrementally.
✅ **Good patch**
---
### Patches 29-30: app/test and examples exclusions
✅ **Good patches** - correctly excludes code that hasn't been fixed yet.
---
### Patch 31/31: build: enable shadowed variable warnings
**Subject Line:** ✅ Good
```python
global_cflags = [
...
+ '-Wshadow',
```✅ **Good patch** - final enablement.
---
## Overall Assessment
### Errors (must fix):
None identified.
### Warnings (should fix):
1. **Patch 1:** Inconsistent variable naming between RTE_MIN/RTE_MAX (_ax/_bx) and RTE_MIN3/RTE_MAX3 (_a/_b/_c). Using RTE_MIN3(RTE_MIN(...)) could still cause shadowing. Consider making variable names more unique.
2. **Patch 1:** Extra blank line between macros (minor style issue).
### Info (consider):
1. The series excludes a significant number of drivers and examples from -Wshadow. This is a pragmatic approach but creates technical debt. Consider documenting which components need fixing in a TODO or tracking bug.
2. Some patches fix code in areas unrelated to the commit message scope (e.g., patch 2 modifies drivers/bus/pci/windows/pci.c but is titled as "eal" fix). This is acceptable since the changes are necessary for clean compilation.
---
## Summary
This is a **well-structured patch series** that methodically enables -Wshadow for DPDK. The patches:
- Follow DPDK commit message conventions
- Have proper Fixes: and Cc: [email protected] tags where appropriate
- Use reasonable renaming strategies
- Correctly employ underscore prefixes for macro-local variables
**Recommendation:** The series is ready for merge with minor style considerations on patch 1. The approach of enabling the warning globally while excluding problematic components is pragmatic and allows incremental improvement.
Re: [PATCH v3 00/31] build DPDK with Wshadow flag
In reply to Bruce RichardsonQuoted 16 lines · Bruce Richardson
As flagged in bugs #1742, #1743 and others, much of DPDK fails to build when -Wshadow flag is passed to the build. This patchset fixes many issues of this nature, but not all, in the hopes we can move towards enabling that warning flag for all components for DPDK in future. This patchset fixes the following components in DPDK:
* all libraries
* Intel net drivers
* all apps in the "app" folderFor the rest of the drivers and example applications, any component which does not build successfully with the shadow warning enabled has it explicitly disabled via cflags. Then the last patch adds -Wshadow to the global DPDK build, which should prevent any regressions in components which are already working.
Quoted 6 lines
At that point, we should not have any regressions and we can, over time, reduce the number of components needing the -Wno-shadow flag.
v3:
* rebase on 25.11 release.
@stable tree maintainers.
Where feasible, for many of the patches in this set, I've marked them as bug fixes against older commits which introduced the shadowing. However, I'll leave it up to you to decide if it's worth backporting this particular series or not. The remaining commits which are not tagged as fixes or which don't have offending commits identified should probably be backported too if you are backporting any. IMHO, I don't see much point in backporting only part of the series - either it should all be backported (bar last patch) or none of it.
Regards,
/Bruce
Re: [PATCH v3 00/31] build DPDK with Wshadow flag
In reply to Bruce RichardsonRecheck-request: iol-intel-Performance
Putting in a retest due to an infra fail at UNH.
v4 cover build DPDK with Wshadow flag
In reply to Bruce RichardsonAs flagged in bugs #1742, #1743 and others, much of DPDK fails to build when -Wshadow flag is passed to the build. This patchset fixes many issues of this nature, but not all, in the hopes we can move towards enabling that warning flag for all components for DPDK in future. This patchset fixes the following components in DPDK:
* all libraries
* Intel net drivers
* all apps in the "app" folder
For the rest of the drivers and example applications, any component which does not build successfully with the shadow warning enabled has it explicitly disabled via cflags. Then the last patch adds -Wshadow to the global DPDK build, which should prevent any regressions in components which are already working.
At that point, we should not have any regressions and we can, over time, reduce the number of components needing the -Wno-shadow flag.
V4:
* Updates follow AI review:
- improve variable naming in min/max fns
- remove extra blank line
* rebase on latest main
v3:
* rebase on 25.11 release.
RFC v2:
* take patch from Stephen for RTE_MIN/MAX fixes
* add additional fixes to clear clang warnings - it's a lot stricter than gcc in this regard, and flags more issues.
* extend app cleanup to all apps, not just testpmd
* add per-component disabling, and add global enable flag at the end.
Bruce Richardson (30):
eal: fix variable shadowing
ethdev: fix variable shadowing issues
eventdev: fix variable shadowing issues
net: remove shadowed variable
pipeline: fix variable shadowing
table: fix issues with variable shadowing
power: rename variable to eliminate shadowing
pcapng: rename variable to fix shadowing
bbdev: fix variable shadowing
bus/pci: remove shadowed variables
net/intel: rename function param to avoid shadow warnings net/e1000: fix build with shadow warnings enabled net/i40e: fix build with shadow warnings enabled net/ice: fix build with shadow warnings enabled net/cpfl: fix build with shadow warnings enabled net/ixgbe: fix build with shadow warnings enabled app/testpmd: fix build with shadow warnings enabled app/graph: fix build with shadow warnings enabled app/pdump: fix warning about shadowed variable app/test-bbdev: remove shadow warning from next max calls app/test-compress-perf: rename local vars to fix shadowing app/test-crypto-perf: rename local vars to fix shadowing app/test-eventdev: fix build with shadow warnings enabled app/test-flow-perf: remove unneeded variable app/test-security-perf: fix build with shadow warnings app/test-pipeline: remove unnecessary variable
drivers: disable variable shadowing warnings for drivers app/test: disable shadowing warnings for unit tests
examples: ignore variable shadowing warnings
build: enable shadowed variable warnings
Stephen Hemminger (1):
eal: add more min/max helpers
app/graph/conn.c | 134 +++++++++--------- app/pdump/main.c | 12 +- app/test-bbdev/test_bbdev_perf.c | 7 +- app/test-compress-perf/main.c | 122 ++++++++-------- .../cperf_test_pmd_cyclecount.c | 6 +- app/test-eventdev/evt_main.c | 6 +- app/test-eventdev/test_atomic_queue.c | 6 +- app/test-eventdev/test_perf_common.c | 4 +- app/test-flow-perf/main.c | 1 - app/test-pipeline/main.c | 1 - app/test-pmd/cmdline_flow.c | 42 +++--- app/test-pmd/config.c | 15 +- app/test-pmd/parameters.c | 38 +++-- app/test-pmd/testpmd.c | 2 +- app/test-security-perf/test_security_perf.c | 42 +++--- app/test/meson.build | 1 + app/test/test_cryptodev_security_ipsec.c | 13 +- config/meson.build | 6 + drivers/baseband/fpga_5gnr_fec/meson.build | 2 + drivers/bus/fslmc/meson.build | 2 + drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- drivers/bus/pci/windows/pci.c | 1 - drivers/common/cnxk/meson.build | 1 + drivers/common/qat/meson.build | 1 + drivers/compress/nitrox/meson.build | 2 + drivers/crypto/cnxk/meson.build | 1 + drivers/crypto/octeontx/meson.build | 1 + drivers/crypto/openssl/meson.build | 1 + drivers/crypto/scheduler/meson.build | 1 + drivers/dma/dpaa2/meson.build | 2 + drivers/event/cnxk/meson.build | 1 + drivers/event/dlb2/meson.build | 2 + drivers/event/sw/meson.build | 1 + drivers/net/axgbe/meson.build | 2 +- drivers/net/bnxt/meson.build | 1 + drivers/net/bonding/meson.build | 1 + drivers/net/cnxk/meson.build | 1 + drivers/net/cxgbe/meson.build | 1 + drivers/net/dpaa/meson.build | 1 + drivers/net/dpaa2/meson.build | 1 + drivers/net/ena/meson.build | 2 + drivers/net/enetfec/meson.build | 2 + drivers/net/enic/meson.build | 2 + drivers/net/failsafe/meson.build | 1 + drivers/net/intel/common/rx.h | 6 +- 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 +- drivers/net/intel/e1000/igc_ethdev.c | 6 +- drivers/net/intel/i40e/i40e_ethdev.h | 10 +- drivers/net/intel/ice/ice_ethdev.c | 6 +- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +- drivers/net/mlx5/meson.build | 1 + drivers/net/ntnic/meson.build | 3 + drivers/net/pfe/meson.build | 3 + drivers/net/qede/meson.build | 3 + drivers/net/txgbe/meson.build | 1 + drivers/net/zxdh/meson.build | 3 + drivers/raw/ifpga/meson.build | 2 + drivers/vdpa/mlx5/meson.build | 1 + examples/bbdev_app/meson.build | 1 + examples/bond/meson.build | 1 + examples/dma/meson.build | 1 + examples/ethtool/meson.build | 1 + examples/eventdev_pipeline/meson.build | 1 + examples/flow_filtering/meson.build | 1 + examples/ip_pipeline/meson.build | 1 + examples/ipsec-secgw/meson.build | 1 + examples/l2fwd-crypto/meson.build | 1 + examples/l2fwd-event/meson.build | 1 + examples/l2fwd-jobstats/meson.build | 1 + examples/l2fwd-keepalive/meson.build | 1 + examples/l3fwd-graph/meson.build | 1 + examples/l3fwd-power/meson.build | 1 + examples/l3fwd/meson.build | 1 + .../client_server_mp/mp_server/meson.build | 1 + examples/packet_ordering/meson.build | 1 + examples/ptpclient/meson.build | 1 + examples/qos_sched/meson.build | 1 + .../server_node_efd/efd_server/meson.build | 1 + examples/vhost/meson.build | 1 + .../vm_power_manager/guest_cli/meson.build | 1 + examples/vm_power_manager/meson.build | 1 + examples/vmdq/meson.build | 1 + lib/bbdev/rte_bbdev.c | 2 +- lib/eal/common/eal_common_options.c | 22 +-- lib/eal/common/eal_common_trace.c | 89 ++++++------ lib/eal/common/malloc_heap.c | 2 +- lib/eal/include/rte_common.h | 38 ++++- lib/ethdev/ethdev_driver.c | 6 +- lib/ethdev/rte_ethdev.c | 1 - lib/eventdev/rte_event_eth_rx_adapter.c | 5 +- lib/eventdev/rte_event_eth_tx_adapter.c | 8 +- lib/net/net_crc_avx512.c | 4 +- lib/pcapng/rte_pcapng.c | 7 +- lib/pipeline/rte_swx_ctl.c | 11 +- lib/pipeline/rte_swx_pipeline.c | 21 ++- lib/pipeline/rte_swx_pipeline_internal.h | 10 +- lib/power/rte_power_pmd_mgmt.c | 6 +- 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 +- 109 files changed, 477 insertions(+), 412 deletions(-)
--
2.51.0
PATCH v4 1/31 eal: add more min/max helpers
From: Stephen Hemminger <[email protected]>
Add RTE_MIN3() to handle case of RTE_MIN(RTE_MIN(...)), and similarly add RTE_MAX3(). Change name of local temporary variables in existing macros to allow for combinations of RTE_MIN(RTE_MAX(...)) without causing shadow declaration warnings.
--- lib/eal/include/rte_common.h | 38 ++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)
lib/eal/include/rte_common.h +32 -6
@@ -794,9 +794,22 @@ __extension__ typedef uint64_t RTE_MARKER64[0];*/ #define RTE_MIN (a, b) \ __extension__ ({ \ - typeof (a) _a = (a); \ - typeof (b) _b = (b); \ - _a < _b ? _a : _b; \ + typeof (a) _a_min = (a); \ + typeof (b) _b_min = (b); \ + _a_min < _b_min ? _a_min : _b_min; \ + }) + +/** +* Macro to return the minimum of three numbers +*/ +#define RTE_MIN3 (a, b, c) \ + __extension__ ({ \ + typeof (a) _a_min3 = (a); \ + typeof (b) _b_min3 = (b); \ + typeof (c) _c_min3 = (c); \ + _a_min3 < _b_min3 ? \ + (_a_min3 < _c_min3 ? _a_min3 : _c_min3) : \ + (_b_min3 < _c_min3 ? _b_min3 : _c_min3); \ })/**
@@ -814,9 +827,22 @@ __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) _a_max = (a); \ + typeof (b) _b_max = (b); \ + _a_max > _b_max ? _a_max : _b_max; \ + }) + +/** +* Macro to return the maximum of three numbers +*/ +#define RTE_MAX3 (a, b, c) \ + __extension__ ({ \ + typeof (a) _a_max3 = (a); \ + typeof (b) _b_max3 = (b); \ + typeof (c) _c_max3 = (c); \ + _a_max3 > _b_max3 ? \ + (_a_max3 > _c_max3 ? _a_max3 : _c_max3) : \ + (_b_max3 > _c_max3 ? _b_max3 : _c_max3); \ })/**
Signature · 1 line
2.51.0
PATCH v4 2/31 eal: fix variable shadowing
In reply to Bruce RichardsonFix 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
--- drivers/bus/pci/windows/pci.c | 1 - lib/eal/common/eal_common_options.c | 22 +++---- lib/eal/common/eal_common_trace.c | 89 ++++++++++++++--------------- lib/eal/common/malloc_heap.c | 2 +- 4 files changed, 56 insertions(+), 58 deletions(-)
drivers/bus/pci/windows/pci.c +0 -1
@@ -433,7 +433,6 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)rte_pci_add_device (dev); }else {struct rte_pci_device *dev2 =NULL ; -int ret; TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) { ret =rte_pci_addr_cmp (&dev->addr, &dev2->addr);
lib/eal/common/eal_common_options.c +11 -11
@@ -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; }
@@ -429,21 +429,21 @@ eal_clean_saved_args(void)#endif /* !RTE_EXEC_ENV_WINDOWS */ 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);
lib/eal/common/eal_common_trace.c +44 -45
196 lines not on this page · raw message
lib/eal/common/malloc_heap.c +1 -1
@@ -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
Signature · 1 line
2.51.0
PATCH v4 3/31 ethdev: fix variable shadowing issues
In reply to Bruce RichardsonRemove unneeded extra variable definitions, and rename variables as necessary to ensure clean compile with -Wshadow warnings enabled.
--- lib/ethdev/ethdev_driver.c | 6 +++--- lib/ethdev/rte_ethdev.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
lib/ethdev/ethdev_driver.c +3 -3
@@ -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" );
lib/ethdev/rte_ethdev.c +0 -1
@@ -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);
Signature · 1 line
2.51.0
PATCH v4 4/31 eventdev: fix variable shadowing issues
In reply to Bruce RichardsonRename a macro variable to avoid shadowing conflicts, and reduce the scope of another variable for the same reason.
--- 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(-)
lib/eventdev/rte_event_eth_rx_adapter.c +2 -3
@@ -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;
lib/eventdev/rte_event_eth_tx_adapter.c +4 -4
@@ -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)
Signature · 1 line
2.51.0
Re: [PATCH v4 04/31] eventdev: fix variable shadowing issues
Quoted 38 lines · Bruce Richardson
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")Signed-off-by Bruce Richardson <[email protected]>--- 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(-)lib/eventdev/rte_event_eth_rx_adapter.c +1
-2@@ -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;
lib/eventdev/rte_event_eth_rx_adapter.c rxa_intr_ring_dequeue(struct event_eth_rx_adapter *rx_adapter) · line 1291
Quoted 5 lines
lib/eventdev/rte_event_eth_rx_adapter.c +1
-1@@ -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,
Split 'n' definition and the function call.
With or without that fix,
Quoted 23 lines
lib/eventdev/rte_event_eth_rx_adapter.c +0
-0rx_adapter->max_nb_rx, &rxq_empty, buf, stats); rx_adapter->qd_valid = !rxq_empty;lib/eventdev/rte_event_eth_tx_adapter.c +4
-4@@ -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)
PATCH v4 5/31 net: remove shadowed variable
In reply to Bruce RichardsonThe "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.
--- lib/net/net_crc_avx512.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/net/net_crc_avx512.c +1 -3
@@ -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 ) {
Signature · 1 line
2.51.0
PATCH v4 6/31 pipeline: fix variable shadowing
In reply to Bruce RichardsonRemove unnecessary inner variables and rename others in order to remove variable shadowing warnings from the code.
--- 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(-)
lib/pipeline/rte_swx_ctl.c +5 -6
@@ -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);
lib/pipeline/rte_swx_pipeline.c +10 -11
@@ -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;
lib/pipeline/rte_swx_pipeline_internal.h +5 -5
@@ -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 ; }
Signature · 1 line
2.51.0
PATCH v4 7/31 table: fix issues with variable shadowing
In reply to Bruce RichardsonBuilding table library with -Wshadow reveals many warnings from shadowed variables. Fix these by removing definitions, or renaming variables as appropriate.
--- 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(-)
lib/table/rte_lru.h +19 -19
@@ -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 )
lib/table/rte_lru_arm64.h +7 -7
@@ -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
lib/table/rte_lru_x86.h +2 -2
@@ -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! */ \
lib/table/rte_swx_table_em.c +0 -2
@@ -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);
lib/table/rte_swx_table_learner.c +2 -2
@@ -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. */
lib/table/rte_table_hash_key16.c +1 -3
@@ -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);
lib/table/rte_table_hash_key32.c +1 -3
@@ -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);
lib/table/rte_table_hash_key8.c +1 -3
@@ -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);
Signature · 1 line
2.51.0
PATCH v4 8/31 power: rename variable to eliminate shadowing
In reply to Bruce RichardsonThe "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".
--- lib/power/rte_power_pmd_mgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/rte_power_pmd_mgmt.c +3 -3
@@ -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 (); } }
Signature · 1 line
2.51.0
PATCH v4 9/31 pcapng: rename variable to fix shadowing
In reply to Bruce RichardsonThe "len" variable is shadowed within a function, so rename inner use to the more descriptive "filter_len" to fix the issue.
--- lib/pcapng/rte_pcapng.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
lib/pcapng/rte_pcapng.c +3 -4
@@ -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 );
Signature · 1 line
2.51.0
PATCH v4 10/31 bbdev: fix variable shadowing
In reply to Bruce RichardsonThe "ret" variable is declared twice in rte_bbdev_setup_queues function. The second declaration is unneeded so remove it.
--- lib/bbdev/rte_bbdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bbdev/rte_bbdev.c +1 -1
@@ -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",
Signature · 1 line
2.51.0
PATCH v4 11/31 bus/pci: remove shadowed variables
In reply to Bruce RichardsonRemove 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.
--- drivers/bus/pci/linux/pci.c | 1 - drivers/bus/pci/linux/pci_vfio.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/bus/pci/linux/pci.c +0 -1
@@ -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);
drivers/bus/pci/linux/pci_vfio.c +1 -1
@@ -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" );
Signature · 1 line
2.51.0
PATCH v4 12/31 net/intel: rename function param to avoid shadow warnings
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/common/rx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/common/rx.h +3 -3
@@ -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;
Signature · 1 line
2.51.0
PATCH v4 13/31 net/e1000: fix build with shadow warnings enabled
In reply to Bruce RichardsonVariable "ret" was shadowed within the close function, so rename outer variable to "retval" to clear the warnings.
--- drivers/net/intel/e1000/igc_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/e1000/igc_ethdev.c +3 -3
@@ -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
Signature · 1 line
2.51.0
PATCH v4 14/31 net/i40e: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe local variables defined with the I40E_WRITE_GLB_REG macro are shadowing other variables. Rename the vars to start with "_" to avoid this shadowing.
--- drivers/net/intel/i40e/i40e_ethdev.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.h +5 -5
@@ -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 )
Signature · 1 line
2.51.0
PATCH v4 15/31 net/ice: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/ice/ice_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +3 -3
@@ -999,9 +999,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
Signature · 1 line
2.51.0
PATCH v4 16/31 net/cpfl: fix build with shadow warnings enabled
In reply to Bruce RichardsonRemove unnecessary variable definitions to ensure compiling with -Wshadow enabled.
--- 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(-)
drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c +0 -2
@@ -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],
drivers/net/intel/cpfl/cpfl_flow_parser.c +3 -3
@@ -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 ) {
drivers/net/intel/cpfl/cpfl_fxp_rule.h +0 -2
@@ -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,
drivers/net/intel/cpfl/cpfl_representor.h +1 -1
@@ -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);
Signature · 1 line
2.51.0
PATCH v4 17/31 net/ixgbe: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe 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.
--- drivers/net/intel/ixgbe/ixgbe_fdir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/intel/ixgbe/ixgbe_fdir.c +3 -4
@@ -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_infostruct 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 );
Signature · 1 line
2.51.0
PATCH v4 18/31 app/testpmd: fix build with shadow warnings enabled
In reply to Bruce RichardsonRename or remove shadowed variables so as to build cleanly with -Wshadow.
--- app/test-pmd/cmdline_flow.c | 42 ++++++++++++++++++------------------- app/test-pmd/config.c | 15 +++++-------- app/test-pmd/parameters.c | 38 ++++++++++++++++----------------- app/test-pmd/testpmd.c | 2 +- 4 files changed, 45 insertions(+), 52 deletions(-)
app/test-pmd/cmdline_flow.c +21 -21
@@ -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 ;
app/test-pmd/config.c +5 -10
@@ -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_DESCportid_t port_id, -#else - __rte_unused portid_t port_id, -#endifuint16_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 ;
app/test-pmd/parameters.c +18 -20
@@ -777,42 +777,42 @@ parse_ringnuma_config(const char *q_arg) }static int -parse_event_printing_config (const char *optarg,int enable) +parse_event_printing_config (const char *event_arg,int enable) {uint32_t mask =0 ; -if (!strcmp (optarg,"unknown" )) +if (!strcmp (event_arg,"unknown" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_UNKNOWN ; -else if (!strcmp (optarg,"intr_lsc" )) +else if (!strcmp (event_arg,"intr_lsc" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_LSC ; -else if (!strcmp (optarg,"queue_state" )) +else if (!strcmp (event_arg,"queue_state" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_QUEUE_STATE ; -else if (!strcmp (optarg,"intr_reset" )) +else if (!strcmp (event_arg,"intr_reset" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_RESET ; -else if (!strcmp (optarg,"vf_mbox" )) +else if (!strcmp (event_arg,"vf_mbox" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_VF_MBOX ; -else if (!strcmp (optarg,"ipsec" )) +else if (!strcmp (event_arg,"ipsec" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_IPSEC ; -else if (!strcmp (optarg,"macsec" )) +else if (!strcmp (event_arg,"macsec" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_MACSEC ; -else if (!strcmp (optarg,"intr_rmv" )) +else if (!strcmp (event_arg,"intr_rmv" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_INTR_RMV ; -else if (!strcmp (optarg,"dev_probed" )) +else if (!strcmp (event_arg,"dev_probed" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_NEW ; -else if (!strcmp (optarg,"dev_released" )) +else if (!strcmp (event_arg,"dev_released" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_DESTROY ; -else if (!strcmp (optarg,"flow_aged" )) +else if (!strcmp (event_arg,"flow_aged" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_FLOW_AGED ; -else if (!strcmp (optarg,"err_recovering" )) +else if (!strcmp (event_arg,"err_recovering" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_ERR_RECOVERING ; -else if (!strcmp (optarg,"recovery_success" )) +else if (!strcmp (event_arg,"recovery_success" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_RECOVERY_SUCCESS ; -else if (!strcmp (optarg,"recovery_failed" )) +else if (!strcmp (event_arg,"recovery_failed" )) mask =UINT32_C (1 ) <<RTE_ETH_EVENT_RECOVERY_FAILED ; -else if (!strcmp (optarg,"all" )) +else if (!strcmp (event_arg,"all" )) mask = ~UINT32_C (0 );else { -fprintf (stderr,"Invalid event: %s\n" , optarg); +fprintf (stderr,"Invalid event: %s\n" , event_arg);return -1 ; }if (enable)
@@ -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 );
app/test-pmd/testpmd.c +1 -1
@@ -4660,7 +4660,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",
Signature · 1 line
2.51.0
PATCH v4 19/31 app/graph: fix build with shadow warnings enabled
In reply to Bruce RichardsonThe global variable "conn" conflicted with the local parameter to each function in the graph conn.c file. To prevent shadowing, use "c" as the name for the local connection variable throughout the file.
--- app/graph/conn.c | 134 +++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 67 deletions(-)
app/graph/conn.c +67 -67
@@ -20,12 +20,12 @@#define MSG_CMD_TOO_LONG "Command too long."static int -data_event_handle (struct conn *conn,int fd_client) +data_event_handle (struct conn *c,int fd_client) {ssize_t len, i, rc =0 ;/* Read input message */ - len =read (fd_client, conn->buf, conn->buf_size); + len =read (fd_client, c->buf, c->buf_size);if (len ==-1 ) {if ((errno ==EAGAIN ) || (errno ==EWOULDBLOCK ))return 0 ;
@@ -38,37 +38,37 @@ data_event_handle(struct conn *conn, int fd_client)/* Handle input messages */ for (i =0 ; i < len; i++) { -if (conn->buf[i] =='\n' ) { +if (c->buf[i] =='\n' ) {size_t n; - conn->msg_in[conn->msg_in_len] =0 ; - conn->msg_out[0 ] =0 ; + c->msg_in[c->msg_in_len] =0 ; + c->msg_out[0 ] =0 ; - conn->msg_handle (conn->msg_in, conn->msg_out, conn->msg_out_len_max, - conn->msg_handle_arg); + c->msg_handle (c->msg_in, c->msg_out, c->msg_out_len_max, + c->msg_handle_arg); - n =strlen (conn->msg_out); + n =strlen (c->msg_out);if (n) { - rc =write (fd_client, conn->msg_out, n); + rc =write (fd_client, c->msg_out, n);if (rc ==-1 ) goto exit; } - conn->msg_in_len =0 ; - }else if (conn->msg_in_len < conn->msg_in_len_max) { - conn->msg_in[conn->msg_in_len] = conn->buf[i]; - conn->msg_in_len++; + c->msg_in_len =0 ; + }else if (c->msg_in_len < c->msg_in_len_max) { + c->msg_in[c->msg_in_len] = c->buf[i]; + c->msg_in_len++; }else { rc =write (fd_client,MSG_CMD_TOO_LONG ,strlen (MSG_CMD_TOO_LONG ));if (rc ==-1 ) goto exit; - conn->msg_in_len =0 ; + c->msg_in_len =0 ; } }/* Write prompt */ - rc =write (fd_client, conn->prompt,strlen (conn->prompt)); + rc =write (fd_client, c->prompt,strlen (c->prompt)); rc = (rc ==-1 ) ?-1 :0 ; exit:
@@ -76,11 +76,11 @@ data_event_handle(struct conn *conn, int fd_client) }static int -control_event_handle (struct conn *conn,int fd_client) +control_event_handle (struct conn *c,int fd_client) {int rc; - rc =epoll_ctl (conn->fd_client_group,EPOLL_CTL_DEL , fd_client,NULL ); + rc =epoll_ctl (c->fd_client_group,EPOLL_CTL_DEL , fd_client,NULL );if (rc ==-1 ) goto exit;
@@ -99,7 +99,7 @@ conn_init(struct conn_params *p) {int fd_server, fd_client_group, rc;struct sockaddr_in server_address; -struct conn *conn =NULL ; +struct conn *c =NULL ;int reuse =1 ;memset (&server_address,0 ,sizeof (server_address));
@@ -115,20 +115,20 @@ conn_init(struct conn_params *p) goto exit;/* Memory allocation */ - conn =calloc (1 ,sizeof (struct conn )); -if (conn ==NULL ) + c =calloc (1 ,sizeof (struct conn )); +if (c ==NULL ) goto exit; - conn->welcome =calloc (1 ,CONN_WELCOME_LEN_MAX +1 ); - conn->prompt =calloc (1 ,CONN_PROMPT_LEN_MAX +1 ); - conn->buf =calloc (1 , p->buf_size); - conn->msg_in =calloc (1 , p->msg_in_len_max +1 ); - conn->msg_out =calloc (1 , p->msg_out_len_max +1 ); + c->welcome =calloc (1 ,CONN_WELCOME_LEN_MAX +1 ); + c->prompt =calloc (1 ,CONN_PROMPT_LEN_MAX +1 ); + c->buf =calloc (1 , p->buf_size); + c->msg_in =calloc (1 , p->msg_in_len_max +1 ); + c->msg_out =calloc (1 , p->msg_out_len_max +1 ); -if ((conn->welcome ==NULL ) || (conn->prompt ==NULL ) || (conn->buf ==NULL ) || - (conn->msg_in ==NULL ) || (conn->msg_out ==NULL )) { -conn_free (conn); - conn =NULL ; +if ((c->welcome ==NULL ) || (c->prompt ==NULL ) || (c->buf ==NULL ) || + (c->msg_in ==NULL ) || (c->msg_out ==NULL )) { +conn_free (c); + c =NULL ; goto exit; }
@@ -138,8 +138,8 @@ conn_init(struct conn_params *p) fd_server =socket (AF_INET ,SOCK_STREAM |SOCK_NONBLOCK ,0 );if (fd_server ==-1 ) { -conn_free (conn); - conn =NULL ; +conn_free (c); + c =NULL ; goto exit; }
@@ -161,47 +161,47 @@ conn_init(struct conn_params *p) goto free;/* Fill in */ -rte_strscpy (conn->welcome, p->welcome,CONN_WELCOME_LEN_MAX ); -rte_strscpy (conn->prompt, p->prompt,CONN_PROMPT_LEN_MAX ); - conn->buf_size = p->buf_size; - conn->msg_in_len_max = p->msg_in_len_max; - conn->msg_out_len_max = p->msg_out_len_max; - conn->msg_in_len =0 ; - conn->fd_server = fd_server; - conn->fd_client_group = fd_client_group; - conn->msg_handle = p->msg_handle; - conn->msg_handle_arg = p->msg_handle_arg; +rte_strscpy (c->welcome, p->welcome,CONN_WELCOME_LEN_MAX ); +rte_strscpy (c->prompt, p->prompt,CONN_PROMPT_LEN_MAX ); + c->buf_size = p->buf_size; + c->msg_in_len_max = p->msg_in_len_max; + c->msg_out_len_max = p->msg_out_len_max; + c->msg_in_len =0 ; + c->fd_server = fd_server; + c->fd_client_group = fd_client_group; + c->msg_handle = p->msg_handle; + c->msg_handle_arg = p->msg_handle_arg; exit: -return conn; +return c; free: -conn_free (conn); +conn_free (c);close (fd_server); - conn =NULL ; -return conn; + c =NULL ; +return c; }void -conn_free (struct conn *conn) +conn_free (struct conn *c) { -if (conn ==NULL ) +if (c ==NULL )return ; -if (conn->fd_client_group) -close (conn->fd_client_group); +if (c->fd_client_group) +close (c->fd_client_group); -if (conn->fd_server) -close (conn->fd_server); +if (c->fd_server) +close (c->fd_server); -free (conn->msg_out); -free (conn->msg_in); -free (conn->prompt); -free (conn->welcome); -free (conn); +free (c->msg_out); +free (c->msg_in); +free (c->prompt); +free (c->welcome); +free (c); }int -conn_req_poll (struct conn *conn) +conn_req_poll (struct conn *c) {struct sockaddr_in client_address;socklen_t client_address_length;
@@ -209,12 +209,12 @@ conn_req_poll(struct conn *conn)int fd_client, rc;/* Check input arguments */ -if (conn ==NULL ) +if (c ==NULL )return -1 ;/* Server socket */ client_address_length =sizeof (client_address); - fd_client =accept4 (conn->fd_server, (struct sockaddr *)&client_address, + fd_client =accept4 (c->fd_server, (struct sockaddr *)&client_address, &client_address_length,SOCK_NONBLOCK );if (fd_client ==-1 ) {if ((errno ==EAGAIN ) || (errno ==EWOULDBLOCK ))
@@ -227,20 +227,20 @@ conn_req_poll(struct conn *conn) event.events =EPOLLIN |EPOLLRDHUP |EPOLLHUP ; event.data.fd = fd_client; - rc =epoll_ctl (conn->fd_client_group,EPOLL_CTL_ADD , fd_client, &event); + rc =epoll_ctl (c->fd_client_group,EPOLL_CTL_ADD , fd_client, &event);if (rc ==-1 ) {close (fd_client); goto exit; }/* Client */ - rc =write (fd_client, conn->welcome,strlen (conn->welcome)); + rc =write (fd_client, c->welcome,strlen (c->welcome));if (rc ==-1 ) {close (fd_client); goto exit; } - rc =write (fd_client, conn->prompt,strlen (conn->prompt)); + rc =write (fd_client, c->prompt,strlen (c->prompt));if (rc ==-1 ) {close (fd_client); goto exit;
@@ -253,17 +253,17 @@ conn_req_poll(struct conn *conn) }int -conn_msg_poll (struct conn *conn) +conn_msg_poll (struct conn *c) {int fd_client, rc, rc_data =0 , rc_control =0 ;struct epoll_event event;/* Check input arguments */ -if (conn ==NULL ) +if (c ==NULL )return -1 ;/* Client group */ - rc =epoll_wait (conn->fd_client_group, &event,1 ,0 ); + rc =epoll_wait (c->fd_client_group, &event,1 ,0 );if ((rc ==-1 ) || rc ==0 )return rc;
@@ -271,11 +271,11 @@ conn_msg_poll(struct conn *conn)/* Data available */ if (event.events &EPOLLIN ) - rc_data =data_event_handle (conn, fd_client); + rc_data =data_event_handle (c, fd_client);/* Control events */ if (event.events & (EPOLLRDHUP |EPOLLERR |EPOLLHUP )) - rc_control =control_event_handle (conn, fd_client); + rc_control =control_event_handle (c, fd_client);if (rc_data || rc_control)return -1 ;
Signature · 1 line
2.51.0
PATCH v4 20/31 app/pdump: fix warning about shadowed variable
In reply to Bruce RichardsonThe variable name "optarg" is a standard global variable in getopt, so use of that name for function parameters causes shadowing warnings. Rename the variable to avoid these issues.
--- app/pdump/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/pdump/main.c +6 -6
@@ -247,7 +247,7 @@ parse_uint_value(const char *key, const char *value, void *extra_args) }static int -parse_pdump (const char *optarg) +parse_pdump (const char *arg) {struct rte_kvargs *kvlist;int ret =0 , cnt1, cnt2;
@@ -257,9 +257,9 @@ parse_pdump(const char *optarg) pt = &pdump_t[num_tuples];/* initial check for invalid arguments */ - kvlist =rte_kvargs_parse (optarg, valid_pdump_arguments); + kvlist =rte_kvargs_parse (arg, valid_pdump_arguments);if (kvlist ==NULL ) { -printf ("--pdump=\"%s\": invalid argument passed\n" , optarg); +printf ("--pdump=\"%s\": invalid argument passed\n" , arg);return -1 ; }
@@ -268,7 +268,7 @@ parse_pdump(const char *optarg) cnt2 =rte_kvargs_count (kvlist,PDUMP_PCI_ARG );if (!((cnt1 ==1 && cnt2 ==0 ) || (cnt1 ==0 && cnt2 ==1 ))) {printf ("--pdump=\"%s\": must have either port or " -"device_id argument\n" , optarg); +"device_id argument\n" , arg); ret =-1 ; goto free_kvlist; }else if (cnt1 ==1 ) {
@@ -290,7 +290,7 @@ parse_pdump(const char *optarg)/* queue parsing and validation */ cnt1 =rte_kvargs_count (kvlist,PDUMP_QUEUE_ARG );if (cnt1 !=1 ) { -printf ("--pdump=\"%s\": must have queue argument\n" , optarg); +printf ("--pdump=\"%s\": must have queue argument\n" , arg); ret =-1 ; goto free_kvlist; }
@@ -303,7 +303,7 @@ parse_pdump(const char *optarg) cnt2 =rte_kvargs_count (kvlist,PDUMP_TX_DEV_ARG );if (cnt1 ==0 && cnt2 ==0 ) {printf ("--pdump=\"%s\": must have either rx-dev or " -"tx-dev argument\n" , optarg); +"tx-dev argument\n" , arg); ret =-1 ; goto free_kvlist; }else if (cnt1 ==1 && cnt2 ==1 ) {
Signature · 1 line
2.51.0
PATCH v4 21/31 app/test-bbdev: remove shadow warning from next max calls
In reply to Bruce RichardsonNested use of RTE_MAX leads to variable shadowing for the internal variables, so use RTE_MAX3 rather than two nested calls.
--- app/test-bbdev/test_bbdev_perf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
app/test-bbdev/test_bbdev_perf.c +3 -4
@@ -552,12 +552,11 @@ create_mempools(struct active_device *ad, int socket_id, &test_vector.entries[DATA_HARQ_OUTPUT ];/* allocate ops mempool */ - ops_pool_size =optimal_mempool_size (RTE_MAX ( + ops_pool_size =optimal_mempool_size (RTE_MAX3 (/* Ops used plus 1 reference op */ -RTE_MAX ((unsigned int )(ad->nb_queues * num_ops +1 ), + (unsigned int )(ad->nb_queues * num_ops +1 ),/* Minimal cache size plus 1 reference op */ - (unsigned int )(1.5 *rte_lcore_count () * -OPS_CACHE_SIZE +1 )), + (unsigned int )(1.5 *rte_lcore_count () *OPS_CACHE_SIZE +1 ),OPS_POOL_SIZE_MIN ));if (org_op_type ==RTE_BBDEV_OP_NONE )
Signature · 1 line
2.51.0