From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Maxime Coquelin <maxime.coquelin@redhat.com>,
Chenbo Xia <chenbox@nvidia.com>
Subject: [PATCH 15/23] examples/vhost: fix shadow warnings
Date: Mon, 6 Apr 2026 20:49:41 -0700 [thread overview]
Message-ID: <20260407035209.650419-16-stephen@networkplumber.org> (raw)
In-Reply-To: <20260407035209.650419-1-stephen@networkplumber.org>
The 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.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/vhost/main.c | 19 ++++++++++---------
examples/vhost/meson.build | 1 -
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index ac888348d2..5978a50cfe 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -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;
diff --git a/examples/vhost/meson.build b/examples/vhost/meson.build
index af5049c7ef..e938be8f45 100644
--- a/examples/vhost/meson.build
+++ b/examples/vhost/meson.build
@@ -19,4 +19,3 @@ sources = files(
'virtio_net.c',
)
cflags += no_wvla_cflag
-cflags += no_shadow_cflag
--
2.53.0
next prev parent reply other threads:[~2026-04-07 3:53 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 3:49 [PATCH 00/23] examples: enable -Wshadow across all examples Stephen Hemminger
2026-04-07 3:49 ` [PATCH 01/23] examples/ethtool: fix shadow variable warning Stephen Hemminger
2026-04-07 3:49 ` [PATCH 02/23] examples/eventdev_pipeline: " Stephen Hemminger
2026-04-07 3:49 ` [PATCH 03/23] examples/dma: fix shadow variable warnings Stephen Hemminger
2026-04-07 3:49 ` [PATCH 04/23] examples/packet_ordering: fix shadow variable warning Stephen Hemminger
2026-04-07 3:49 ` [PATCH 05/23] examples/bond: fix shadow variable warnings Stephen Hemminger
2026-04-07 3:49 ` [PATCH 06/23] examples/vmdq: fix shadow variable warning Stephen Hemminger
2026-04-07 3:49 ` [PATCH 07/23] examples/server_node_efd: fix shadowed variable Stephen Hemminger
2026-04-07 3:49 ` [PATCH 08/23] examples/flow_filtering: fix shadowed variables Stephen Hemminger
2026-04-07 3:49 ` [PATCH 09/23] examples/ipsec-secgw: " Stephen Hemminger
2026-04-07 3:49 ` [PATCH 10/23] examples/ip_pipeline: fix shadow variable Stephen Hemminger
2026-04-07 3:49 ` [PATCH 11/23] examples/multi_process: fix shadowed variable Stephen Hemminger
2026-04-07 3:49 ` [PATCH 12/23] examples/vm_power_manage: enable shadow warnings Stephen Hemminger
2026-04-07 3:49 ` [PATCH 13/23] examples/bbdev_app: " Stephen Hemminger
2026-04-07 3:49 ` [PATCH 14/23] examples/ptpclient: fix shadow variable warnings Stephen Hemminger
2026-04-07 3:49 ` Stephen Hemminger [this message]
2026-04-07 3:49 ` [PATCH 16/23] examples/qos_sched: eliminate shadowed variables Stephen Hemminger
2026-04-07 3:49 ` [PATCH 17/23] examples/l2fwd-jobstats: fix shadowed variable Stephen Hemminger
2026-04-07 3:49 ` [PATCH 18/23] examples/l2fwd-crypto: remove no shadow flag Stephen Hemminger
2026-04-07 3:49 ` [PATCH 19/23] examples/l2fwd-event: " Stephen Hemminger
2026-04-07 3:49 ` [PATCH 20/23] examples/l2fwd-keepalive: fix shadow variable warning Stephen Hemminger
2026-04-07 3:49 ` [PATCH 21/23] examples/l3fwd-graph: remove no shadow flag Stephen Hemminger
2026-04-07 3:49 ` [PATCH 22/23] examples/l3fwd: fix shadow variable warnings Stephen Hemminger
2026-04-07 3:49 ` [PATCH 23/23] examples/l3fwd-power: " Stephen Hemminger
2026-04-07 9:22 ` [PATCH 00/23] examples: enable -Wshadow across all examples Bruce Richardson
2026-04-07 15:15 ` [PATCH v2 00/23] examples: fix -Wshadow warnings Stephen Hemminger
2026-04-07 15:15 ` [PATCH v2 01/23] examples/ethtool: resolve shadow variable warnings Stephen Hemminger
2026-04-08 0:32 ` fengchengwen
2026-04-07 15:15 ` [PATCH v2 02/23] examples/eventdev_pipeline: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:15 ` [PATCH v2 03/23] examples/dma: resolve shadow variable warnings Stephen Hemminger
2026-04-08 0:30 ` fengchengwen
2026-04-07 15:16 ` [PATCH v2 04/23] examples/packet_ordering: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 05/23] examples/bond: resolve shadow variable warnings Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 06/23] examples/vmdq: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 07/23] examples/server_node_efd: " Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 08/23] examples/flow_filtering: resolve shadowed variable warnings Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 09/23] examples/ipsec-secgw: " Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 10/23] examples/ip_pipeline: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 11/23] examples/multi_process: resolve shadowed variable warnings Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 12/23] examples/vm_power_manage: enable shadow warnings Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 13/23] examples/bbdev_app: " Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 14/23] examples/ptpclient: resolve shadow variable warnings Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 15/23] examples/vhost: resolve shadow warnings Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 16/23] examples/qos_sched: eliminate shadowed variables Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 17/23] examples/l2fwd-jobstats: resolve shadowed variable Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 18/23] examples/l2fwd-crypto: resolve shadow variable Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 19/23] examples/l2fwd-event: resolve shadowed variable Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 20/23] examples/l2fwd-keepalive: resolve shadow variable warning Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 21/23] examples/l3fwd-graph: " Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 22/23] examples/l3fwd: resolve shadow variable warnings Stephen Hemminger
2026-04-07 15:16 ` [PATCH v2 23/23] examples/l3fwd-power: " Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260407035209.650419-16-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox