Fix building much of DPDK with -Wshadow
Subsystems (7)
PATCH v4 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 v4 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 v4 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 v4 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 v4 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 v4 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 v4 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 v4 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 v4 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 v4 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 v4 00/31] build DPDK with Wshadow flag
In reply to Bruce RichardsonQuoted 181 lines · On Wed, 14 Jan 2026 15:44:14 +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.
V4:
* Updates follow AI review:
- improve variable naming in min/max fns
- remove extra blank line
* rebase on latest mainv3:
* 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 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-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(-)
Quoted 3 lines
--
2.51.0
AI review gives thumbs up on this...
## DPDK Patch Series Review: Shadow Warning Fixes (v4)
### Series Overview
| Aspect | Details | |--------|---------| | **Series** | [PATCH v4 01-31/31] Shadow warning fixes | | **Submitter** | Bruce Richardson (Intel) | | **Original Author (Patch 1)** | Stephen Hemminger | | **Purpose** | Enable `-Wshadow` compiler warning globally |
---
## Patch-by-Patch Evaluation
### Patch 01/31: eal: add more min/max helpers
**Commit Message:**
| Check | Status | Notes | |-------|--------|-------| | Subject ≤60 chars | ✓ | "eal: add more min/max helpers" (27 chars) | | Correct prefix | ✓ | `eal:` is correct for lib/eal | | Lowercase after colon | ✓ | | | Imperative mood | ✓ | "add" | | No trailing period | ✓ | | | Signed-off-by present | ✓ | Stephen Hemminger + Bruce Richardson | | Body does not start with "It" | ✓ | |
**Code Review:**
- **Logic**: Adds RTE_MIN3() and RTE_MAX3() macros, and renames internal variables (_a→_a_min, etc.) to avoid shadow conflicts when nesting MIN/MAX calls. Sound approach.
**Warning - Minor style issue in RTE_MIN3:**
```c _a_min3 < _b_min3 ? \ (_a_min3 < _c_min3 ? _a_min3 : _c_min3) : \ (_b_min3 < _c_min3 ? _b_min3 : _c_min3); \ ```
Line 3 has inconsistent indentation (spaces vs tabs for alignment) and a trailing double-space before the backslash. The same issue exists in RTE_MAX3.
---
### Patch 02/31: eal: fix variable shadowing
**Commit Message:**
| Check | Status | Notes | |-------|--------|-------| | Subject ≤60 chars | ✓ | 26 chars | | Bugzilla ID present | ✓ | IDs 1742 and 1743 | | Fixes: tags | ✓ | 3 Fixes with 12-char SHA and exact subjects | | Cc: [email protected] | ✓ | Present for bug fix | | Tag order | ✓ | Bugzilla ID → Fixes → Cc → Signed-off-by → Acked-by |
**Code Review:** Clean refactoring - renames trace to t for local variables, renames args to out_args, removes redundant aligned_end redefinition.
---
### Patches 03-11: Library Fixes
All follow the same pattern for ethdev, eventdev, net, pipeline, table, power, pcapng, bbdev, and bus/pci. Each:
- Has proper Fixes: tags with 12-char SHA
- Has Cc: [email protected]
- Has appropriate Acked-by tags
- Correctly removes shadowed variables by renaming or removing redundant definitions
---
### Patches 12-17: Intel Driver Fixes (net/intel, e1000, i40e, ice, cpfl, ixgbe)
**Patch 14 (i40e) - Good macro fix:**
```c - struct rte_eth_dev *dev;\ + struct rte_eth_dev *_dev;\ ```
Correctly prefixes macro-internal variables with _ to avoid shadowing.
**Patch 15 (ice):** Converts nested RTE_MIN(RTE_MIN(...)) to two separate calls - necessary workaround for the old macro implementation.
---
### Patches 18-27: Application Fixes (testpmd, app/graph, pdump, etc.)
**Patch 18 (testpmd):** Several good fixes:
- Renames opt to geneve_opt, gtp_opt, gre_opt for clarity
- Removes unnecessary rss_hf intermediate variable
- Renames optarg parameter to event_arg to avoid shadowing the global optarg from getopt
**Patch 19 (app/graph):** Renames function parameter conn to c throughout to avoid shadowing global variable. Good systematic approach.
---
### Patches 28-30: Bulk Disable for Drivers/Tests/Examples
These patches add cflags += no_shadow_cflag to meson.build files for components that have extensive shadow warnings. This is a pragmatic approach for:
- **Drivers**: ~35 drivers that need cleanup later
- **app/test**: Unit tests with many warnings
- **examples**: ~24 example apps
---
### Patch 31/31: Enable -Wshadow globally
Adds -Wshadow to the global compiler flags, completing the series.
---
## Overall Assessment
### Errors (Must Fix)
**None found.** All commit messages follow DPDK standards.
### Warnings (Should Fix)
| Issue | Location | Severity | |-------|----------|----------| | Inconsistent indentation (spaces vs tabs) | Patch 01, RTE_MIN3/RTE_MAX3 | Warning | | Trailing double-space before backslash | Patch 01, line endings | Warning |
### Info (Consider)
1. **Patch 01**: The new RTE_MIN3/RTE_MAX3 macros lack @param documentation in the Doxygen comment. Consider adding:
```c
/**
* Macro to return the minimum of three numbers
* @param a First number
* @param b Second number
* @param c Third number
*/
```2. **Series organization**: The series is well-structured, fixing core issues first, then building up through libraries, drivers, and apps before enabling the warning globally.
---
## Verdict
**Recommended: Acked-by** with minor style fixes requested for Patch 01.
The series is comprehensive and well-executed. It systematically enables an important compiler warning while maintaining buildability by temporarily disabling it where extensive cleanup would be needed. The approach of fixing core libraries first and deferring driver/example cleanup is pragmatic for a large codebase.
Re: [PATCH v4 00/31] build DPDK with Wshadow flag
In reply to Bruce RichardsonHello Bruce,
Quoted 173 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.
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 mainv3:
* 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 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-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 ++---
Quoted 8 lines
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(-)
Series applied, thanks.
Signature · 1 line
David Marchand