examples: enable -Wshadow across all examples
cover examples: enable -Wshadow across all examples
Several DPDK examples had -Wshadow disabled via no_shadow_cflag in their meson.build files. This series fixes all shadow variable warnings and removes the suppression flag, so that -Wshadow is enabled uniformly across every example.
The fixes fall into three categories:
- Renaming function parameters or local variables that shadow globals (most patches)
- Removing unused function parameters that duplicated globals (dma, bond, flow_filtering, ipsec-secgw, vhost, qos_sched)
- Simply removing no_shadow_cflag where there were no warnings (vm_power_manage, bbdev_app, l2fwd-crypto, l2fwd-event, l3fwd-graph)
All the patches are listed as fixes they are not worth back porting so no Fixes: tag is given.
Stephen Hemminger (23):
examples/ethtool: fix shadow variable warning examples/eventdev_pipeline: fix shadow variable warning examples/dma: fix shadow variable warnings examples/packet_ordering: fix shadow variable warning examples/bond: fix shadow variable warnings examples/vmdq: fix shadow variable warning examples/server_node_efd: fix shadowed variable examples/flow_filtering: fix shadowed variables examples/ipsec-secgw: fix shadowed variables examples/ip_pipeline: fix shadow variable examples/multi_process: fix shadowed variable examples/vm_power_manage: enable shadow warnings examples/bbdev_app: enable shadow warnings examples/ptpclient: fix shadow variable warnings examples/vhost: fix shadow warnings examples/qos_sched: eliminate shadowed variables examples/l2fwd-jobstats: fix shadowed variable examples/l2fwd-crypto: remove no shadow flag examples/l2fwd-event: remove no shadow flag examples/l2fwd-keepalive: fix shadow variable warning examples/l3fwd-graph: remove no shadow flag examples/l3fwd: fix shadow variable warnings examples/l3fwd-power: fix shadow variable warnings
examples/bbdev_app/meson.build | 1 - examples/bond/main.c | 21 ++- examples/bond/meson.build | 1 - examples/dma/dmafwd.c | 10 +- examples/dma/meson.build | 1 - examples/ethtool/ethtool-app/main.c | 4 +- examples/ethtool/meson.build | 1 - examples/eventdev_pipeline/meson.build | 1 - .../eventdev_pipeline/pipeline_worker_tx.c | 4 +- examples/flow_filtering/flow_skeleton.c | 10 +- examples/flow_filtering/main.c | 4 +- examples/flow_filtering/meson.build | 1 - examples/ip_pipeline/cli.c | 9 +- examples/ip_pipeline/meson.build | 1 - examples/ipsec-secgw/ipsec-secgw.c | 3 +- examples/ipsec-secgw/ipsec.c | 3 +- examples/ipsec-secgw/ipsec.h | 1 - examples/ipsec-secgw/ipsec_worker.c | 30 ++-- examples/ipsec-secgw/ipsec_worker.h | 4 +- examples/ipsec-secgw/meson.build | 1 - examples/ipsec-secgw/sa.c | 34 ++--- examples/l2fwd-crypto/meson.build | 1 - examples/l2fwd-event/meson.build | 1 - examples/l2fwd-jobstats/main.c | 6 +- examples/l2fwd-jobstats/meson.build | 1 - examples/l2fwd-keepalive/main.c | 2 +- examples/l2fwd-keepalive/meson.build | 1 - examples/l3fwd-graph/meson.build | 1 - examples/l3fwd-power/main.c | 12 +- examples/l3fwd-power/meson.build | 1 - examples/l3fwd/l3fwd.h | 2 +- examples/l3fwd/l3fwd_em.c | 32 ++-- examples/l3fwd/l3fwd_em_hlm.h | 8 +- examples/l3fwd/l3fwd_lpm.c | 4 +- examples/l3fwd/l3fwd_route.h | 12 +- examples/l3fwd/main.c | 12 +- examples/l3fwd/meson.build | 1 - .../client_server_mp/mp_server/args.c | 12 +- .../client_server_mp/mp_server/meson.build | 1 - examples/packet_ordering/main.c | 6 +- examples/packet_ordering/meson.build | 1 - examples/ptpclient/meson.build | 1 - examples/ptpclient/ptpclient.c | 138 +++++++++--------- examples/qos_sched/cfg_file.c | 12 +- examples/qos_sched/cfg_file.h | 4 +- examples/qos_sched/init.c | 4 +- examples/qos_sched/meson.build | 1 - examples/server_node_efd/efd_server/args.c | 6 +- .../server_node_efd/efd_server/meson.build | 1 - examples/vhost/main.c | 19 +-- examples/vhost/meson.build | 1 - .../vm_power_manager/guest_cli/meson.build | 1 - examples/vm_power_manager/meson.build | 1 - examples/vmdq/main.c | 8 +- examples/vmdq/meson.build | 1 - 55 files changed, 216 insertions(+), 244 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/23 examples/ethtool: fix shadow variable warning
Fix shadow variable warning by renaming the function parameter from 'app_cfg' to 'ptr_cfg' to avoid shadowing the global variable.
../examples/ethtool/ethtool-app/main.c:89:44: warning: declaration of 'app_cfg' shadows a global declaration [-Wshadow]
--- examples/ethtool/ethtool-app/main.c | 4 ++-- examples/ethtool/meson.build | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
examples/ethtool/ethtool-app/main.c +2 -2
@@ -86,7 +86,7 @@ void mark_port_newmac(int idx_port) ptr_port->port_dirty =1 ; } -static void setup_ports (struct app_config *app_cfg,int cnt_ports) +static void setup_ports (struct app_config *ptr_cfg,int cnt_ports) {int idx_port;int size_pktpool;
@@ -101,7 +101,7 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) cfg_port.txmode.mq_mode =RTE_ETH_MQ_TX_NONE ;for (idx_port =0 ; idx_port < cnt_ports; idx_port++) { -struct app_port *ptr_port = &app_cfg->ports[idx_port]; +struct app_port *ptr_port = &ptr_cfg->ports[idx_port]; ret =rte_eth_dev_info_get (idx_port, &dev_info);if (ret !=0 )
examples/ethtool/meson.build +0 -1
@@ -17,7 +17,6 @@ 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')
Signature · 1 line
2.53.0
PATCH 2/23 examples/eventdev_pipeline: fix shadow variable warning
In reply to Stephen HemmingerFix shadow variable warning by reusing the existing 'ret' variable instead of declaring a new one with the same name.
../examples/eventdev_pipeline/pipeline_worker_tx.c:877:25: warning:
declaration of 'ret' shadows a previous local [-Wshadow]
--- examples/eventdev_pipeline/meson.build | 1 - examples/eventdev_pipeline/pipeline_worker_tx.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
examples/eventdev_pipeline/meson.build +0 -1
@@ -13,4 +13,3 @@ sources = files( 'pipeline_worker_generic.c', 'pipeline_worker_tx.c', ) -cflags += no_shadow_cflag
examples/eventdev_pipeline/pipeline_worker_tx.c +2 -2
@@ -874,8 +874,8 @@ init_adapters(uint16_t nb_ports) service.callback = service_rx_adapter; service.callback_userdata = (void *)adptr_services; -int32_t ret =rte_service_component_register (&service, - &fdata->rxadptr_service_id); + ret =rte_service_component_register (&service, + &fdata->rxadptr_service_id);if (ret)rte_exit (EXIT_FAILURE ,"Rx adapter service register failed" );
Signature · 1 line
2.53.0
PATCH 3/23 examples/dma: fix shadow variable warnings
In reply to Stephen HemmingerFix shadow variable warnings by:
- Renaming 'copy_mode' parameter to 'mode' in dma_parse_copy_mode()
- Removing 'nb_queues' parameter from port_init() and using the global variable directly, since it's always called with the global nb_queues value
../examples/dma/dmafwd.c:593:33: warning: declaration of 'copy_mode' shadows a global declaration [-Wshadow] ../examples/dma/dmafwd.c:881:68: warning: declaration of 'nb_queues' shadows a global declaration [-Wshadow]
--- examples/dma/dmafwd.c | 10 +++++----- examples/dma/meson.build | 1 - 2 files changed, 5 insertions(+), 6 deletions(-)
examples/dma/dmafwd.c +5 -5
@@ -590,11 +590,11 @@ dma_parse_portmask(const char *portmask) }static copy_mode_t -dma_parse_copy_mode (const char *copy_mode) +dma_parse_copy_mode (const char *mode) { -if (strcmp (copy_mode,COPY_MODE_SW ) ==0 ) +if (strcmp (mode,COPY_MODE_SW ) ==0 )return COPY_MODE_SW_NUM ; -else if (strcmp (copy_mode,COPY_MODE_DMA ) ==0 ) +else if (strcmp (mode,COPY_MODE_DMA ) ==0 )return COPY_MODE_DMA_NUM ;return COPY_MODE_INVALID_NUM ;
@@ -878,7 +878,7 @@ config_port_max_pkt_len(struct rte_eth_conf *conf,* coming from the mbuf_pool passed as a parameter. */ static inline void -port_init (uint16_t portid,struct rte_mempool *mbuf_pool,uint16_t nb_queues) +port_init (uint16_t portid,struct rte_mempool *mbuf_pool) {/* Configuring port to use RSS for multiple RX queues. 8< */ static const struct rte_eth_conf port_conf = {
@@ -1061,7 +1061,7 @@ main(int argc, char **argv)/* Initialize each port. 8< */ cfg.nb_ports =0 ;RTE_ETH_FOREACH_DEV (portid) -port_init (portid, dma_pktmbuf_pool, nb_queues); +port_init (portid, dma_pktmbuf_pool);/* >8 End of initializing each port. */ /* Initialize port xstats */
examples/dma/meson.build +0 -1
@@ -13,4 +13,3 @@ deps += ['argparse', 'dmadev'] sources = files( 'dmafwd.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 4/23 examples/packet_ordering: fix shadow variable warning
In reply to Stephen HemmingerFix shadow variable warning by renaming the parameter from 'portmask' to 'mask' in parse_portmask() to avoid shadowing the global variable.
../examples/packet_ordering/main.c:147:28: warning: declaration of 'portmask' shadows a global declaration [-Wshadow]
--- examples/packet_ordering/main.c | 6 +++--- examples/packet_ordering/meson.build | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
examples/packet_ordering/main.c +3 -3
@@ -144,14 +144,14 @@ print_usage(const char *prgname) }static int -parse_portmask (const char *portmask) +parse_portmask (const char *mask) {unsigned long pm;char *end =NULL ;/* parse hexadecimal string */ - pm =strtoul (portmask, &end,16 ); -if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) + pm =strtoul (mask, &end,16 ); +if ((mask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))return 0 ;return pm;
examples/packet_ordering/meson.build +0 -1
@@ -11,4 +11,3 @@ deps += 'reorder' sources = files( 'main.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 5/23 examples/bond: fix shadow variable warnings
In reply to Stephen HemmingerFix shadow variable warnings
- remove mbuf_pool parameters since member_port_init() and bond_port_init() always called with same pool.
- rename members array used in show command
- make the variables static
--- examples/bond/main.c | 21 ++++++++++----------- examples/bond/meson.build | 1 - 2 files changed, 10 insertions(+), 12 deletions(-)
examples/bond/main.c +10 -11
@@ -96,13 +96,12 @@ ":%02"PRIx8":%02"PRIx8":%02"PRIx8, \ RTE_ETHER_ADDR_BYTES(&addr)) -uint16_t members[RTE_MAX_ETHPORTS ]; -uint16_t members_count; +static uint16_t members[RTE_MAX_ETHPORTS ]; +static uint16_t members_count; +static struct rte_mempool *mbuf_pool;static uint16_t BOND_PORT =0xffff ; -static struct rte_mempool *mbuf_pool; -static struct rte_eth_conf port_conf = { .rxmode = { .mq_mode =RTE_ETH_MQ_RX_NONE ,
@@ -119,7 +118,7 @@ static struct rte_eth_conf port_conf = { };static void -member_port_init (uint16_t portid,struct rte_mempool *mbuf_pool) +member_port_init (uint16_t portid) {int retval;uint16_t nb_rxd =RTE_RX_DESC_DEFAULT ;
@@ -204,7 +203,7 @@ member_port_init(uint16_t portid, struct rte_mempool *mbuf_pool) }static void -bond_port_init (struct rte_mempool *mbuf_pool) +bond_port_init (void ) {int retval;uint8_t i;
@@ -462,10 +461,10 @@ static inline void get_string(struct cmd_send_result *res, char *buf, uint8_t si ((unsigned )((unsigned char *)&(res->ip.addr.ipv4))[3 ]) ); } +void cmd_send_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data) { -struct cmd_send_result *res = parsed_result;char ip_str[INET6_ADDRSTRLEN ];
@@ -635,7 +634,7 @@ cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unusvoid cmd_show_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data) { -uint16_t members[16 ] = {0 }; +uint16_t act_members[16 ] = {0 };uint8_t len =16 ;struct rte_ether_addr addr;uint16_t i;
@@ -658,7 +657,7 @@ cmd_show_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unuscmdline_printf (cl,"Active_members:%d " "packets received:Tot:%d Arp:%d IPv4:%d\n" , -rte_eth_bond_active_members_get (BOND_PORT , members, len), +rte_eth_bond_active_members_get (BOND_PORT , act_members, len), global_flag_stru_p->port_packets[0 ], global_flag_stru_p->port_packets[1 ], global_flag_stru_p->port_packets[2 ]);
@@ -706,11 +705,11 @@ main(int argc, char *argv[])/* initialize all ports */ members_count = nb_ports;RTE_ETH_FOREACH_DEV (i) { -member_port_init (i, mbuf_pool); +member_port_init (i); members[i] = i; } -bond_port_init (mbuf_pool); +bond_port_init ();rte_spinlock_init (&global_flag_stru_p->lock);
examples/bond/meson.build +0 -1
@@ -11,7 +11,6 @@ allow_experimental_apis = true sources = files( 'main.c', ) -cflags += no_shadow_cflag cmd_h = custom_target('commands_hdr', output: 'commands.h',
Signature · 1 line
2.53.0
PATCH 6/23 examples/vmdq: fix shadow variable warning
In reply to Stephen HemmingerRename parameter of get_eth_conf to avoid conflicting with global variable.
--- examples/vmdq/main.c | 8 ++++---- examples/vmdq/meson.build | 1 - 2 files changed, 4 insertions(+), 5 deletions(-)
examples/vmdq/main.c +4 -4
@@ -135,19 +135,19 @@ static struct rte_ether_addr vmdq_ports_eth_addr[RTE_MAX_ETHPORTS];/* Building correct configuration for vdmq. 8< */ static inline int -get_eth_conf (struct rte_eth_conf *eth_conf,uint32_t num_pools) +get_eth_conf (struct rte_eth_conf *eth_conf,uint32_t max_pools) {struct rte_eth_vmdq_rx_conf conf;unsigned i; - conf.nb_queue_pools = (enum rte_eth_nb_pools )num_pools; - conf.nb_pool_maps = num_pools; + conf.nb_queue_pools = (enum rte_eth_nb_pools )max_pools; + conf.nb_pool_maps = max_pools; conf.enable_default_pool =0 ; conf.default_pool =0 ;/* set explicit value, even if not used */ for (i =0 ; i < conf.nb_pool_maps; i++) { conf.pool_map[i].vlan_id = vlan_tags[i]; - conf.pool_map[i].pools = (1UL << (i % num_pools)); + conf.pool_map[i].pools = (1UL << (i % max_pools)); } *eth_conf = vmdq_conf_default;
examples/vmdq/meson.build +0 -1
@@ -10,4 +10,3 @@ allow_experimental_apis = true sources = files( 'main.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 7/23 examples/server_node_efd: fix shadowed variable
In reply to Stephen HemmingerArgument to parse_numa_nodes() shadowed global variable.
--- examples/server_node_efd/efd_server/args.c | 6 +++--- examples/server_node_efd/efd_server/meson.build | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
examples/server_node_efd/efd_server/args.c +3 -3
@@ -81,15 +81,15 @@ parse_portmask(uint8_t max_ports, const char *portmask)* and convert to a number to store in the num_nodes variable */ static int -parse_num_nodes (const char *nodes) +parse_num_nodes (const char *arg) {char *end =NULL ;unsigned long temp; -if (nodes ==NULL || *nodes =='\0' ) +if (arg ==NULL || *arg =='\0' )return -1 ; - temp =strtoul (nodes, &end,10 ); + temp =strtoul (arg, &end,10 );if (end ==NULL || *end !='\0' || temp ==0 )return -1 ;
examples/server_node_efd/efd_server/meson.build +0 -1
@@ -10,4 +10,3 @@ allow_experimental_apis = true deps += 'efd' sources += files('args.c', 'init.c', 'main.c') includes += include_directories('../shared') -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 8/23 examples/flow_filtering: fix shadowed variables
In reply to Stephen HemmingerRename places where argument name is shadowing a global variable.
--- examples/flow_filtering/flow_skeleton.c | 10 +++++----- examples/flow_filtering/main.c | 4 ++-- examples/flow_filtering/meson.build | 1 - 3 files changed, 7 insertions(+), 8 deletions(-)
examples/flow_filtering/flow_skeleton.c +5 -5
@@ -14,7 +14,7 @@ struct rte_flow_attr flow_attr;struct rte_flow_op_attr ops_attr = { .postpone =0 };static struct rte_flow * -create_flow_non_template (uint16_t port_id,struct rte_flow_attr *flow_attr, +create_flow_non_template (uint16_t port_id,struct rte_flow_attr *attr,struct rte_flow_item *patterns,struct rte_flow_action *actions,struct rte_flow_error *error)
@@ -22,13 +22,13 @@ create_flow_non_template(uint16_t port_id, struct rte_flow_attr *flow_attr,struct rte_flow *flow =NULL ;/* Validate the rule and create it. */ -if (rte_flow_validate (port_id, flow_attr, patterns, actions, error) ==0 ) - flow =rte_flow_create (port_id, flow_attr, patterns, actions, error); +if (rte_flow_validate (port_id, attr, patterns, actions, error) ==0 ) + flow =rte_flow_create (port_id, attr, patterns, actions, error);return flow; }static struct rte_flow * -create_flow_template (uint16_t port_id,struct rte_flow_op_attr *ops_attr, +create_flow_template (uint16_t port_id,struct rte_flow_op_attr *attr,struct rte_flow_item *patterns,struct rte_flow_action *actions,struct rte_flow_error *error)
@@ -42,7 +42,7 @@ create_flow_template(uint16_t port_id, struct rte_flow_op_attr *ops_attr, return rte_flow_async_create(port_id, 1, /* Flow queue used to insert the rule. */ - ops_attr, + attr, table, patterns, 0, /* Pattern template index in the table. */
examples/flow_filtering/main.c +2 -2
@@ -125,7 +125,7 @@ assert_link_status(void) }static void -configure_port_template (uint16_t port_id) +configure_port_template (void ) {int ret;uint16_t std_queue;
@@ -254,7 +254,7 @@ init_port(void)"rte_eth_dev_stop:err=%d, port=%u\n" , ret, port_id); -configure_port_template (port_id); +configure_port_template (); ret =rte_eth_dev_start (port_id);if (ret <0 ) rte_exit(EXIT_FAILURE,
examples/flow_filtering/meson.build +0 -1
@@ -33,4 +33,3 @@ sources = files( # The code snippets are not utilized. cflags += '-Wno-unused-function' -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 9/23 examples/ipsec-secgw: fix shadowed variables
In reply to Stephen HemmingerRename variables where local variable shadows a global declaration. Remove unused lcore_conf parameter from sa_init().
--- examples/ipsec-secgw/ipsec-secgw.c | 3 +-- examples/ipsec-secgw/ipsec.c | 3 +-- examples/ipsec-secgw/ipsec.h | 1 - examples/ipsec-secgw/ipsec_worker.c | 30 ++++++++++++------------- examples/ipsec-secgw/ipsec_worker.h | 4 ++-- examples/ipsec-secgw/meson.build | 1 - examples/ipsec-secgw/sa.c | 34 +++++++++++++---------------- 7 files changed, 34 insertions(+), 42 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +1 -2
@@ -3123,8 +3123,7 @@ main(int32_t argc, char **argv)if ((socket_ctx[socket_id].session_pool !=NULL ) && (socket_ctx[socket_id].sa_in ==NULL ) && (socket_ctx[socket_id].sa_out ==NULL )) { -sa_init (&socket_ctx[socket_id], socket_id, lcore_conf, - eh_conf->mode_params); +sa_init (&socket_ctx[socket_id], socket_id, eh_conf->mode_params);sp4_init (&socket_ctx[socket_id], socket_id);sp6_init (&socket_ctx[socket_id], socket_id);rt_init (&socket_ctx[socket_id], socket_id);
examples/ipsec-secgw/ipsec.c +1 -2
@@ -415,7 +415,7 @@ int create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, struct rte_ipsec_session *ips) { - int32_t ret = 0; + int ret = 0;void *sec_ctx; struct rte_security_session_conf sess_conf = { .action_type = ips->type,
@@ -489,7 +489,6 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,if (ips->type ==RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ) {struct rte_flow_error err; -int ret =0 ; sec_ctx =rte_eth_dev_get_sec_ctx (sa->portid);if (sec_ctx ==NULL ) {
examples/ipsec-secgw/ipsec.h +0 -1
@@ -439,7 +439,6 @@ sa_spi_present(struct sa_ctx *sa_ctx, uint32_t spi, int inbound);void sa_init (struct socket_ctx *ctx,int32_t socket_id, -struct lcore_conf *lcore_conf,const struct eventmode_conf *em_conf);void
examples/ipsec-secgw/ipsec_worker.c +15 -15
@@ -94,7 +94,7 @@ ev_vector_attr_update(struct rte_event_vector *vec, struct rte_mbuf *pkt) }static inline void -prepare_out_sessions_tbl (struct sa_ctx *sa_out, +prepare_out_sessions_tbl (struct sa_ctx *out_ctx,struct port_drv_mode_data *data,uint16_t size) {
@@ -102,12 +102,12 @@ prepare_out_sessions_tbl(struct sa_ctx *sa_out,struct ipsec_sa *sa;uint32_t i; -if (!sa_out) +if (!out_ctx)return ; -for (i =0 ; i < sa_out->nb_sa; i++) { +for (i =0 ; i < out_ctx->nb_sa; i++) { - sa = &sa_out->sa[i]; + sa = &out_ctx->sa[i];if (!sa)continue ;
@@ -1597,7 +1597,7 @@ ipsec_poll_mode_wrkr_inl_pr(void)uint64_t prev_tsc, diff_tsc, cur_tsc;struct ipsec_core_statistics *stats;struct rt_ctx *rt4_ctx, *rt6_ctx; -struct sa_ctx *sa_in, *sa_out; +struct sa_ctx *in_ctx, *out_ctx;struct traffic_type ip4, ip6;struct lcore_rx_queue *rxql;struct rte_mbuf **v4, **v6;
@@ -1621,11 +1621,11 @@ ipsec_poll_mode_wrkr_inl_pr(void) sp4_in = socket_ctx[socket_id].sp_ip4_in; sp6_in = socket_ctx[socket_id].sp_ip6_in; - sa_in = socket_ctx[socket_id].sa_in; + in_ctx = socket_ctx[socket_id].sa_in; sp4_out = socket_ctx[socket_id].sp_ip4_out; sp6_out = socket_ctx[socket_id].sp_ip6_out; - sa_out = socket_ctx[socket_id].sa_out; + out_ctx = socket_ctx[socket_id].sa_out; qconf->frag.pool_indir = socket_ctx[socket_id].mbuf_pool_indir;
@@ -1676,11 +1676,11 @@ ipsec_poll_mode_wrkr_inl_pr(void)free_pkts (trf.ipsec.pkts, trf.ipsec.num);if (is_unprotected_port (portid)) { -inbound_sp_sa (sp4_in, sa_in, &trf.ip4, +inbound_sp_sa (sp4_in, in_ctx, &trf.ip4, trf.ip4.num, &stats->inbound.spd4); -inbound_sp_sa (sp6_in, sa_in, &trf.ip6, +inbound_sp_sa (sp6_in, in_ctx, &trf.ip6, trf.ip6.num, &stats->inbound.spd6);
@@ -1692,12 +1692,12 @@ ipsec_poll_mode_wrkr_inl_pr(void) ip4.num =0 ; ip6.num =0 ; -outb_inl_pro_spd_process (sp4_out, sa_out, +outb_inl_pro_spd_process (sp4_out, out_ctx, &trf.ip4, &ip4, &ip6, true, &stats->outbound.spd4); -outb_inl_pro_spd_process (sp6_out, sa_out, +outb_inl_pro_spd_process (sp6_out, out_ctx, &trf.ip6, &ip6, &ip4, false, &stats->outbound.spd6);
@@ -1733,7 +1733,7 @@ ipsec_poll_mode_wrkr_inl_pr_ss(void)struct lcore_rx_queue *rxql;struct ipsec_sa *sa =NULL ;struct lcore_conf *qconf; -struct sa_ctx *sa_out; +struct sa_ctx *out_ctx;uint32_t i, nb_rx, j;int32_t socket_id;uint32_t lcore_id;
@@ -1746,9 +1746,9 @@ ipsec_poll_mode_wrkr_inl_pr_ss(void) socket_id =rte_lcore_to_socket_id (lcore_id);/* Get SA info */ - sa_out = socket_ctx[socket_id].sa_out; -if (sa_out && single_sa_idx < sa_out->nb_sa) { - sa = &sa_out->sa[single_sa_idx]; + out_ctx = socket_ctx[socket_id].sa_out; +if (out_ctx && single_sa_idx < out_ctx->nb_sa) { + sa = &out_ctx->sa[single_sa_idx]; ips =ipsec_get_primary_session (sa); sa_out_portid = sa->portid;if (sa->flags &IP6_TUNNEL )
examples/ipsec-secgw/ipsec_worker.h +2 -2
@@ -469,7 +469,7 @@ get_hop_for_offload_pkt(struct rte_mbuf *pkt, int is_ipv6) static __rte_always_inline voidroute4_pkts (struct rt_ctx *rt_ctx,struct rte_mbuf *pkts[], -uint32_t nb_pkts,uint64_t tx_offloads,bool ip_cksum) +uint32_t nb_pkts,uint64_t ol_flags,bool ip_cksum) {uint32_t hop[MAX_PKT_BURST *2 ];uint32_t dst_ip[MAX_PKT_BURST *2 ];
@@ -536,7 +536,7 @@ route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[],if (ip_cksum) {struct rte_ipv4_hdr *ip; - pkt->ol_flags |= tx_offloads; + pkt->ol_flags |= ol_flags; ip = (struct rte_ipv4_hdr *)(ethhdr +1 ); ip->hdr_checksum =0 ;
examples/ipsec-secgw/meson.build +0 -1
@@ -25,7 +25,6 @@ sources = files( ) cflags += no_wvla_cflag -cflags += no_shadow_cflag app_cflags = ['-Wno-address-of-packed-member'] foreach flag:app_cflags
examples/ipsec-secgw/sa.c +15 -19
@@ -1696,7 +1696,6 @@ sa_spi_present(struct sa_ctx *sa_ctx, uint32_t spi, int inbound)void sa_init (struct socket_ctx *ctx,int32_t socket_id, -struct lcore_conf *lcore_conf,const struct eventmode_conf *em_conf) {int32_t rc;
@@ -1828,8 +1827,8 @@ outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],* Select HW offloads to be used. */ int -sa_check_offloads (uint16_t port_id,uint64_t *rx_offloads, -uint64_t *tx_offloads,uint8_t *hw_reassembly) +sa_check_offloads (uint16_t port_id,uint64_t *rx_flags, +uint64_t *tx_flags,uint8_t *hw_reassembly) {struct ipsec_sa *rule;uint32_t idx_sa;
@@ -1837,8 +1836,8 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,struct rte_eth_dev_info dev_info;int ret; - *rx_offloads =0 ; - *tx_offloads =0 ; + *rx_flags =0 ; + *tx_flags =0 ; *hw_reassembly =0 ; ret =rte_eth_dev_info_get (port_id, &dev_info);
@@ -1855,9 +1854,9 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads, rule_type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) && rule->portid == port_id) - *rx_offloads |=RTE_ETH_RX_OFFLOAD_SECURITY ; + *rx_flags |=RTE_ETH_RX_OFFLOAD_SECURITY ;if (IS_HW_REASSEMBLY_EN (rule->flags)) { - *tx_offloads |=RTE_ETH_TX_OFFLOAD_MULTI_SEGS ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_MULTI_SEGS ; *hw_reassembly =1 ; } }
@@ -1875,20 +1874,17 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,* non-IPSec packets, there is no need of * IPv4 Checksum offload. */ - *tx_offloads |=RTE_ETH_TX_OFFLOAD_SECURITY ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_SECURITY ;if (rule->mss) - *tx_offloads |= (RTE_ETH_TX_OFFLOAD_TCP_TSO | -RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ); + *tx_flags |=RTE_ETH_TX_OFFLOAD_TCP_TSO | +RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ;break ;case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO : - *tx_offloads |=RTE_ETH_TX_OFFLOAD_SECURITY ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_SECURITY ;if (rule->mss) - *tx_offloads |= -RTE_ETH_TX_OFFLOAD_TCP_TSO ; -if (dev_info.tx_offload_capa & -RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) - *tx_offloads |= -RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_TCP_TSO ; +if (dev_info.tx_offload_capa &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) + *tx_flags |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ;break ;default :/* Enable IPv4 checksum offload even if
@@ -1896,13 +1892,13 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,*/ if (dev_info.tx_offload_capa &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) - *tx_offloads |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ;break ; } }else {if (dev_info.tx_offload_capa &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) - *tx_offloads |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ; } }return 0 ;
Signature · 1 line
2.53.0
PATCH 10/23 examples/ip_pipeline: fix shadow variable
In reply to Stephen HemmingerThe variable p was used for both pipeline and parameters. Rename first instance.
--- examples/ip_pipeline/cli.c | 9 ++++----- examples/ip_pipeline/meson.build | 1 - 2 files changed, 4 insertions(+), 6 deletions(-)
examples/ip_pipeline/cli.c +4 -5
@@ -4721,7 +4721,7 @@ table_rule_show(const char *pipeline_name,uint32_t table_id, const char *file_name) { - struct pipeline *p; + struct pipeline *pipeline;struct table *table;struct table_rule *rule;FILE *f =NULL ;
@@ -4732,12 +4732,11 @@ table_rule_show(const char *pipeline_name, (file_name == NULL))return -1 ; - p =pipeline_find (pipeline_name); -if ((p ==NULL ) || - (table_id >= p->n_tables)) + pipeline =pipeline_find (pipeline_name); +if (pipeline ==NULL || table_id >= pipeline->n_tables)return -1 ; - table = &p->table[table_id]; + table = &pipeline->table[table_id];/* Open file. */ f =fopen (file_name,"w" );
examples/ip_pipeline/meson.build +0 -1
@@ -28,4 +28,3 @@ sources = files( 'thread.c', 'tmgr.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 11/23 examples/multi_process: fix shadowed variable
In reply to Stephen HemmingerThe string passed to parsing function number of clients shadowed global declaration. Also avoid similar problem in parsing portmask.
--- .../multi_process/client_server_mp/mp_server/args.c | 12 ++++++------ .../client_server_mp/mp_server/meson.build | 1 - 2 files changed, 6 insertions(+), 7 deletions(-)
examples/multi_process/client_server_mp/mp_server/args.c +6 -6
@@ -42,18 +42,18 @@ usage(void)* array variable */ static int -parse_portmask (const char *portmask) +parse_portmask (const char *str) {char *end =NULL ;unsigned long long pm;uint16_t id; -if (portmask ==NULL || *portmask =='\0' ) +if (str ==NULL || *str =='\0' )return -1 ;/* convert parameter to a number and verify */ errno =0 ; - pm =strtoull (portmask, &end,16 ); + pm =strtoull (str, &end,16 );if (errno !=0 || end ==NULL || *end !='\0' )return -1 ;
@@ -80,15 +80,15 @@ parse_portmask(const char *portmask)* and convert to a number to store in the num_clients variable */ static int -parse_num_clients (const char *clients) +parse_num_clients (const char *str) {char *end =NULL ;unsigned long temp; -if (clients ==NULL || *clients =='\0' ) +if (str ==NULL || *str =='\0' )return -1 ; - temp =strtoul (clients, &end,10 ); + temp =strtoul (str, &end,10 );if (end ==NULL || *end !='\0' || temp ==0 )return -1 ;
examples/multi_process/client_server_mp/mp_server/meson.build +0 -1
@@ -14,4 +14,3 @@ sources = files( 'init.c', 'main.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 12/23 examples/vm_power_manage: enable shadow warnings
In reply to Stephen HemmingerNo problems in this code, re-enable the warning.
--- examples/vm_power_manager/guest_cli/meson.build | 1 - examples/vm_power_manager/meson.build | 1 - 2 files changed, 2 deletions(-)
examples/vm_power_manager/guest_cli/meson.build +0 -1
@@ -13,7 +13,6 @@ sources = files( 'parse.c', 'vm_power_cli_guest.c', ) -cflags += no_shadow_cflag allow_experimental_apis = true
examples/vm_power_manager/meson.build +0 -1
@@ -29,7 +29,6 @@ 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')
Signature · 1 line
2.53.0
PATCH 13/23 examples/bbdev_app: enable shadow warnings
In reply to Stephen HemmingerNo shadows here.
--- examples/bbdev_app/meson.build | 1 - 1 file changed, 1 deletion(-)
examples/bbdev_app/meson.build +0 -1
@@ -11,4 +11,3 @@ allow_experimental_apis = true sources = files( 'main.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 14/23 examples/ptpclient: fix shadow variable warnings
In reply to Stephen HemmingerRename function parameters that shadow global variables. In port_init() rename mbuf_pool to mp, and in print_clock_info(), delta_eval(), parse_sync(), parse_fup(), and parse_drsp() rename ptp_data to ptp.
--- examples/ptpclient/meson.build | 1 - examples/ptpclient/ptpclient.c | 138 ++++++++++++++++----------------- 2 files changed, 69 insertions(+), 70 deletions(-)
examples/ptpclient/meson.build +0 -1
@@ -10,4 +10,3 @@ allow_experimental_apis = true sources = files( 'ptpclient.c', ) -cflags += no_shadow_cflag
examples/ptpclient/ptpclient.c +69 -69
288 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 15/23 examples/vhost: fix shadow warnings
In reply to Stephen HemmingerThe mbuf_pool was being passed as parameter with same as global; resolve conflict by making variable local to main and passing where needed.
The num_devices was global but also passed as arg. Remove the parameter.
--- examples/vhost/main.c | 19 ++++++++++--------- examples/vhost/meson.build | 1 - 2 files changed, 10 insertions(+), 10 deletions(-)
examples/vhost/main.c +10 -9
@@ -86,7 +86,6 @@ static uint32_t promiscuous;static uint32_t num_queues =0 ;static uint32_t num_devices; -static struct rte_mempool *mbuf_pool;static int mergeable;/* Enable VM2VM communications. If this is disabled then the MAC address compare is skipped. */
@@ -387,7 +386,7 @@ open_dma(const char *value)* according to the pool & queue limits. */ static inline int -get_eth_conf (struct rte_eth_conf *eth_conf,uint32_t num_devices) +get_eth_conf (struct rte_eth_conf *eth_conf) {struct rte_eth_vmdq_rx_conf conf; struct rte_eth_vmdq_rx_conf *def_conf =
@@ -415,7 +414,7 @@ get_eth_conf(struct rte_eth_conf *eth_conf, uint32_t num_devices)* coming from the mbuf_pool passed as parameter */ static inline int -port_init (uint16_t port) +port_init (uint16_t port,struct rte_mempool *mbuf_pool) {struct rte_eth_dev_info dev_info;struct rte_eth_conf port_conf;
@@ -460,7 +459,7 @@ port_init(uint16_t port) }/* Get port configuration. */ - retval =get_eth_conf (&port_conf, num_devices); + retval =get_eth_conf (&port_conf);if (retval <0 )return retval;/* NIC queues are divided into pf queues and vmdq queues. */
@@ -1440,7 +1439,7 @@ uint16_t sync_dequeue_pkts(struct vhost_dev *dev, uint16_t queue_id, } static __rte_always_inline void -drain_virtio_tx (struct vhost_dev *vdev) +drain_virtio_tx (struct vhost_dev *vdev,struct rte_mempool *mbuf_pool) {struct rte_mbuf *pkts[MAX_PKT_BURST ];uint16_t count;
@@ -1477,8 +1476,9 @@ drain_virtio_tx(struct vhost_dev *vdev)* } */ static int -switch_worker(void *arg __rte_unused) +switch_worker (void *arg) { +struct rte_mempool *mbuf_pool = arg;unsigned i;unsigned lcore_id =rte_lcore_id ();struct vhost_dev *vdev;
@@ -1519,7 +1519,7 @@ switch_worker(void *arg __rte_unused)drain_eth_rx (vdev);if (likely (!vdev->remove)) -drain_virtio_tx (vdev); +drain_virtio_tx (vdev, mbuf_pool); } }
@@ -1906,6 +1906,7 @@ reset_dma(void)int main (int argc,char *argv[]) { +struct rte_mempool *mbuf_pool =NULL ;unsigned lcore_id, core_id =0 ;unsigned nb_ports, valid_num_ports;int ret, i;
@@ -1982,7 +1983,7 @@ main(int argc, char *argv[]) "Skipping disabled port %d\n", portid);continue ; } -if (port_init (portid) !=0 ) +if (port_init (portid, mbuf_pool) !=0 )rte_exit (EXIT_FAILURE ,"Cannot initialize network ports\n" ); }
@@ -1998,7 +1999,7 @@ main(int argc, char *argv[])/* Launch all data cores. */ RTE_LCORE_FOREACH_WORKER (lcore_id) -rte_eal_remote_launch (switch_worker, NULL, lcore_id); +rte_eal_remote_launch (switch_worker, mbuf_pool, lcore_id);if (client_mode) flags |=RTE_VHOST_USER_CLIENT ;
examples/vhost/meson.build +0 -1
@@ -19,4 +19,3 @@ sources = files( 'virtio_net.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 16/23 examples/qos_sched: eliminate shadowed variables
In reply to Stephen HemmingerThe port_params and subport_params are global variables, then passed to load functions. The names clash so just use the globals.
--- examples/qos_sched/cfg_file.c | 12 ++++++------ examples/qos_sched/cfg_file.h | 4 ++-- examples/qos_sched/init.c | 4 ++-- examples/qos_sched/meson.build | 1 - 4 files changed, 10 insertions(+), 11 deletions(-)
examples/qos_sched/cfg_file.c +6 -6
@@ -41,20 +41,20 @@ int parse_u64(const char *entry, uint64_t *val) }int -cfg_load_port (struct rte_cfgfile *cfg,struct rte_sched_port_params *port_params) +cfg_load_port (struct rte_cfgfile *cfg) {const char *entry; -if (!cfg || !port_params) +if (!cfg)return -1 ; entry =rte_cfgfile_get_entry (cfg,"port" ,"frame overhead" );if (entry) - port_params->frame_overhead = (uint32_t )atoi (entry); + port_params.frame_overhead = (uint32_t )atoi (entry); entry =rte_cfgfile_get_entry (cfg,"port" ,"number of subports per port" );if (entry) - port_params->n_subports_per_port = (uint32_t )atoi (entry); + port_params.n_subports_per_port = (uint32_t )atoi (entry);return 0 ; }
@@ -279,13 +279,13 @@ cfg_load_subport_profile(struct rte_cfgfile *cfg, }int -cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) +cfg_load_subport (struct rte_cfgfile *cfg) {bool cman_enabled = false;const char *entry;int i, j, k; -if (!cfg || !subport_params) +if (!cfg)return -1 ;memset (app_pipe_to_profile,-1 ,sizeof (app_pipe_to_profile));
examples/qos_sched/cfg_file.h +2 -2
@@ -10,11 +10,11 @@int parse_u64 (const char *entry,uint64_t *val); -int cfg_load_port (struct rte_cfgfile *cfg,struct rte_sched_port_params *port); +int cfg_load_port (struct rte_cfgfile *cfg);int cfg_load_pipe (struct rte_cfgfile *cfg,struct rte_sched_pipe_params *pipe); -int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport (struct rte_cfgfile *cfg);int cfg_load_subport_profile (struct rte_cfgfile *cfg, struct rte_sched_subport_profile_params
examples/qos_sched/init.c +2 -2
@@ -296,11 +296,11 @@ app_load_cfg_profile(const char *profile)if (file ==NULL )rte_exit (EXIT_FAILURE ,"Cannot load configuration profile %s\n" , profile); - ret =cfg_load_port (file, &port_params); + ret =cfg_load_port (file);if (ret) goto _app_load_cfg_profile_error_return; - ret =cfg_load_subport (file, subport_params); + ret =cfg_load_subport (file);if (ret) goto _app_load_cfg_profile_error_return;
examples/qos_sched/meson.build +0 -1
@@ -18,4 +18,3 @@ sources = files( 'stats.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 17/23 examples/l2fwd-jobstats: fix shadowed variable
In reply to Stephen HemmingerThe inner loop across ports was shadowing other definition of variable i.
--- examples/l2fwd-jobstats/main.c | 6 +++--- examples/l2fwd-jobstats/meson.build | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
examples/l2fwd-jobstats/main.c +3 -3
@@ -515,7 +515,6 @@ l2fwd_main_loop(void)uint64_t repeats =0 ; do { - uint8_t i; uint64_t now = rte_get_timer_cycles(); repeats++;
@@ -526,8 +525,9 @@ l2fwd_main_loop(void) rte_memory_order_relaxed); need_manage |= stats_read_pending; -for (i =0 ; i < qconf->n_rx_port && !need_manage; i++) - need_manage = qconf->rx_timers[i].expire < now; +for (uint16_t port_id =0 ; + port_id < qconf->n_rx_port && !need_manage; port_id++) + need_manage = qconf->rx_timers[port_id].expire < now; }while (!need_manage);
examples/l2fwd-jobstats/meson.build +0 -1
@@ -12,4 +12,3 @@ sources = files( 'main.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 18/23 examples/l2fwd-crypto: remove no shadow flag
In reply to Stephen HemmingerThere are no instances of shadow variables in this example.
--- examples/l2fwd-crypto/meson.build | 1 - 1 file changed, 1 deletion(-)
examples/l2fwd-crypto/meson.build +0 -1
@@ -15,4 +15,3 @@ sources = files( 'main.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 19/23 examples/l2fwd-event: remove no shadow flag
In reply to Stephen HemmingerThere are no shadow variable warnings in this example.
--- examples/l2fwd-event/meson.build | 1 - 1 file changed, 1 deletion(-)
examples/l2fwd-event/meson.build +0 -1
@@ -17,4 +17,3 @@ sources = files( 'l2fwd_event_internal_port.c', 'l2fwd_poll.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 20/23 examples/l2fwd-keepalive: fix shadow variable warning
In reply to Stephen HemmingerThe qconf parameter can reused, fixing a shadow warning.
--- examples/l2fwd-keepalive/main.c | 2 +- examples/l2fwd-keepalive/meson.build | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
examples/l2fwd-keepalive/main.c +1 -1
@@ -780,7 +780,7 @@ main(int argc, char **argv) }/* launch per-lcore init on every worker lcore */ RTE_LCORE_FOREACH_WORKER (lcore_id) { -struct lcore_queue_conf *qconf = &lcore_queue_conf[lcore_id]; + qconf = &lcore_queue_conf[lcore_id];if (qconf->n_rx_port ==0 ) RTE_LOG(INFO, L2FWD,
examples/l2fwd-keepalive/meson.build +0 -1
@@ -19,4 +19,3 @@ sources = files( 'main.c', 'shm.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 21/23 examples/l3fwd-graph: remove no shadow flag
In reply to Stephen HemmingerThis example has no shadow variable warnings.
--- examples/l3fwd-graph/meson.build | 1 - 1 file changed, 1 deletion(-)
examples/l3fwd-graph/meson.build +0 -1
@@ -11,4 +11,3 @@ sources = files( 'main.c', ) allow_experimental_apis = true -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 22/23 examples/l3fwd: fix shadow variable warnings
In reply to Stephen HemmingerCorrect for shadow variables by renaming:
- global ipv6 becomes ipv6_enabled (convert int to bool)
- lcore_params used by eventdev becomes config_parsed
- masks for sse globals get xmm_ prefix
--- examples/l3fwd/l3fwd.h | 2 +- examples/l3fwd/l3fwd_em.c | 32 ++++++++++++++++++-------------- examples/l3fwd/l3fwd_em_hlm.h | 8 ++++---- examples/l3fwd/l3fwd_lpm.c | 4 ++-- examples/l3fwd/l3fwd_route.h | 12 ++++++------ examples/l3fwd/main.c | 12 ++++++------ examples/l3fwd/meson.build | 1 - 7 files changed, 37 insertions(+), 34 deletions(-)
examples/l3fwd/l3fwd.h +1 -1
@@ -99,7 +99,7 @@ extern struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];extern uint32_t enabled_port_mask;/* Used only in exact match mode. */ -extern int ipv6;/**< ipv6 is false by default. */ +extern bool ipv6_enabled;/**< ipv6 is false by default. */ extern uint32_t hash_entry_number;extern xmm_t val_eth[RTE_MAX_ETHPORTS ];
examples/l3fwd/l3fwd_em.c +18 -14
@@ -211,9 +211,9 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,static alignas(RTE_CACHE_LINE_SIZE )uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES ];static alignas(RTE_CACHE_LINE_SIZE )uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES ]; -static rte_xmm_t mask0; -static rte_xmm_t mask1; -static rte_xmm_t mask2; +static rte_xmm_t xmm_mask0; +static rte_xmm_t xmm_mask1; +static rte_xmm_t xmm_mask2;#if defined(__SSE2__) static inline xmm_t
@@ -275,7 +275,7 @@ em_get_ipv4_dst_port(void *ipv4_hdr, uint16_t portid, void *lookup_struct)* Get 5 tuple: dst port, src port, dst IP address, * src IP address and protocol. */ - key.xmm =em_mask_key (ipv4_hdr, mask0.x); + key.xmm =em_mask_key (ipv4_hdr, xmm_mask0.x);/* Find destination port */ ret =rte_hash_lookup (ipv4_l3fwd_lookup_struct, (const void *)&key);
@@ -298,7 +298,7 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint16_t portid, void *lookup_struct)void *data2 = ((uint8_t *)ipv6_hdr) +sizeof (xmm_t) +sizeof (xmm_t);/* Get part of 5 tuple: src IP address lower 96 bits and protocol */ - key.xmm[0 ] =em_mask_key (data0, mask1.x); + key.xmm[0 ] =em_mask_key (data0, xmm_mask1.x);/* * Get part of 5 tuple: dst IP address lower 96 bits
@@ -314,7 +314,7 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint16_t portid, void *lookup_struct)* Get part of 5 tuple: dst port and src port * and dst IP address higher 32 bits. */ - key.xmm[2 ] =em_mask_key (data2, mask2.x); + key.xmm[2 ] =em_mask_key (data2, xmm_mask2.x);/* Find destination port */ ret =rte_hash_lookup (ipv6_l3fwd_lookup_struct, (const void *)&key);
@@ -375,8 +375,9 @@ populate_ipv4_flow_into_table(const struct rte_hash *h)char srcbuf[INET6_ADDRSTRLEN ];char dstbuf[INET6_ADDRSTRLEN ]; - mask0 = (rte_xmm_t ){.u32 = {BIT_8_TO_15 ,ALL_32_BITS , -ALL_32_BITS ,ALL_32_BITS } }; + xmm_mask0 = (rte_xmm_t ) { + .u32 = {BIT_8_TO_15 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } + };for (i =0 ; i < route_num_v4; i++) {struct em_rule *entry;
@@ -427,10 +428,13 @@ populate_ipv6_flow_into_table(const struct rte_hash *h)char srcbuf[INET6_ADDRSTRLEN ];char dstbuf[INET6_ADDRSTRLEN ]; - mask1 = (rte_xmm_t ){.u32 = {BIT_16_TO_23 ,ALL_32_BITS , -ALL_32_BITS ,ALL_32_BITS } }; + xmm_mask1 = (rte_xmm_t ){ + .u32 = {BIT_16_TO_23 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } + }; - mask2 = (rte_xmm_t ){.u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } }; + xmm_mask2 = (rte_xmm_t ){ + .u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } + };for (i =0 ; i < route_num_v6; i++) {struct em_rule *entry;
@@ -507,11 +511,11 @@ em_check_ptype(int portid) } } -if (!ipv6 && !ptype_l3_ipv4_ext) { +if (!ipv6_enabled && !ptype_l3_ipv4_ext) {printf ("port %d cannot parse RTE_PTYPE_L3_IPV4_EXT\n" , portid);return 0 ; } -if (ipv6 && !ptype_l3_ipv6_ext) { +if (ipv6_enabled && !ptype_l3_ipv6_ext) {printf ("port %d cannot parse RTE_PTYPE_L3_IPV6_EXT\n" , portid);return 0 ; }
@@ -1010,7 +1014,7 @@ setup_hash(const int socketid)* Use data from ipv4/ipv6 l3fwd config file * directly to initialize the hash table. */ -if (ipv6 ==0 ) { +if (!ipv6_enabled) {/* populate the ipv4 hash */ populate_ipv4_flow_into_table ( ipv4_l3fwd_em_lookup_struct[socketid]);
examples/l3fwd/l3fwd_em_hlm.h +4 -4
@@ -31,7 +31,7 @@ em_get_dst_port_ipv4xN(struct lcore_conf *qconf, struct rte_mbuf *m[],const void *key_array[EM_HASH_LOOKUP_COUNT ];for (i =0 ; i <EM_HASH_LOOKUP_COUNT ; i++) { -get_ipv4_5tuple (m[i], mask0.x, &key[i]); +get_ipv4_5tuple (m[i], xmm_mask0.x, &key[i]); key_array[i] = &key[i]; }
@@ -58,7 +58,7 @@ em_get_dst_port_ipv6xN(struct lcore_conf *qconf, struct rte_mbuf *m[],const void *key_array[EM_HASH_LOOKUP_COUNT ];for (i =0 ; i <EM_HASH_LOOKUP_COUNT ; i++) { -get_ipv6_5tuple (m[i], mask1.x, mask2.x, &key[i]); +get_ipv6_5tuple (m[i], xmm_mask1.x, xmm_mask2.x, &key[i]); key_array[i] = &key[i]; }
@@ -85,7 +85,7 @@ em_get_dst_port_ipv4xN_events(struct lcore_conf *qconf, struct rte_mbuf *m[],const void *key_array[EM_HASH_LOOKUP_COUNT ];for (i =0 ; i <EM_HASH_LOOKUP_COUNT ; i++) { -get_ipv4_5tuple (m[i], mask0.x, &key[i]); +get_ipv4_5tuple (m[i], xmm_mask0.x, &key[i]); key_array[i] = &key[i]; }
@@ -112,7 +112,7 @@ em_get_dst_port_ipv6xN_events(struct lcore_conf *qconf, struct rte_mbuf *m[],const void *key_array[EM_HASH_LOOKUP_COUNT ];for (i =0 ; i <EM_HASH_LOOKUP_COUNT ; i++) { -get_ipv6_5tuple (m[i], mask1.x, mask2.x, &key[i]); +get_ipv6_5tuple (m[i], xmm_mask1.x, xmm_mask2.x, &key[i]); key_array[i] = &key[i]; }
examples/l3fwd/l3fwd_lpm.c +2 -2
@@ -681,12 +681,12 @@ lpm_check_ptype(int portid) ptype_l3_ipv6 =1 ; } -if (!ipv6 && !ptype_l3_ipv4) { +if (!ipv6_enabled && !ptype_l3_ipv4) {printf ("port %d cannot parse RTE_PTYPE_L3_IPV4\n" , portid);return 0 ; } -if (ipv6 && !ptype_l3_ipv6) { +if (ipv6_enabled && !ptype_l3_ipv6) {printf ("port %d cannot parse RTE_PTYPE_L3_IPV6\n" , portid);return 0 ; }
examples/l3fwd/l3fwd_route.h +6 -6
@@ -14,14 +14,14 @@#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t))#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ - unsigned long val; \ - char *end; \ + unsigned long _val; \ + char *_end; \ errno = 0; \ - val = strtoul((in), &end, (base)); \ - if (errno != 0 || end[0] != (dlm) || val > (lim)) \ + _val = strtoul((in), &_end, (base)); \ + if (errno != 0 || _end[0] != (dlm) || _val > (lim)) \ return -EINVAL; \ - (fd) = (typeof(fd))val; \ - (in) = end + 1; \ + (fd) = (typeof(fd))_val; \ + (in) = _end + 1; \ } while (0)struct ipv4_l3fwd_route {
examples/l3fwd/main.c +6 -6
@@ -94,7 +94,7 @@ xmm_t val_eth[RTE_MAX_ETHPORTS];uint32_t enabled_port_mask;/* Used only in exact match mode. */ -int ipv6;/**< ipv6 is false by default. */ +bool ipv6_enabled;/**< ipv6 is false by default. */ struct lcore_conf lcore_conf[RTE_MAX_LCORE ];
@@ -871,7 +871,7 @@ parse_args(int argc, char **argv)char **argvopt;int option_index;char *prgname = argv[0 ]; -uint8_t lcore_params =0 ; +bool config_parsed = false;#ifdef RTE_LIB_EVENTDEV uint8_t eventq_sched =0 ;uint8_t eth_rx_q =0 ;
@@ -924,7 +924,7 @@ parse_args(int argc, char **argv)print_usage (prgname);return -1 ; } - lcore_params =1 ; + config_parsed = true;break ;case CMD_LINK_OPT_ETH_LINK_SPEED_NUM : speed_num =atoi (optarg);
@@ -966,7 +966,7 @@ parse_args(int argc, char **argv)break ;case CMD_LINE_OPT_IPV6_NUM : - ipv6 =1 ; + ipv6_enabled = true;break ;case CMD_LINE_OPT_MAX_PKT_LEN_NUM :
@@ -1056,9 +1056,9 @@ parse_args(int argc, char **argv) } } -RTE_SET_USED (lcore_params);/* needed if no eventdev block */ +RTE_SET_USED (config_parsed);/* needed if no eventdev block */ #ifdef RTE_LIB_EVENTDEV -if (evt_rsrc->enabled && lcore_params) { +if (evt_rsrc->enabled && config_parsed) {fprintf (stderr,"lcore config is not valid when event mode is selected\n" );return -1 ; }
examples/l3fwd/meson.build +0 -1
@@ -22,4 +22,3 @@ if dpdk_conf.has('RTE_LIB_EVENTDEV') deps += 'eventdev' endif cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH 23/23 examples/l3fwd-power: fix shadow variable warnings
In reply to Stephen HemmingerRename function parameters to avoid shadowing the file-scope static arrays ipv4_l3fwd_lookup_struct and ipv6_l3fwd_lookup_struct. The new parameter names ipv4_lookup_struct and ipv6_lookup_struct match the member names used in struct lcore_conf.
Fixes warnings with -Wshadow for get_ipv4_dst_port (both exact-match and LPM variants) and get_ipv6_dst_port.
--- examples/l3fwd-power/main.c | 12 ++++++------ examples/l3fwd-power/meson.build | 1 - 2 files changed, 6 insertions(+), 7 deletions(-)
examples/l3fwd-power/main.c +6 -6
@@ -552,7 +552,7 @@ print_ipv6_key(struct ipv6_5tuple key)static inline uint16_t get_ipv4_dst_port (struct rte_ipv4_hdr *ipv4_hdr,uint16_t portid, -lookup_struct_t * ipv4_l3fwd_lookup_struct) +lookup_struct_t *ipv4_lookup_struct) {struct ipv4_5tuple key;struct rte_tcp_hdr *tcp;
@@ -585,13 +585,13 @@ get_ipv4_dst_port(struct rte_ipv4_hdr *ipv4_hdr, uint16_t portid, }/* Find destination port */ - ret =rte_hash_lookup (ipv4_l3fwd_lookup_struct, (const void *)&key); + ret =rte_hash_lookup (ipv4_lookup_struct, (const void *)&key);return ((ret <0 ) ? portid : ipv4_l3fwd_out_if[ret]); }static inline uint16_t get_ipv6_dst_port (struct rte_ipv6_hdr *ipv6_hdr,uint16_t portid, -lookup_struct_t *ipv6_l3fwd_lookup_struct) +lookup_struct_t *ipv6_lookup_struct) {struct ipv6_5tuple key;struct rte_tcp_hdr *tcp;
@@ -625,7 +625,7 @@ get_ipv6_dst_port(struct rte_ipv6_hdr *ipv6_hdr, uint16_t portid, }/* Find destination port */ - ret =rte_hash_lookup (ipv6_l3fwd_lookup_struct, (const void *)&key); + ret =rte_hash_lookup (ipv6_lookup_struct, (const void *)&key);return ((ret <0 ) ? portid : ipv6_l3fwd_out_if[ret]); }#endif
@@ -633,11 +633,11 @@ get_ipv6_dst_port(struct rte_ipv6_hdr *ipv6_hdr, uint16_t portid,#if (APP_LOOKUP_METHOD ==APP_LOOKUP_LPM )static inline uint16_t get_ipv4_dst_port (struct rte_ipv4_hdr *ipv4_hdr,uint16_t portid, -lookup_struct_t *ipv4_l3fwd_lookup_struct) +lookup_struct_t *ipv4_lookup_struct) {uint32_t next_hop; -return ((rte_lpm_lookup (ipv4_l3fwd_lookup_struct, +return ((rte_lpm_lookup (ipv4_lookup_struct,rte_be_to_cpu_32 (ipv4_hdr->dst_addr), &next_hop) ==0 )? next_hop : portid); }
examples/l3fwd-power/meson.build +0 -1
@@ -13,4 +13,3 @@ sources = files( 'perf_core.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
Quoted 33 lines · Stephen Hemminger
Several DPDK examples had -Wshadow disabled via
no_shadow_cflagin their meson.build files. This series fixes all shadow variable warnings and removes the suppression flag, so that -Wshadow is enabled uniformly across every example.The fixes fall into three categories:
- Renaming function parameters or local variables that shadow globals (most patches)
- Removing unused function parameters that duplicated globals (dma, bond,flow_filtering, ipsec-secgw, vhost,qos_sched)
- Simply removingno_shadow_cflagwhere there were no warnings (vm_power_manage,bbdev_app, l2fwd-crypto, l2fwd-event, l3fwd-graph)All the patches are listed as fixes they are not worth back porting so no Fixes: tag is given.
Stephen Hemminger (23):
examples/ethtool: fix shadow variable warning examples/eventdev_pipeline: fix shadow variable warning examples/dma: fix shadow variable warnings examples/packet_ordering: fix shadow variable warning examples/bond: fix shadow variable warnings examples/vmdq: fix shadow variable warning examples/server_node_efd: fix shadowed variable examples/flow_filtering: fix shadowed variables examples/ipsec-secgw: fix shadowed variables examples/ip_pipeline: fix shadow variable examples/multi_process: fix shadowed variable examples/vm_power_manage: enable shadow warnings examples/bbdev_app: enable shadow warnings examples/ptpclient: fix shadow variable warnings examples/vhost: fix shadow warnings
Quoted 9 lines
examples/qos_sched: eliminate shadowed variables examples/l2fwd-jobstats: fix shadowed variable examples/l2fwd-crypto: remove no shadow flag examples/l2fwd-event: remove no shadow flag examples/l2fwd-keepalive: fix shadow variable warning examples/l3fwd-graph: remove no shadow flag examples/l3fwd: fix shadow variable warnings examples/l3fwd-power: fix shadow variable warnings
Thanks for the cleanup, Stephen.
v2 cover examples: fix -Wshadow warnings
In reply to Stephen HemmingerSeveral DPDK examples had -Wshadow disabled via no_shadow_cflag in their meson.build files. This series fixes all shadow variable warnings and removes the suppression flag, so that -Wshadow is enabled uniformly across every example.
The fixes fall into three categories:
- Renaming function parameters or local variables that shadow globals (most patches)
- Removing unused function parameters that duplicated globals (dma, bond, flow_filtering, ipsec-secgw, vhost, qos_sched)
- Simply removing no_shadow_cflag where there were no warnings (vm_power_manage, bbdev_app, l2fwd-crypto, l2fwd-event, l3fwd-graph)
v2 - fix additional shadow warnings only visible with clang
Stephen Hemminger (23):
examples/ethtool: resolve shadow variable warnings examples/eventdev_pipeline: resolve shadow variable warning examples/dma: resolve shadow variable warnings examples/packet_ordering: resolve shadow variable warning examples/bond: resolve shadow variable warnings examples/vmdq: resolve shadow variable warning examples/server_node_efd: resolve shadow variable warning examples/flow_filtering: resolve shadowed variable warnings examples/ipsec-secgw: resolve shadowed variable warnings examples/ip_pipeline: resolve shadow variable warning examples/multi_process: resolve shadowed variable warnings examples/vm_power_manage: enable shadow warnings examples/bbdev_app: enable shadow warnings examples/ptpclient: resolve shadow variable warnings examples/vhost: resolve shadow warnings examples/qos_sched: eliminate shadowed variables examples/l2fwd-jobstats: resolve shadowed variable examples/l2fwd-crypto: resolve shadow variable examples/l2fwd-event: resolve shadowed variable examples/l2fwd-keepalive: resolve shadow variable warning examples/l3fwd-graph: resolve shadow variable warning examples/l3fwd: resolve shadow variable warnings examples/l3fwd-power: resolve shadow variable warnings
examples/bbdev_app/main.c | 4 +- examples/bbdev_app/meson.build | 1 - examples/bond/main.c | 21 ++- examples/bond/meson.build | 1 - examples/dma/dmafwd.c | 10 +- examples/dma/meson.build | 1 - examples/ethtool/ethtool-app/main.c | 4 +- examples/ethtool/meson.build | 1 - examples/eventdev_pipeline/meson.build | 1 - .../eventdev_pipeline/pipeline_worker_tx.c | 4 +- examples/flow_filtering/flow_skeleton.c | 10 +- examples/flow_filtering/main.c | 4 +- examples/flow_filtering/meson.build | 1 - examples/ip_pipeline/cli.c | 9 +- examples/ip_pipeline/meson.build | 1 - examples/ipsec-secgw/ipsec-secgw.c | 17 +-- examples/ipsec-secgw/ipsec.c | 3 +- examples/ipsec-secgw/ipsec.h | 1 - examples/ipsec-secgw/ipsec_worker.c | 30 ++-- examples/ipsec-secgw/ipsec_worker.h | 4 +- examples/ipsec-secgw/meson.build | 1 - examples/ipsec-secgw/sa.c | 34 ++--- examples/l2fwd-crypto/main.c | 50 +++---- examples/l2fwd-crypto/meson.build | 1 - examples/l2fwd-event/main.c | 15 +- examples/l2fwd-event/meson.build | 1 - examples/l2fwd-jobstats/main.c | 6 +- examples/l2fwd-jobstats/meson.build | 1 - examples/l2fwd-keepalive/main.c | 2 +- examples/l2fwd-keepalive/meson.build | 1 - examples/l3fwd-graph/main.c | 8 +- examples/l3fwd-graph/meson.build | 1 - examples/l3fwd-power/main.c | 12 +- examples/l3fwd-power/meson.build | 1 - examples/l3fwd/l3fwd.h | 2 +- examples/l3fwd/l3fwd_em.c | 32 ++-- examples/l3fwd/l3fwd_em_hlm.h | 8 +- examples/l3fwd/l3fwd_lpm.c | 4 +- examples/l3fwd/l3fwd_route.h | 12 +- examples/l3fwd/main.c | 68 ++++----- examples/l3fwd/meson.build | 1 - .../client_server_mp/mp_server/args.c | 12 +- .../client_server_mp/mp_server/meson.build | 1 - examples/packet_ordering/main.c | 6 +- examples/packet_ordering/meson.build | 1 - examples/ptpclient/meson.build | 1 - examples/ptpclient/ptpclient.c | 138 +++++++++--------- examples/qos_sched/cfg_file.c | 12 +- examples/qos_sched/cfg_file.h | 4 +- examples/qos_sched/init.c | 4 +- examples/qos_sched/meson.build | 1 - examples/server_node_efd/efd_server/args.c | 6 +- .../server_node_efd/efd_server/meson.build | 1 - examples/vhost/main.c | 19 +-- examples/vhost/meson.build | 1 - .../vm_power_manager/guest_cli/meson.build | 1 - examples/vm_power_manager/meson.build | 1 - examples/vmdq/main.c | 8 +- examples/vmdq/meson.build | 1 - 59 files changed, 288 insertions(+), 319 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/23 examples/ethtool: resolve shadow variable warnings
Fix shadow variable warning by renaming the function parameter from 'app_cfg' to 'ptr_cfg' to avoid shadowing the global variable.
../examples/ethtool/ethtool-app/main.c:89:44: warning: declaration of 'app_cfg' shadows a global declaration [-Wshadow]
--- examples/ethtool/ethtool-app/main.c | 4 ++-- examples/ethtool/meson.build | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
examples/ethtool/ethtool-app/main.c +2 -2
@@ -86,7 +86,7 @@ void mark_port_newmac(int idx_port) ptr_port->port_dirty =1 ; } -static void setup_ports (struct app_config *app_cfg,int cnt_ports) +static void setup_ports (struct app_config *ptr_cfg,int cnt_ports) {int idx_port;int size_pktpool;
@@ -101,7 +101,7 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) cfg_port.txmode.mq_mode =RTE_ETH_MQ_TX_NONE ;for (idx_port =0 ; idx_port < cnt_ports; idx_port++) { -struct app_port *ptr_port = &app_cfg->ports[idx_port]; +struct app_port *ptr_port = &ptr_cfg->ports[idx_port]; ret =rte_eth_dev_info_get (idx_port, &dev_info);if (ret !=0 )
examples/ethtool/meson.build +0 -1
@@ -17,7 +17,6 @@ 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')
Signature · 1 line
2.53.0
PATCH v2 2/23 examples/eventdev_pipeline: resolve shadow variable warning
In reply to Stephen HemmingerFix shadow variable warning by reusing the existing 'ret' variable instead of declaring a new one with the same name.
../examples/eventdev_pipeline/pipeline_worker_tx.c:877:25: warning:
declaration of 'ret' shadows a previous local [-Wshadow]
--- examples/eventdev_pipeline/meson.build | 1 - examples/eventdev_pipeline/pipeline_worker_tx.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
examples/eventdev_pipeline/meson.build +0 -1
@@ -13,4 +13,3 @@ sources = files( 'pipeline_worker_generic.c', 'pipeline_worker_tx.c', ) -cflags += no_shadow_cflag
examples/eventdev_pipeline/pipeline_worker_tx.c +2 -2
@@ -874,8 +874,8 @@ init_adapters(uint16_t nb_ports) service.callback = service_rx_adapter; service.callback_userdata = (void *)adptr_services; -int32_t ret =rte_service_component_register (&service, - &fdata->rxadptr_service_id); + ret =rte_service_component_register (&service, + &fdata->rxadptr_service_id);if (ret)rte_exit (EXIT_FAILURE ,"Rx adapter service register failed" );
Signature · 1 line
2.53.0
PATCH v2 3/23 examples/dma: resolve shadow variable warnings
In reply to Stephen HemmingerFix shadow variable warnings by:
- Renaming 'copy_mode' parameter to 'mode' in dma_parse_copy_mode()
- Removing 'nb_queues' parameter from port_init() and using the global variable directly, since it's always called with the global nb_queues value
../examples/dma/dmafwd.c:593:33: warning: declaration of 'copy_mode' shadows a global declaration [-Wshadow] ../examples/dma/dmafwd.c:881:68: warning: declaration of 'nb_queues' shadows a global declaration [-Wshadow]
--- examples/dma/dmafwd.c | 10 +++++----- examples/dma/meson.build | 1 - 2 files changed, 5 insertions(+), 6 deletions(-)
examples/dma/dmafwd.c +5 -5
@@ -590,11 +590,11 @@ dma_parse_portmask(const char *portmask) }static copy_mode_t -dma_parse_copy_mode (const char *copy_mode) +dma_parse_copy_mode (const char *mode) { -if (strcmp (copy_mode,COPY_MODE_SW ) ==0 ) +if (strcmp (mode,COPY_MODE_SW ) ==0 )return COPY_MODE_SW_NUM ; -else if (strcmp (copy_mode,COPY_MODE_DMA ) ==0 ) +else if (strcmp (mode,COPY_MODE_DMA ) ==0 )return COPY_MODE_DMA_NUM ;return COPY_MODE_INVALID_NUM ;
@@ -878,7 +878,7 @@ config_port_max_pkt_len(struct rte_eth_conf *conf,* coming from the mbuf_pool passed as a parameter. */ static inline void -port_init (uint16_t portid,struct rte_mempool *mbuf_pool,uint16_t nb_queues) +port_init (uint16_t portid,struct rte_mempool *mbuf_pool) {/* Configuring port to use RSS for multiple RX queues. 8< */ static const struct rte_eth_conf port_conf = {
@@ -1061,7 +1061,7 @@ main(int argc, char **argv)/* Initialize each port. 8< */ cfg.nb_ports =0 ;RTE_ETH_FOREACH_DEV (portid) -port_init (portid, dma_pktmbuf_pool, nb_queues); +port_init (portid, dma_pktmbuf_pool);/* >8 End of initializing each port. */ /* Initialize port xstats */
examples/dma/meson.build +0 -1
@@ -13,4 +13,3 @@ deps += ['argparse', 'dmadev'] sources = files( 'dmafwd.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 4/23 examples/packet_ordering: resolve shadow variable warning
In reply to Stephen HemmingerFix shadow variable warning by renaming the parameter from 'portmask' to 'mask' in parse_portmask() to avoid shadowing the global variable.
../examples/packet_ordering/main.c:147:28: warning: declaration of 'portmask' shadows a global declaration [-Wshadow]
--- examples/packet_ordering/main.c | 6 +++--- examples/packet_ordering/meson.build | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
examples/packet_ordering/main.c +3 -3
@@ -144,14 +144,14 @@ print_usage(const char *prgname) }static int -parse_portmask (const char *portmask) +parse_portmask (const char *mask) {unsigned long pm;char *end =NULL ;/* parse hexadecimal string */ - pm =strtoul (portmask, &end,16 ); -if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) + pm =strtoul (mask, &end,16 ); +if ((mask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))return 0 ;return pm;
examples/packet_ordering/meson.build +0 -1
@@ -11,4 +11,3 @@ deps += 'reorder' sources = files( 'main.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 5/23 examples/bond: resolve shadow variable warnings
In reply to Stephen HemmingerFix shadow variable warnings
- remove mbuf_pool parameters since member_port_init() and bond_port_init() always called with same pool.
- rename members array used in show command
- make the variables static
--- examples/bond/main.c | 21 ++++++++++----------- examples/bond/meson.build | 1 - 2 files changed, 10 insertions(+), 12 deletions(-)
examples/bond/main.c +10 -11
@@ -96,13 +96,12 @@ ":%02"PRIx8":%02"PRIx8":%02"PRIx8, \ RTE_ETHER_ADDR_BYTES(&addr)) -uint16_t members[RTE_MAX_ETHPORTS ]; -uint16_t members_count; +static uint16_t members[RTE_MAX_ETHPORTS ]; +static uint16_t members_count; +static struct rte_mempool *mbuf_pool;static uint16_t BOND_PORT =0xffff ; -static struct rte_mempool *mbuf_pool; -static struct rte_eth_conf port_conf = { .rxmode = { .mq_mode =RTE_ETH_MQ_RX_NONE ,
@@ -119,7 +118,7 @@ static struct rte_eth_conf port_conf = { };static void -member_port_init (uint16_t portid,struct rte_mempool *mbuf_pool) +member_port_init (uint16_t portid) {int retval;uint16_t nb_rxd =RTE_RX_DESC_DEFAULT ;
@@ -204,7 +203,7 @@ member_port_init(uint16_t portid, struct rte_mempool *mbuf_pool) }static void -bond_port_init (struct rte_mempool *mbuf_pool) +bond_port_init (void ) {int retval;uint8_t i;
@@ -462,10 +461,10 @@ static inline void get_string(struct cmd_send_result *res, char *buf, uint8_t si ((unsigned )((unsigned char *)&(res->ip.addr.ipv4))[3 ]) ); } +void cmd_send_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data) { -struct cmd_send_result *res = parsed_result;char ip_str[INET6_ADDRSTRLEN ];
@@ -635,7 +634,7 @@ cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unusvoid cmd_show_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data) { -uint16_t members[16 ] = {0 }; +uint16_t act_members[16 ] = {0 };uint8_t len =16 ;struct rte_ether_addr addr;uint16_t i;
@@ -658,7 +657,7 @@ cmd_show_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unuscmdline_printf (cl,"Active_members:%d " "packets received:Tot:%d Arp:%d IPv4:%d\n" , -rte_eth_bond_active_members_get (BOND_PORT , members, len), +rte_eth_bond_active_members_get (BOND_PORT , act_members, len), global_flag_stru_p->port_packets[0 ], global_flag_stru_p->port_packets[1 ], global_flag_stru_p->port_packets[2 ]);
@@ -706,11 +705,11 @@ main(int argc, char *argv[])/* initialize all ports */ members_count = nb_ports;RTE_ETH_FOREACH_DEV (i) { -member_port_init (i, mbuf_pool); +member_port_init (i); members[i] = i; } -bond_port_init (mbuf_pool); +bond_port_init ();rte_spinlock_init (&global_flag_stru_p->lock);
examples/bond/meson.build +0 -1
@@ -11,7 +11,6 @@ allow_experimental_apis = true sources = files( 'main.c', ) -cflags += no_shadow_cflag cmd_h = custom_target('commands_hdr', output: 'commands.h',
Signature · 1 line
2.53.0
PATCH v2 6/23 examples/vmdq: resolve shadow variable warning
In reply to Stephen HemmingerRename parameter of get_eth_conf to avoid conflicting with global variable.
--- examples/vmdq/main.c | 8 ++++---- examples/vmdq/meson.build | 1 - 2 files changed, 4 insertions(+), 5 deletions(-)
examples/vmdq/main.c +4 -4
@@ -135,19 +135,19 @@ static struct rte_ether_addr vmdq_ports_eth_addr[RTE_MAX_ETHPORTS];/* Building correct configuration for vdmq. 8< */ static inline int -get_eth_conf (struct rte_eth_conf *eth_conf,uint32_t num_pools) +get_eth_conf (struct rte_eth_conf *eth_conf,uint32_t max_pools) {struct rte_eth_vmdq_rx_conf conf;unsigned i; - conf.nb_queue_pools = (enum rte_eth_nb_pools )num_pools; - conf.nb_pool_maps = num_pools; + conf.nb_queue_pools = (enum rte_eth_nb_pools )max_pools; + conf.nb_pool_maps = max_pools; conf.enable_default_pool =0 ; conf.default_pool =0 ;/* set explicit value, even if not used */ for (i =0 ; i < conf.nb_pool_maps; i++) { conf.pool_map[i].vlan_id = vlan_tags[i]; - conf.pool_map[i].pools = (1UL << (i % num_pools)); + conf.pool_map[i].pools = (1UL << (i % max_pools)); } *eth_conf = vmdq_conf_default;
examples/vmdq/meson.build +0 -1
@@ -10,4 +10,3 @@ allow_experimental_apis = true sources = files( 'main.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 7/23 examples/server_node_efd: resolve shadow variable warning
In reply to Stephen HemmingerArgument to parse_numa_nodes() shadowed global variable.
--- examples/server_node_efd/efd_server/args.c | 6 +++--- examples/server_node_efd/efd_server/meson.build | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
examples/server_node_efd/efd_server/args.c +3 -3
@@ -81,15 +81,15 @@ parse_portmask(uint8_t max_ports, const char *portmask)* and convert to a number to store in the num_nodes variable */ static int -parse_num_nodes (const char *nodes) +parse_num_nodes (const char *arg) {char *end =NULL ;unsigned long temp; -if (nodes ==NULL || *nodes =='\0' ) +if (arg ==NULL || *arg =='\0' )return -1 ; - temp =strtoul (nodes, &end,10 ); + temp =strtoul (arg, &end,10 );if (end ==NULL || *end !='\0' || temp ==0 )return -1 ;
examples/server_node_efd/efd_server/meson.build +0 -1
@@ -10,4 +10,3 @@ allow_experimental_apis = true deps += 'efd' sources += files('args.c', 'init.c', 'main.c') includes += include_directories('../shared') -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 8/23 examples/flow_filtering: resolve shadowed variable warnings
In reply to Stephen HemmingerRename places where argument name is shadowing a global variable.
--- examples/flow_filtering/flow_skeleton.c | 10 +++++----- examples/flow_filtering/main.c | 4 ++-- examples/flow_filtering/meson.build | 1 - 3 files changed, 7 insertions(+), 8 deletions(-)
examples/flow_filtering/flow_skeleton.c +5 -5
@@ -14,7 +14,7 @@ struct rte_flow_attr flow_attr;struct rte_flow_op_attr ops_attr = { .postpone =0 };static struct rte_flow * -create_flow_non_template (uint16_t port_id,struct rte_flow_attr *flow_attr, +create_flow_non_template (uint16_t port_id,struct rte_flow_attr *attr,struct rte_flow_item *patterns,struct rte_flow_action *actions,struct rte_flow_error *error)
@@ -22,13 +22,13 @@ create_flow_non_template(uint16_t port_id, struct rte_flow_attr *flow_attr,struct rte_flow *flow =NULL ;/* Validate the rule and create it. */ -if (rte_flow_validate (port_id, flow_attr, patterns, actions, error) ==0 ) - flow =rte_flow_create (port_id, flow_attr, patterns, actions, error); +if (rte_flow_validate (port_id, attr, patterns, actions, error) ==0 ) + flow =rte_flow_create (port_id, attr, patterns, actions, error);return flow; }static struct rte_flow * -create_flow_template (uint16_t port_id,struct rte_flow_op_attr *ops_attr, +create_flow_template (uint16_t port_id,struct rte_flow_op_attr *attr,struct rte_flow_item *patterns,struct rte_flow_action *actions,struct rte_flow_error *error)
@@ -42,7 +42,7 @@ create_flow_template(uint16_t port_id, struct rte_flow_op_attr *ops_attr, return rte_flow_async_create(port_id, 1, /* Flow queue used to insert the rule. */ - ops_attr, + attr, table, patterns, 0, /* Pattern template index in the table. */
examples/flow_filtering/main.c +2 -2
@@ -125,7 +125,7 @@ assert_link_status(void) }static void -configure_port_template (uint16_t port_id) +configure_port_template (void ) {int ret;uint16_t std_queue;
@@ -254,7 +254,7 @@ init_port(void)"rte_eth_dev_stop:err=%d, port=%u\n" , ret, port_id); -configure_port_template (port_id); +configure_port_template (); ret =rte_eth_dev_start (port_id);if (ret <0 ) rte_exit(EXIT_FAILURE,
examples/flow_filtering/meson.build +0 -1
@@ -33,4 +33,3 @@ sources = files( # The code snippets are not utilized. cflags += '-Wno-unused-function' -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 9/23 examples/ipsec-secgw: resolve shadowed variable warnings
In reply to Stephen HemmingerRename variables where local variable shadows a global declaration. Remove unused lcore_conf parameter from sa_init(). Replace shadowed optarg with parameter named arg.
--- examples/ipsec-secgw/ipsec-secgw.c | 17 +++++++-------- examples/ipsec-secgw/ipsec.c | 3 +-- examples/ipsec-secgw/ipsec.h | 1 - examples/ipsec-secgw/ipsec_worker.c | 30 ++++++++++++------------- examples/ipsec-secgw/ipsec_worker.h | 4 ++-- examples/ipsec-secgw/meson.build | 1 - examples/ipsec-secgw/sa.c | 34 +++++++++++++---------------- 7 files changed, 41 insertions(+), 49 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +8 -9
@@ -1108,11 +1108,11 @@ print_app_sa_prm(const struct app_sa_prm *prm) }static int -parse_transfer_mode (struct eh_conf *conf,const char *optarg) +parse_transfer_mode (struct eh_conf *conf,const char *arg) { -if (!strcmp (CMD_LINE_ARG_POLL , optarg)) +if (!strcmp (CMD_LINE_ARG_POLL , arg)) conf->mode =EH_PKT_TRANSFER_MODE_POLL ; -else if (!strcmp (CMD_LINE_ARG_EVENT , optarg)) +else if (!strcmp (CMD_LINE_ARG_EVENT , arg)) conf->mode =EH_PKT_TRANSFER_MODE_EVENT ;else {printf ("Unsupported packet transfer mode\n" );
@@ -1123,18 +1123,18 @@ parse_transfer_mode(struct eh_conf *conf, const char *optarg) }static int -parse_schedule_type (struct eh_conf *conf,const char *optarg) +parse_schedule_type (struct eh_conf *conf,const char *arg) {struct eventmode_conf *em_conf =NULL ;/* Get eventmode conf */ em_conf = conf->mode_params; -if (!strcmp (CMD_LINE_ARG_ORDERED , optarg)) +if (!strcmp (CMD_LINE_ARG_ORDERED , arg)) em_conf->ext_params.sched_type =RTE_SCHED_TYPE_ORDERED ; -else if (!strcmp (CMD_LINE_ARG_ATOMIC , optarg)) +else if (!strcmp (CMD_LINE_ARG_ATOMIC , arg)) em_conf->ext_params.sched_type =RTE_SCHED_TYPE_ATOMIC ; -else if (!strcmp (CMD_LINE_ARG_PARALLEL , optarg)) +else if (!strcmp (CMD_LINE_ARG_PARALLEL , arg)) em_conf->ext_params.sched_type =RTE_SCHED_TYPE_PARALLEL ;else {printf ("Unsupported queue schedule type\n" );
@@ -3123,8 +3123,7 @@ main(int32_t argc, char **argv)if ((socket_ctx[socket_id].session_pool !=NULL ) && (socket_ctx[socket_id].sa_in ==NULL ) && (socket_ctx[socket_id].sa_out ==NULL )) { -sa_init (&socket_ctx[socket_id], socket_id, lcore_conf, - eh_conf->mode_params); +sa_init (&socket_ctx[socket_id], socket_id, eh_conf->mode_params);sp4_init (&socket_ctx[socket_id], socket_id);sp6_init (&socket_ctx[socket_id], socket_id);rt_init (&socket_ctx[socket_id], socket_id);
examples/ipsec-secgw/ipsec.c +1 -2
@@ -415,7 +415,7 @@ int create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa, struct rte_ipsec_session *ips) { - int32_t ret = 0; + int ret = 0;void *sec_ctx; struct rte_security_session_conf sess_conf = { .action_type = ips->type,
@@ -489,7 +489,6 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,if (ips->type ==RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ) {struct rte_flow_error err; -int ret =0 ; sec_ctx =rte_eth_dev_get_sec_ctx (sa->portid);if (sec_ctx ==NULL ) {
examples/ipsec-secgw/ipsec.h +0 -1
@@ -439,7 +439,6 @@ sa_spi_present(struct sa_ctx *sa_ctx, uint32_t spi, int inbound);void sa_init (struct socket_ctx *ctx,int32_t socket_id, -struct lcore_conf *lcore_conf,const struct eventmode_conf *em_conf);void
examples/ipsec-secgw/ipsec_worker.c +15 -15
@@ -94,7 +94,7 @@ ev_vector_attr_update(struct rte_event_vector *vec, struct rte_mbuf *pkt) }static inline void -prepare_out_sessions_tbl (struct sa_ctx *sa_out, +prepare_out_sessions_tbl (struct sa_ctx *out_ctx,struct port_drv_mode_data *data,uint16_t size) {
@@ -102,12 +102,12 @@ prepare_out_sessions_tbl(struct sa_ctx *sa_out,struct ipsec_sa *sa;uint32_t i; -if (!sa_out) +if (!out_ctx)return ; -for (i =0 ; i < sa_out->nb_sa; i++) { +for (i =0 ; i < out_ctx->nb_sa; i++) { - sa = &sa_out->sa[i]; + sa = &out_ctx->sa[i];if (!sa)continue ;
@@ -1597,7 +1597,7 @@ ipsec_poll_mode_wrkr_inl_pr(void)uint64_t prev_tsc, diff_tsc, cur_tsc;struct ipsec_core_statistics *stats;struct rt_ctx *rt4_ctx, *rt6_ctx; -struct sa_ctx *sa_in, *sa_out; +struct sa_ctx *in_ctx, *out_ctx;struct traffic_type ip4, ip6;struct lcore_rx_queue *rxql;struct rte_mbuf **v4, **v6;
@@ -1621,11 +1621,11 @@ ipsec_poll_mode_wrkr_inl_pr(void) sp4_in = socket_ctx[socket_id].sp_ip4_in; sp6_in = socket_ctx[socket_id].sp_ip6_in; - sa_in = socket_ctx[socket_id].sa_in; + in_ctx = socket_ctx[socket_id].sa_in; sp4_out = socket_ctx[socket_id].sp_ip4_out; sp6_out = socket_ctx[socket_id].sp_ip6_out; - sa_out = socket_ctx[socket_id].sa_out; + out_ctx = socket_ctx[socket_id].sa_out; qconf->frag.pool_indir = socket_ctx[socket_id].mbuf_pool_indir;
@@ -1676,11 +1676,11 @@ ipsec_poll_mode_wrkr_inl_pr(void)free_pkts (trf.ipsec.pkts, trf.ipsec.num);if (is_unprotected_port (portid)) { -inbound_sp_sa (sp4_in, sa_in, &trf.ip4, +inbound_sp_sa (sp4_in, in_ctx, &trf.ip4, trf.ip4.num, &stats->inbound.spd4); -inbound_sp_sa (sp6_in, sa_in, &trf.ip6, +inbound_sp_sa (sp6_in, in_ctx, &trf.ip6, trf.ip6.num, &stats->inbound.spd6);
@@ -1692,12 +1692,12 @@ ipsec_poll_mode_wrkr_inl_pr(void) ip4.num =0 ; ip6.num =0 ; -outb_inl_pro_spd_process (sp4_out, sa_out, +outb_inl_pro_spd_process (sp4_out, out_ctx, &trf.ip4, &ip4, &ip6, true, &stats->outbound.spd4); -outb_inl_pro_spd_process (sp6_out, sa_out, +outb_inl_pro_spd_process (sp6_out, out_ctx, &trf.ip6, &ip6, &ip4, false, &stats->outbound.spd6);
@@ -1733,7 +1733,7 @@ ipsec_poll_mode_wrkr_inl_pr_ss(void)struct lcore_rx_queue *rxql;struct ipsec_sa *sa =NULL ;struct lcore_conf *qconf; -struct sa_ctx *sa_out; +struct sa_ctx *out_ctx;uint32_t i, nb_rx, j;int32_t socket_id;uint32_t lcore_id;
@@ -1746,9 +1746,9 @@ ipsec_poll_mode_wrkr_inl_pr_ss(void) socket_id =rte_lcore_to_socket_id (lcore_id);/* Get SA info */ - sa_out = socket_ctx[socket_id].sa_out; -if (sa_out && single_sa_idx < sa_out->nb_sa) { - sa = &sa_out->sa[single_sa_idx]; + out_ctx = socket_ctx[socket_id].sa_out; +if (out_ctx && single_sa_idx < out_ctx->nb_sa) { + sa = &out_ctx->sa[single_sa_idx]; ips =ipsec_get_primary_session (sa); sa_out_portid = sa->portid;if (sa->flags &IP6_TUNNEL )
examples/ipsec-secgw/ipsec_worker.h +2 -2
@@ -469,7 +469,7 @@ get_hop_for_offload_pkt(struct rte_mbuf *pkt, int is_ipv6) static __rte_always_inline voidroute4_pkts (struct rt_ctx *rt_ctx,struct rte_mbuf *pkts[], -uint32_t nb_pkts,uint64_t tx_offloads,bool ip_cksum) +uint32_t nb_pkts,uint64_t ol_flags,bool ip_cksum) {uint32_t hop[MAX_PKT_BURST *2 ];uint32_t dst_ip[MAX_PKT_BURST *2 ];
@@ -536,7 +536,7 @@ route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[],if (ip_cksum) {struct rte_ipv4_hdr *ip; - pkt->ol_flags |= tx_offloads; + pkt->ol_flags |= ol_flags; ip = (struct rte_ipv4_hdr *)(ethhdr +1 ); ip->hdr_checksum =0 ;
examples/ipsec-secgw/meson.build +0 -1
@@ -25,7 +25,6 @@ sources = files( ) cflags += no_wvla_cflag -cflags += no_shadow_cflag app_cflags = ['-Wno-address-of-packed-member'] foreach flag:app_cflags
examples/ipsec-secgw/sa.c +15 -19
@@ -1696,7 +1696,6 @@ sa_spi_present(struct sa_ctx *sa_ctx, uint32_t spi, int inbound)void sa_init (struct socket_ctx *ctx,int32_t socket_id, -struct lcore_conf *lcore_conf,const struct eventmode_conf *em_conf) {int32_t rc;
@@ -1828,8 +1827,8 @@ outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],* Select HW offloads to be used. */ int -sa_check_offloads (uint16_t port_id,uint64_t *rx_offloads, -uint64_t *tx_offloads,uint8_t *hw_reassembly) +sa_check_offloads (uint16_t port_id,uint64_t *rx_flags, +uint64_t *tx_flags,uint8_t *hw_reassembly) {struct ipsec_sa *rule;uint32_t idx_sa;
@@ -1837,8 +1836,8 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,struct rte_eth_dev_info dev_info;int ret; - *rx_offloads =0 ; - *tx_offloads =0 ; + *rx_flags =0 ; + *tx_flags =0 ; *hw_reassembly =0 ; ret =rte_eth_dev_info_get (port_id, &dev_info);
@@ -1855,9 +1854,9 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads, rule_type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) && rule->portid == port_id) - *rx_offloads |=RTE_ETH_RX_OFFLOAD_SECURITY ; + *rx_flags |=RTE_ETH_RX_OFFLOAD_SECURITY ;if (IS_HW_REASSEMBLY_EN (rule->flags)) { - *tx_offloads |=RTE_ETH_TX_OFFLOAD_MULTI_SEGS ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_MULTI_SEGS ; *hw_reassembly =1 ; } }
@@ -1875,20 +1874,17 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,* non-IPSec packets, there is no need of * IPv4 Checksum offload. */ - *tx_offloads |=RTE_ETH_TX_OFFLOAD_SECURITY ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_SECURITY ;if (rule->mss) - *tx_offloads |= (RTE_ETH_TX_OFFLOAD_TCP_TSO | -RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ); + *tx_flags |=RTE_ETH_TX_OFFLOAD_TCP_TSO | +RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ;break ;case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO : - *tx_offloads |=RTE_ETH_TX_OFFLOAD_SECURITY ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_SECURITY ;if (rule->mss) - *tx_offloads |= -RTE_ETH_TX_OFFLOAD_TCP_TSO ; -if (dev_info.tx_offload_capa & -RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) - *tx_offloads |= -RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_TCP_TSO ; +if (dev_info.tx_offload_capa &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) + *tx_flags |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ;break ;default :/* Enable IPv4 checksum offload even if
@@ -1896,13 +1892,13 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,*/ if (dev_info.tx_offload_capa &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) - *tx_offloads |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ;break ; } }else {if (dev_info.tx_offload_capa &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) - *tx_offloads |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ; + *tx_flags |=RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ; } }return 0 ;
Signature · 1 line
2.53.0
PATCH v2 10/23 examples/ip_pipeline: resolve shadow variable warning
In reply to Stephen HemmingerThe variable p was used for both pipeline and parameters. Rename first instance.
--- examples/ip_pipeline/cli.c | 9 ++++----- examples/ip_pipeline/meson.build | 1 - 2 files changed, 4 insertions(+), 6 deletions(-)
examples/ip_pipeline/cli.c +4 -5
@@ -4721,7 +4721,7 @@ table_rule_show(const char *pipeline_name,uint32_t table_id, const char *file_name) { - struct pipeline *p; + struct pipeline *pipeline;struct table *table;struct table_rule *rule;FILE *f =NULL ;
@@ -4732,12 +4732,11 @@ table_rule_show(const char *pipeline_name, (file_name == NULL))return -1 ; - p =pipeline_find (pipeline_name); -if ((p ==NULL ) || - (table_id >= p->n_tables)) + pipeline =pipeline_find (pipeline_name); +if (pipeline ==NULL || table_id >= pipeline->n_tables)return -1 ; - table = &p->table[table_id]; + table = &pipeline->table[table_id];/* Open file. */ f =fopen (file_name,"w" );
examples/ip_pipeline/meson.build +0 -1
@@ -28,4 +28,3 @@ sources = files( 'thread.c', 'tmgr.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 11/23 examples/multi_process: resolve shadowed variable warnings
In reply to Stephen HemmingerThe string passed to parsing function number of clients shadowed global declaration. Also avoid similar problem in parsing portmask.
--- .../multi_process/client_server_mp/mp_server/args.c | 12 ++++++------ .../client_server_mp/mp_server/meson.build | 1 - 2 files changed, 6 insertions(+), 7 deletions(-)
examples/multi_process/client_server_mp/mp_server/args.c +6 -6
@@ -42,18 +42,18 @@ usage(void)* array variable */ static int -parse_portmask (const char *portmask) +parse_portmask (const char *str) {char *end =NULL ;unsigned long long pm;uint16_t id; -if (portmask ==NULL || *portmask =='\0' ) +if (str ==NULL || *str =='\0' )return -1 ;/* convert parameter to a number and verify */ errno =0 ; - pm =strtoull (portmask, &end,16 ); + pm =strtoull (str, &end,16 );if (errno !=0 || end ==NULL || *end !='\0' )return -1 ;
@@ -80,15 +80,15 @@ parse_portmask(const char *portmask)* and convert to a number to store in the num_clients variable */ static int -parse_num_clients (const char *clients) +parse_num_clients (const char *str) {char *end =NULL ;unsigned long temp; -if (clients ==NULL || *clients =='\0' ) +if (str ==NULL || *str =='\0' )return -1 ; - temp =strtoul (clients, &end,10 ); + temp =strtoul (str, &end,10 );if (end ==NULL || *end !='\0' || temp ==0 )return -1 ;
examples/multi_process/client_server_mp/mp_server/meson.build +0 -1
@@ -14,4 +14,3 @@ sources = files( 'init.c', 'main.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 12/23 examples/vm_power_manage: enable shadow warnings
In reply to Stephen HemmingerNo problems in this code, re-enable the warning.
--- examples/vm_power_manager/guest_cli/meson.build | 1 - examples/vm_power_manager/meson.build | 1 - 2 files changed, 2 deletions(-)
examples/vm_power_manager/guest_cli/meson.build +0 -1
@@ -13,7 +13,6 @@ sources = files( 'parse.c', 'vm_power_cli_guest.c', ) -cflags += no_shadow_cflag allow_experimental_apis = true
examples/vm_power_manager/meson.build +0 -1
@@ -29,7 +29,6 @@ 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')
Signature · 1 line
2.53.0
PATCH v2 13/23 examples/bbdev_app: enable shadow warnings
In reply to Stephen HemmingerReplace shadowed optarg with parameter named arg.
--- examples/bbdev_app/main.c | 4 +--- examples/bbdev_app/meson.build | 1 - 2 files changed, 1 insertion(+), 4 deletions(-)
examples/bbdev_app/main.c +1 -3
@@ -214,7 +214,6 @@ static int bbdev_parse_args(int argc, char **argv, struct app_config_params *app_params) { - int optind = 0; int opt;int opt_indx =0 ;char *prgname = argv[0 ];
@@ -269,8 +268,7 @@ bbdev_parse_args(int argc, char **argv,return -1 ; } } - optind =0 ; -return optind; +return 0 ; } static void
examples/bbdev_app/meson.build +0 -1
@@ -11,4 +11,3 @@ allow_experimental_apis = true sources = files( 'main.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 14/23 examples/ptpclient: resolve shadow variable warnings
In reply to Stephen HemmingerRename function parameters that shadow global variables. In port_init() rename mbuf_pool to mp, and in print_clock_info(), delta_eval(), parse_sync(), parse_fup(), and parse_drsp() rename ptp_data to ptp.
--- examples/ptpclient/meson.build | 1 - examples/ptpclient/ptpclient.c | 138 ++++++++++++++++----------------- 2 files changed, 69 insertions(+), 70 deletions(-)
examples/ptpclient/meson.build +0 -1
@@ -10,4 +10,3 @@ allow_experimental_apis = true sources = files( 'ptpclient.c', ) -cflags += no_shadow_cflag
examples/ptpclient/ptpclient.c +69 -69
288 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 15/23 examples/vhost: resolve shadow warnings
In reply to Stephen HemmingerThe mbuf_pool was being passed as parameter with same as global; resolve conflict by making variable local to main and passing where needed.
The num_devices was global but also passed as arg. Remove the parameter.
--- examples/vhost/main.c | 19 ++++++++++--------- examples/vhost/meson.build | 1 - 2 files changed, 10 insertions(+), 10 deletions(-)
examples/vhost/main.c +10 -9
@@ -86,7 +86,6 @@ static uint32_t promiscuous;static uint32_t num_queues =0 ;static uint32_t num_devices; -static struct rte_mempool *mbuf_pool;static int mergeable;/* Enable VM2VM communications. If this is disabled then the MAC address compare is skipped. */
@@ -387,7 +386,7 @@ open_dma(const char *value)* according to the pool & queue limits. */ static inline int -get_eth_conf (struct rte_eth_conf *eth_conf,uint32_t num_devices) +get_eth_conf (struct rte_eth_conf *eth_conf) {struct rte_eth_vmdq_rx_conf conf; struct rte_eth_vmdq_rx_conf *def_conf =
@@ -415,7 +414,7 @@ get_eth_conf(struct rte_eth_conf *eth_conf, uint32_t num_devices)* coming from the mbuf_pool passed as parameter */ static inline int -port_init (uint16_t port) +port_init (uint16_t port,struct rte_mempool *mbuf_pool) {struct rte_eth_dev_info dev_info;struct rte_eth_conf port_conf;
@@ -460,7 +459,7 @@ port_init(uint16_t port) }/* Get port configuration. */ - retval =get_eth_conf (&port_conf, num_devices); + retval =get_eth_conf (&port_conf);if (retval <0 )return retval;/* NIC queues are divided into pf queues and vmdq queues. */
@@ -1440,7 +1439,7 @@ uint16_t sync_dequeue_pkts(struct vhost_dev *dev, uint16_t queue_id, } static __rte_always_inline void -drain_virtio_tx (struct vhost_dev *vdev) +drain_virtio_tx (struct vhost_dev *vdev,struct rte_mempool *mbuf_pool) {struct rte_mbuf *pkts[MAX_PKT_BURST ];uint16_t count;
@@ -1477,8 +1476,9 @@ drain_virtio_tx(struct vhost_dev *vdev)* } */ static int -switch_worker(void *arg __rte_unused) +switch_worker (void *arg) { +struct rte_mempool *mbuf_pool = arg;unsigned i;unsigned lcore_id =rte_lcore_id ();struct vhost_dev *vdev;
@@ -1519,7 +1519,7 @@ switch_worker(void *arg __rte_unused)drain_eth_rx (vdev);if (likely (!vdev->remove)) -drain_virtio_tx (vdev); +drain_virtio_tx (vdev, mbuf_pool); } }
@@ -1906,6 +1906,7 @@ reset_dma(void)int main (int argc,char *argv[]) { +struct rte_mempool *mbuf_pool =NULL ;unsigned lcore_id, core_id =0 ;unsigned nb_ports, valid_num_ports;int ret, i;
@@ -1982,7 +1983,7 @@ main(int argc, char *argv[]) "Skipping disabled port %d\n", portid);continue ; } -if (port_init (portid) !=0 ) +if (port_init (portid, mbuf_pool) !=0 )rte_exit (EXIT_FAILURE ,"Cannot initialize network ports\n" ); }
@@ -1998,7 +1999,7 @@ main(int argc, char *argv[])/* Launch all data cores. */ RTE_LCORE_FOREACH_WORKER (lcore_id) -rte_eal_remote_launch (switch_worker, NULL, lcore_id); +rte_eal_remote_launch (switch_worker, mbuf_pool, lcore_id);if (client_mode) flags |=RTE_VHOST_USER_CLIENT ;
examples/vhost/meson.build +0 -1
@@ -19,4 +19,3 @@ sources = files( 'virtio_net.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 16/23 examples/qos_sched: eliminate shadowed variables
In reply to Stephen HemmingerThe port_params and subport_params are global variables, then passed to load functions. The names clash so just use the globals.
--- examples/qos_sched/cfg_file.c | 12 ++++++------ examples/qos_sched/cfg_file.h | 4 ++-- examples/qos_sched/init.c | 4 ++-- examples/qos_sched/meson.build | 1 - 4 files changed, 10 insertions(+), 11 deletions(-)
examples/qos_sched/cfg_file.c +6 -6
@@ -41,20 +41,20 @@ int parse_u64(const char *entry, uint64_t *val) }int -cfg_load_port (struct rte_cfgfile *cfg,struct rte_sched_port_params *port_params) +cfg_load_port (struct rte_cfgfile *cfg) {const char *entry; -if (!cfg || !port_params) +if (!cfg)return -1 ; entry =rte_cfgfile_get_entry (cfg,"port" ,"frame overhead" );if (entry) - port_params->frame_overhead = (uint32_t )atoi (entry); + port_params.frame_overhead = (uint32_t )atoi (entry); entry =rte_cfgfile_get_entry (cfg,"port" ,"number of subports per port" );if (entry) - port_params->n_subports_per_port = (uint32_t )atoi (entry); + port_params.n_subports_per_port = (uint32_t )atoi (entry);return 0 ; }
@@ -279,13 +279,13 @@ cfg_load_subport_profile(struct rte_cfgfile *cfg, }int -cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) +cfg_load_subport (struct rte_cfgfile *cfg) {bool cman_enabled = false;const char *entry;int i, j, k; -if (!cfg || !subport_params) +if (!cfg)return -1 ;memset (app_pipe_to_profile,-1 ,sizeof (app_pipe_to_profile));
examples/qos_sched/cfg_file.h +2 -2
@@ -10,11 +10,11 @@int parse_u64 (const char *entry,uint64_t *val); -int cfg_load_port (struct rte_cfgfile *cfg,struct rte_sched_port_params *port); +int cfg_load_port (struct rte_cfgfile *cfg);int cfg_load_pipe (struct rte_cfgfile *cfg,struct rte_sched_pipe_params *pipe); -int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport (struct rte_cfgfile *cfg);int cfg_load_subport_profile (struct rte_cfgfile *cfg, struct rte_sched_subport_profile_params
examples/qos_sched/init.c +2 -2
@@ -296,11 +296,11 @@ app_load_cfg_profile(const char *profile)if (file ==NULL )rte_exit (EXIT_FAILURE ,"Cannot load configuration profile %s\n" , profile); - ret =cfg_load_port (file, &port_params); + ret =cfg_load_port (file);if (ret) goto _app_load_cfg_profile_error_return; - ret =cfg_load_subport (file, subport_params); + ret =cfg_load_subport (file);if (ret) goto _app_load_cfg_profile_error_return;
examples/qos_sched/meson.build +0 -1
@@ -18,4 +18,3 @@ sources = files( 'stats.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 17/23 examples/l2fwd-jobstats: resolve shadowed variable
In reply to Stephen HemmingerThe inner loop across ports was shadowing other definition of variable i.
--- examples/l2fwd-jobstats/main.c | 6 +++--- examples/l2fwd-jobstats/meson.build | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
examples/l2fwd-jobstats/main.c +3 -3
@@ -515,7 +515,6 @@ l2fwd_main_loop(void)uint64_t repeats =0 ; do { - uint8_t i; uint64_t now = rte_get_timer_cycles(); repeats++;
@@ -526,8 +525,9 @@ l2fwd_main_loop(void) rte_memory_order_relaxed); need_manage |= stats_read_pending; -for (i =0 ; i < qconf->n_rx_port && !need_manage; i++) - need_manage = qconf->rx_timers[i].expire < now; +for (uint16_t port_id =0 ; + port_id < qconf->n_rx_port && !need_manage; port_id++) + need_manage = qconf->rx_timers[port_id].expire < now; }while (!need_manage);
examples/l2fwd-jobstats/meson.build +0 -1
@@ -12,4 +12,3 @@ sources = files( 'main.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 18/23 examples/l2fwd-crypto: resolve shadow variable
In reply to Stephen HemmingerReplace shadowed optarg with parameter named arg.
--- examples/l2fwd-crypto/main.c | 50 +++++++++++++++---------------- examples/l2fwd-crypto/meson.build | 1 - 2 files changed, 25 insertions(+), 26 deletions(-)
examples/l2fwd-crypto/main.c +25 -25
@@ -1030,15 +1030,15 @@ l2fwd_crypto_usage(const char *prgname)/** Parse crypto device type command line argument */ static int -parse_cryptodev_type (enum cdev_type *type,char *optarg) +parse_cryptodev_type (enum cdev_type *type,const char *arg) { -if (strcmp ("HW" , optarg) ==0 ) { +if (strcmp ("HW" , arg) ==0 ) { *type =CDEV_TYPE_HW ;return 0 ; - }else if (strcmp ("SW" , optarg) ==0 ) { + }else if (strcmp ("SW" , arg) ==0 ) { *type =CDEV_TYPE_SW ;return 0 ; - }else if (strcmp ("ANY" , optarg) ==0 ) { + }else if (strcmp ("ANY" , arg) ==0 ) { *type =CDEV_TYPE_ANY ;return 0 ; }
@@ -1048,21 +1048,21 @@ parse_cryptodev_type(enum cdev_type *type, char *optarg)/** Parse crypto chain xform command line argument */ static int -parse_crypto_opt_chain (struct l2fwd_crypto_options *options,char *optarg) +parse_crypto_opt_chain (struct l2fwd_crypto_options *options,const char *arg) { -if (strcmp ("CIPHER_HASH" , optarg) ==0 ) { +if (strcmp ("CIPHER_HASH" , arg) ==0 ) { options->xform_chain =L2FWD_CRYPTO_CIPHER_HASH ;return 0 ; - }else if (strcmp ("HASH_CIPHER" , optarg) ==0 ) { + }else if (strcmp ("HASH_CIPHER" , arg) ==0 ) { options->xform_chain =L2FWD_CRYPTO_HASH_CIPHER ;return 0 ; - }else if (strcmp ("CIPHER_ONLY" , optarg) ==0 ) { + }else if (strcmp ("CIPHER_ONLY" , arg) ==0 ) { options->xform_chain =L2FWD_CRYPTO_CIPHER_ONLY ;return 0 ; - }else if (strcmp ("HASH_ONLY" , optarg) ==0 ) { + }else if (strcmp ("HASH_ONLY" , arg) ==0 ) { options->xform_chain =L2FWD_CRYPTO_HASH_ONLY ;return 0 ; - }else if (strcmp ("AEAD" , optarg) ==0 ) { + }else if (strcmp ("AEAD" , arg) ==0 ) { options->xform_chain =L2FWD_CRYPTO_AEAD ;return 0 ; }
@@ -1072,10 +1072,10 @@ parse_crypto_opt_chain(struct l2fwd_crypto_options *options, char *optarg)/** Parse crypto cipher algo option command line argument */ static int -parse_cipher_algo (enum rte_crypto_cipher_algorithm *algo,char *optarg) +parse_cipher_algo (enum rte_crypto_cipher_algorithm *algo,const char *arg) { -if (rte_cryptodev_get_cipher_algo_enum (algo, optarg) <0 ) { +if (rte_cryptodev_get_cipher_algo_enum (algo, arg) <0 ) {RTE_LOG (ERR ,USER1 ,"Cipher algorithm specified " "not supported!\n" );return -1 ;
@@ -1086,12 +1086,12 @@ parse_cipher_algo(enum rte_crypto_cipher_algorithm *algo, char *optarg)/** Parse crypto cipher operation command line argument */ static int -parse_cipher_op (enum rte_crypto_cipher_operation *op,char *optarg) +parse_cipher_op (enum rte_crypto_cipher_operation *op,const char *arg) { -if (strcmp ("ENCRYPT" , optarg) ==0 ) { +if (strcmp ("ENCRYPT" , arg) ==0 ) { *op =RTE_CRYPTO_CIPHER_OP_ENCRYPT ;return 0 ; - }else if (strcmp ("DECRYPT" , optarg) ==0 ) { + }else if (strcmp ("DECRYPT" , arg) ==0 ) { *op =RTE_CRYPTO_CIPHER_OP_DECRYPT ;return 0 ; }
@@ -1146,9 +1146,9 @@ parse_size(int *size, const char *q_arg)/** Parse crypto cipher operation command line argument */ static int -parse_auth_algo (enum rte_crypto_auth_algorithm *algo,char *optarg) +parse_auth_algo (enum rte_crypto_auth_algorithm *algo,const char *arg) { -if (rte_cryptodev_get_auth_algo_enum (algo, optarg) <0 ) { +if (rte_cryptodev_get_auth_algo_enum (algo, arg) <0 ) {RTE_LOG (ERR ,USER1 ,"Authentication algorithm specified " "not supported!\n" );return -1 ;
@@ -1158,12 +1158,12 @@ parse_auth_algo(enum rte_crypto_auth_algorithm *algo, char *optarg) }static int -parse_auth_op (enum rte_crypto_auth_operation *op,char *optarg) +parse_auth_op (enum rte_crypto_auth_operation *op,const char *arg) { -if (strcmp ("VERIFY" , optarg) ==0 ) { +if (strcmp ("VERIFY" , arg) ==0 ) { *op =RTE_CRYPTO_AUTH_OP_VERIFY ;return 0 ; - }else if (strcmp ("GENERATE" , optarg) ==0 ) { + }else if (strcmp ("GENERATE" , arg) ==0 ) { *op =RTE_CRYPTO_AUTH_OP_GENERATE ;return 0 ; }
@@ -1173,9 +1173,9 @@ parse_auth_op(enum rte_crypto_auth_operation *op, char *optarg) }static int -parse_aead_algo (enum rte_crypto_aead_algorithm *algo,char *optarg) +parse_aead_algo (enum rte_crypto_aead_algorithm *algo,const char *arg) { -if (rte_cryptodev_get_aead_algo_enum (algo, optarg) <0 ) { +if (rte_cryptodev_get_aead_algo_enum (algo, arg) <0 ) {RTE_LOG (ERR ,USER1 ,"AEAD algorithm specified " "not supported!\n" );return -1 ;
@@ -1185,12 +1185,12 @@ parse_aead_algo(enum rte_crypto_aead_algorithm *algo, char *optarg) }static int -parse_aead_op (enum rte_crypto_aead_operation *op,char *optarg) +parse_aead_op (enum rte_crypto_aead_operation *op,const char *arg) { -if (strcmp ("ENCRYPT" , optarg) ==0 ) { +if (strcmp ("ENCRYPT" , arg) ==0 ) { *op =RTE_CRYPTO_AEAD_OP_ENCRYPT ;return 0 ; - }else if (strcmp ("DECRYPT" , optarg) ==0 ) { + }else if (strcmp ("DECRYPT" , arg) ==0 ) { *op =RTE_CRYPTO_AEAD_OP_DECRYPT ;return 0 ; }
examples/l2fwd-crypto/meson.build +0 -1
@@ -15,4 +15,3 @@ sources = files( 'main.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 19/23 examples/l2fwd-event: resolve shadowed variable
In reply to Stephen HemmingerReplace shadowed global optarg with parameter named arg.
--- examples/l2fwd-event/main.c | 15 +++++++-------- examples/l2fwd-event/meson.build | 1 - 2 files changed, 7 insertions(+), 9 deletions(-)
examples/l2fwd-event/main.c +7 -8
@@ -82,24 +82,23 @@ l2fwd_event_parse_timer_period(const char *q_arg) }static void -l2fwd_event_parse_mode (const char *optarg, -struct l2fwd_resources *rsrc) +l2fwd_event_parse_mode (const char *arg,struct l2fwd_resources *rsrc) { -if (!strncmp (optarg,"poll" ,4 )) +if (!strncmp (arg,"poll" ,4 )) rsrc->event_mode = false; -else if (!strncmp (optarg,"eventdev" ,8 )) +else if (!strncmp (arg,"eventdev" ,8 )) rsrc->event_mode = true; }static void -l2fwd_event_parse_eventq_sched (const char *optarg, +l2fwd_event_parse_eventq_sched (const char *arg,struct l2fwd_resources *rsrc) { -if (!strncmp (optarg,"ordered" ,7 )) +if (!strncmp (arg,"ordered" ,7 )) rsrc->sched_type =RTE_SCHED_TYPE_ORDERED ; -else if (!strncmp (optarg,"atomic" ,6 )) +else if (!strncmp (arg,"atomic" ,6 )) rsrc->sched_type =RTE_SCHED_TYPE_ATOMIC ; -else if (!strncmp (optarg,"parallel" ,8 )) +else if (!strncmp (arg,"parallel" ,8 )) rsrc->sched_type =RTE_SCHED_TYPE_PARALLEL ; }
examples/l2fwd-event/meson.build +0 -1
@@ -17,4 +17,3 @@ sources = files( 'l2fwd_event_internal_port.c', 'l2fwd_poll.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 20/23 examples/l2fwd-keepalive: resolve shadow variable warning
In reply to Stephen HemmingerThe qconf parameter can reused, fixing a shadow warning.
--- examples/l2fwd-keepalive/main.c | 2 +- examples/l2fwd-keepalive/meson.build | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
examples/l2fwd-keepalive/main.c +1 -1
@@ -780,7 +780,7 @@ main(int argc, char **argv) }/* launch per-lcore init on every worker lcore */ RTE_LCORE_FOREACH_WORKER (lcore_id) { -struct lcore_queue_conf *qconf = &lcore_queue_conf[lcore_id]; + qconf = &lcore_queue_conf[lcore_id];if (qconf->n_rx_port ==0 ) RTE_LOG(INFO, L2FWD,
examples/l2fwd-keepalive/meson.build +0 -1
@@ -19,4 +19,3 @@ sources = files( 'main.c', 'shm.c', ) -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 21/23 examples/l3fwd-graph: resolve shadow variable warning
In reply to Stephen HemmingerReplace global optarg with parameter arg.
--- examples/l3fwd-graph/main.c | 8 ++++---- examples/l3fwd-graph/meson.build | 1 - 2 files changed, 4 insertions(+), 5 deletions(-)
examples/l3fwd-graph/main.c +4 -4
@@ -454,16 +454,16 @@ parse_config(const char *q_arg) }static void -parse_eth_dest (const char *optarg) +parse_eth_dest (const char *arg) {uint8_t c, *dest, peer_addr[6 ];uint16_t portid;char *port_end; errno =0 ; - portid =strtoul (optarg, &port_end,10 ); -if (errno !=0 || port_end == optarg || *port_end++ !=',' ) -rte_exit (EXIT_FAILURE ,"Invalid eth-dest: %s" , optarg); + portid =strtoul (arg, &port_end,10 ); +if (errno !=0 || port_end == arg || *port_end++ !=',' ) +rte_exit (EXIT_FAILURE ,"Invalid eth-dest: %s" , arg);if (portid >=RTE_MAX_ETHPORTS ) rte_exit(EXIT_FAILURE, "eth-dest: port %d >= RTE_MAX_ETHPORTS(%d)\n", portid,
examples/l3fwd-graph/meson.build +0 -1
@@ -11,4 +11,3 @@ sources = files( 'main.c', ) allow_experimental_apis = true -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 22/23 examples/l3fwd: resolve shadow variable warnings
In reply to Stephen HemmingerCorrect for shadow variables by renaming:
- global ipv6 becomes ipv6_enabled (convert int to bool)
- lcore_params used by eventdev becomes config_parsed
- masks for sse globals get xmm_ prefix
- replace global optarg with parameter named arg
--- examples/l3fwd/l3fwd.h | 2 +- examples/l3fwd/l3fwd_em.c | 32 +++++++++-------- examples/l3fwd/l3fwd_em_hlm.h | 8 ++--- examples/l3fwd/l3fwd_lpm.c | 4 +-- examples/l3fwd/l3fwd_route.h | 12 +++---- examples/l3fwd/main.c | 68 +++++++++++++++++------------------ examples/l3fwd/meson.build | 1 - 7 files changed, 65 insertions(+), 62 deletions(-)
examples/l3fwd/l3fwd.h +1 -1
@@ -99,7 +99,7 @@ extern struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];extern uint32_t enabled_port_mask;/* Used only in exact match mode. */ -extern int ipv6;/**< ipv6 is false by default. */ +extern bool ipv6_enabled;/**< ipv6 is false by default. */ extern uint32_t hash_entry_number;extern xmm_t val_eth[RTE_MAX_ETHPORTS ];
examples/l3fwd/l3fwd_em.c +18 -14
@@ -211,9 +211,9 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,static alignas(RTE_CACHE_LINE_SIZE )uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES ];static alignas(RTE_CACHE_LINE_SIZE )uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES ]; -static rte_xmm_t mask0; -static rte_xmm_t mask1; -static rte_xmm_t mask2; +static rte_xmm_t xmm_mask0; +static rte_xmm_t xmm_mask1; +static rte_xmm_t xmm_mask2;#if defined(__SSE2__) static inline xmm_t
@@ -275,7 +275,7 @@ em_get_ipv4_dst_port(void *ipv4_hdr, uint16_t portid, void *lookup_struct)* Get 5 tuple: dst port, src port, dst IP address, * src IP address and protocol. */ - key.xmm =em_mask_key (ipv4_hdr, mask0.x); + key.xmm =em_mask_key (ipv4_hdr, xmm_mask0.x);/* Find destination port */ ret =rte_hash_lookup (ipv4_l3fwd_lookup_struct, (const void *)&key);
@@ -298,7 +298,7 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint16_t portid, void *lookup_struct)void *data2 = ((uint8_t *)ipv6_hdr) +sizeof (xmm_t) +sizeof (xmm_t);/* Get part of 5 tuple: src IP address lower 96 bits and protocol */ - key.xmm[0 ] =em_mask_key (data0, mask1.x); + key.xmm[0 ] =em_mask_key (data0, xmm_mask1.x);/* * Get part of 5 tuple: dst IP address lower 96 bits
@@ -314,7 +314,7 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint16_t portid, void *lookup_struct)* Get part of 5 tuple: dst port and src port * and dst IP address higher 32 bits. */ - key.xmm[2 ] =em_mask_key (data2, mask2.x); + key.xmm[2 ] =em_mask_key (data2, xmm_mask2.x);/* Find destination port */ ret =rte_hash_lookup (ipv6_l3fwd_lookup_struct, (const void *)&key);
@@ -375,8 +375,9 @@ populate_ipv4_flow_into_table(const struct rte_hash *h)char srcbuf[INET6_ADDRSTRLEN ];char dstbuf[INET6_ADDRSTRLEN ]; - mask0 = (rte_xmm_t ){.u32 = {BIT_8_TO_15 ,ALL_32_BITS , -ALL_32_BITS ,ALL_32_BITS } }; + xmm_mask0 = (rte_xmm_t ) { + .u32 = {BIT_8_TO_15 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } + };for (i =0 ; i < route_num_v4; i++) {struct em_rule *entry;
@@ -427,10 +428,13 @@ populate_ipv6_flow_into_table(const struct rte_hash *h)char srcbuf[INET6_ADDRSTRLEN ];char dstbuf[INET6_ADDRSTRLEN ]; - mask1 = (rte_xmm_t ){.u32 = {BIT_16_TO_23 ,ALL_32_BITS , -ALL_32_BITS ,ALL_32_BITS } }; + xmm_mask1 = (rte_xmm_t ){ + .u32 = {BIT_16_TO_23 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } + }; - mask2 = (rte_xmm_t ){.u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } }; + xmm_mask2 = (rte_xmm_t ){ + .u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } + };for (i =0 ; i < route_num_v6; i++) {struct em_rule *entry;
@@ -507,11 +511,11 @@ em_check_ptype(int portid) } } -if (!ipv6 && !ptype_l3_ipv4_ext) { +if (!ipv6_enabled && !ptype_l3_ipv4_ext) {printf ("port %d cannot parse RTE_PTYPE_L3_IPV4_EXT\n" , portid);return 0 ; } -if (ipv6 && !ptype_l3_ipv6_ext) { +if (ipv6_enabled && !ptype_l3_ipv6_ext) {printf ("port %d cannot parse RTE_PTYPE_L3_IPV6_EXT\n" , portid);return 0 ; }
@@ -1010,7 +1014,7 @@ setup_hash(const int socketid)* Use data from ipv4/ipv6 l3fwd config file * directly to initialize the hash table. */ -if (ipv6 ==0 ) { +if (!ipv6_enabled) {/* populate the ipv4 hash */ populate_ipv4_flow_into_table ( ipv4_l3fwd_em_lookup_struct[socketid]);
examples/l3fwd/l3fwd_em_hlm.h +4 -4
@@ -31,7 +31,7 @@ em_get_dst_port_ipv4xN(struct lcore_conf *qconf, struct rte_mbuf *m[],const void *key_array[EM_HASH_LOOKUP_COUNT ];for (i =0 ; i <EM_HASH_LOOKUP_COUNT ; i++) { -get_ipv4_5tuple (m[i], mask0.x, &key[i]); +get_ipv4_5tuple (m[i], xmm_mask0.x, &key[i]); key_array[i] = &key[i]; }
@@ -58,7 +58,7 @@ em_get_dst_port_ipv6xN(struct lcore_conf *qconf, struct rte_mbuf *m[],const void *key_array[EM_HASH_LOOKUP_COUNT ];for (i =0 ; i <EM_HASH_LOOKUP_COUNT ; i++) { -get_ipv6_5tuple (m[i], mask1.x, mask2.x, &key[i]); +get_ipv6_5tuple (m[i], xmm_mask1.x, xmm_mask2.x, &key[i]); key_array[i] = &key[i]; }
@@ -85,7 +85,7 @@ em_get_dst_port_ipv4xN_events(struct lcore_conf *qconf, struct rte_mbuf *m[],const void *key_array[EM_HASH_LOOKUP_COUNT ];for (i =0 ; i <EM_HASH_LOOKUP_COUNT ; i++) { -get_ipv4_5tuple (m[i], mask0.x, &key[i]); +get_ipv4_5tuple (m[i], xmm_mask0.x, &key[i]); key_array[i] = &key[i]; }
@@ -112,7 +112,7 @@ em_get_dst_port_ipv6xN_events(struct lcore_conf *qconf, struct rte_mbuf *m[],const void *key_array[EM_HASH_LOOKUP_COUNT ];for (i =0 ; i <EM_HASH_LOOKUP_COUNT ; i++) { -get_ipv6_5tuple (m[i], mask1.x, mask2.x, &key[i]); +get_ipv6_5tuple (m[i], xmm_mask1.x, xmm_mask2.x, &key[i]); key_array[i] = &key[i]; }
examples/l3fwd/l3fwd_lpm.c +2 -2
@@ -681,12 +681,12 @@ lpm_check_ptype(int portid) ptype_l3_ipv6 =1 ; } -if (!ipv6 && !ptype_l3_ipv4) { +if (!ipv6_enabled && !ptype_l3_ipv4) {printf ("port %d cannot parse RTE_PTYPE_L3_IPV4\n" , portid);return 0 ; } -if (ipv6 && !ptype_l3_ipv6) { +if (ipv6_enabled && !ptype_l3_ipv6) {printf ("port %d cannot parse RTE_PTYPE_L3_IPV6\n" , portid);return 0 ; }
examples/l3fwd/l3fwd_route.h +6 -6
@@ -14,14 +14,14 @@#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t))#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ - unsigned long val; \ - char *end; \ + unsigned long _val; \ + char *_end; \ errno = 0; \ - val = strtoul((in), &end, (base)); \ - if (errno != 0 || end[0] != (dlm) || val > (lim)) \ + _val = strtoul((in), &_end, (base)); \ + if (errno != 0 || _end[0] != (dlm) || _val > (lim)) \ return -EINVAL; \ - (fd) = (typeof(fd))val; \ - (in) = end + 1; \ + (fd) = (typeof(fd))_val; \ + (in) = _end + 1; \ } while (0)struct ipv4_l3fwd_route {
examples/l3fwd/main.c +34 -34
181 lines not on this page · raw message
examples/l3fwd/meson.build +0 -1
@@ -22,4 +22,3 @@ if dpdk_conf.has('RTE_LIB_EVENTDEV') deps += 'eventdev' endif cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
PATCH v2 23/23 examples/l3fwd-power: resolve shadow variable warnings
In reply to Stephen HemmingerRename function parameters to avoid shadowing the file-scope static arrays ipv4_l3fwd_lookup_struct and ipv6_l3fwd_lookup_struct. The new parameter names ipv4_lookup_struct and ipv6_lookup_struct match the member names used in struct lcore_conf.
Fixes warnings with -Wshadow for get_ipv4_dst_port (both exact-match and LPM variants) and get_ipv6_dst_port.
--- examples/l3fwd-power/main.c | 12 ++++++------ examples/l3fwd-power/meson.build | 1 - 2 files changed, 6 insertions(+), 7 deletions(-)
examples/l3fwd-power/main.c +6 -6
@@ -552,7 +552,7 @@ print_ipv6_key(struct ipv6_5tuple key)static inline uint16_t get_ipv4_dst_port (struct rte_ipv4_hdr *ipv4_hdr,uint16_t portid, -lookup_struct_t * ipv4_l3fwd_lookup_struct) +lookup_struct_t *ipv4_lookup_struct) {struct ipv4_5tuple key;struct rte_tcp_hdr *tcp;
@@ -585,13 +585,13 @@ get_ipv4_dst_port(struct rte_ipv4_hdr *ipv4_hdr, uint16_t portid, }/* Find destination port */ - ret =rte_hash_lookup (ipv4_l3fwd_lookup_struct, (const void *)&key); + ret =rte_hash_lookup (ipv4_lookup_struct, (const void *)&key);return ((ret <0 ) ? portid : ipv4_l3fwd_out_if[ret]); }static inline uint16_t get_ipv6_dst_port (struct rte_ipv6_hdr *ipv6_hdr,uint16_t portid, -lookup_struct_t *ipv6_l3fwd_lookup_struct) +lookup_struct_t *ipv6_lookup_struct) {struct ipv6_5tuple key;struct rte_tcp_hdr *tcp;
@@ -625,7 +625,7 @@ get_ipv6_dst_port(struct rte_ipv6_hdr *ipv6_hdr, uint16_t portid, }/* Find destination port */ - ret =rte_hash_lookup (ipv6_l3fwd_lookup_struct, (const void *)&key); + ret =rte_hash_lookup (ipv6_lookup_struct, (const void *)&key);return ((ret <0 ) ? portid : ipv6_l3fwd_out_if[ret]); }#endif
@@ -633,11 +633,11 @@ get_ipv6_dst_port(struct rte_ipv6_hdr *ipv6_hdr, uint16_t portid,#if (APP_LOOKUP_METHOD ==APP_LOOKUP_LPM )static inline uint16_t get_ipv4_dst_port (struct rte_ipv4_hdr *ipv4_hdr,uint16_t portid, -lookup_struct_t *ipv4_l3fwd_lookup_struct) +lookup_struct_t *ipv4_lookup_struct) {uint32_t next_hop; -return ((rte_lpm_lookup (ipv4_l3fwd_lookup_struct, +return ((rte_lpm_lookup (ipv4_lookup_struct,rte_be_to_cpu_32 (ipv4_hdr->dst_addr), &next_hop) ==0 )? next_hop : portid); }
examples/l3fwd-power/meson.build +0 -1
@@ -13,4 +13,3 @@ sources = files( 'perf_core.c', ) cflags += no_wvla_cflag -cflags += no_shadow_cflag
Signature · 1 line
2.53.0
Re: [PATCH v2 03/23] examples/dma: resolve shadow variable warnings
In reply to Stephen HemmingerQuoted 13 lines · Stephen Hemminger
Fix shadow variable warnings by:
- Renaming 'copy_mode' parameter to 'mode' indma_parse_copy_mode()
- Removing 'nb_queues' parameter fromport_init()and using the global variable directly, since it's always called with the globalnb_queuesvalue
../examples/dma/dmafwd.c:593:33: warning: declaration of 'copy_mode' shadows a global declaration [-Wshadow]../examples/dma/dmafwd.c:881:68: warning: declaration of 'nb_queues' shadows a global declaration [-Wshadow]Signed-off-by Stephen Hemminger <[email protected]>Acked-by Bruce Richardson <[email protected]>
Re: [PATCH v2 01/23] examples/ethtool: resolve shadow variable warnings
In reply to Stephen HemmingerQuoted 8 lines · Stephen Hemminger
Fix shadow variable warning by renaming the function parameter from '
app_cfg' to 'ptr_cfg' to avoid shadowing the global variable.
../examples/ethtool/ethtool-app/main.c:89:44: warning: declaration of 'app_cfg' shadows a global declaration [-Wshadow]Signed-off-by Stephen Hemminger <[email protected]>Acked-by Bruce Richardson <[email protected]>
Re: [PATCH v2 09/23] examples/ipsec-secgw: resolve shadowed variable warnings
In reply to Stephen HemmingerQuoted 7 lines · Stephen Hemminger
Rename variables where local variable shadows a global declaration. Remove unused
lcore_confparameter fromsa_init(). Replace shadowed optarg with parameter named arg.Signed-off-by Stephen Hemminger <[email protected]>Acked-by Bruce Richardson <[email protected]>---
Re: [PATCH v2 12/23] examples/vm_power_manage: enable shadow warnings
In reply to Stephen Hemminger07/04/2026 17:16, Stephen Hemminger:
Quoted 1 line
No problems in this code, re-enable the warning.
Actually, there are a lot of variables ret defined multiple times in the same function.
Re: [PATCH v2 09/23] examples/ipsec-secgw: resolve shadowed variable warnings
In reply to Stephen Hemminger07/04/2026 17:16, Stephen Hemminger:
Quoted 3 lines
Rename variables where local variable shadows a global declaration. Remove unused
lcore_confparameter fromsa_init(). Replace shadowed optarg with parameter named arg.
There are more in the Arm implementation.
Re: [PATCH v2 00/23] examples: fix -Wshadow warnings
In reply to Stephen Hemminger07/04/2026 17:15, Stephen Hemminger:
Quoted 14 lines
Several DPDK examples had -Wshadow disabled via
no_shadow_cflagin their meson.build files. This series fixes all shadow variable warnings and removes the suppression flag, so that -Wshadow is enabled uniformly across every example.The fixes fall into three categories:
- Renaming function parameters or local variables that shadow globals (most patches)
- Removing unused function parameters that duplicated globals (dma, bond,flow_filtering, ipsec-secgw, vhost,qos_sched)
- Simply removingno_shadow_cflagwhere there were no warnings (vm_power_manage,bbdev_app, l2fwd-crypto, l2fwd-event, l3fwd-graph)
Quoted 1 line
v2 - fix additional shadow warnings only visible with clang
Applied with fixes noted in the thread, thanks.