From: Stephen Hemminger <stephen@networkplumber.org>
To: "WanRenyong" <wanry@yunsilicon.com>
Cc: <dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
<qianr@yunsilicon.com>, <nana@yunsilicon.com>,
<zhangxx@yunsilicon.com>, <xudw@yunsilicon.com>,
<jacky@yunsilicon.com>, <weihg@yunsilicon.com>
Subject: Re: [PATCH v6 06/15] net/xsc: initialize xsc representors
Date: Mon, 20 Jan 2025 11:06:19 -0800 [thread overview]
Message-ID: <20250120110619.33edcdec@hermes.local> (raw)
In-Reply-To: <20250120111443.1048479-7-wanry@yunsilicon.com>
On Mon, 20 Jan 2025 19:14:44 +0800
"WanRenyong" <wanry@yunsilicon.com> wrote:
> +static int
> +xsc_ethdev_init_representors(struct rte_eth_dev *eth_dev)
> +{
> + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(eth_dev);
> + struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
> + struct rte_device *dev;
> + struct xsc_dev *xdev;
> + struct xsc_repr_port *repr_port;
> + char name[RTE_ETH_NAME_MAX_LEN];
> + int i;
> + int ret;
> +
> + PMD_INIT_FUNC_TRACE();
> +
> + dev = &priv->pci_dev->device;
> + if (dev->devargs != NULL) {
> + ret = rte_eth_devargs_parse(dev->devargs->args, ð_da, 1);
> + if (ret < 0) {
> + PMD_DRV_LOG(ERR, "Failed to parse device arguments: %s",
> + dev->devargs->args);
> + return -EINVAL;
> + }
> + }
> +
> + xdev = priv->xdev;
> + ret = xsc_dev_repr_ports_probe(xdev, eth_da.nb_representor_ports, RTE_MAX_ETHPORTS);
> + if (ret != 0) {
> + PMD_DRV_LOG(ERR, "Failed to probe %d xsc device representors",
> + eth_da.nb_representor_ports);
> + return ret;
> + }
> +
> + /* PF rep init */
> + repr_port = &xdev->repr_ports[xdev->num_repr_ports - 1];
> + ret = xsc_ethdev_init_one_representor(eth_dev, repr_port);
> + if (ret != 0) {
> + PMD_DRV_LOG(ERR, "Failed to init backing representor");
> + return ret;
> + }
> +
> + /* VF rep init */
> + for (i = 0; i < eth_da.nb_representor_ports; i++) {
> + repr_port = &xdev->repr_ports[i];
> + snprintf(name, sizeof(name), "%s_rep_%d",
> + xdev->name, repr_port->info.repr_id);
If I enable format-truncation warnings then there is this message.
The warning is suppressed by drivers/meson.build, but would like in the future
to not disable warnings there.
../drivers/net/xsc/xsc_ethdev.c: In function ‘xsc_ethdev_init’:
../drivers/net/xsc/xsc_ethdev.c:787:49: warning: ‘_rep_’ directive output may be truncated writing 5 bytes into a region of size between 1 and 64 [-Wformat-truncation=]
787 | snprintf(name, sizeof(name), "%s_rep_%d",
| ^~~~~
In function ‘xsc_ethdev_init_representors’,
inlined from ‘xsc_ethdev_init’ at ../drivers/net/xsc/xsc_ethdev.c:834:8:
../drivers/net/xsc/xsc_ethdev.c:787:17: note: ‘snprintf’ output between 7 and 80 bytes into a destination of size 64
787 | snprintf(name, sizeof(name), "%s_rep_%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
788 | xdev->name, repr_port->info.repr_id);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is because local variable name is of size RTE_ETH_NAME_MAX_LEN which is 64
and xdev->name is defined as RTE_ETH_NAME_MAX_LEN as well.
The warning is correct but impossible to happen since xdev->name is only filled
in with PCI information. A simple way to get rid of it (and save some space)
would be to define name to be for PCI address only.
Would this work?
diff --git a/drivers/net/xsc/xsc_dev.h b/drivers/net/xsc/xsc_dev.h
index d661523e13..cc5fa8aad8 100644
--- a/drivers/net/xsc/xsc_dev.h
+++ b/drivers/net/xsc/xsc_dev.h
@@ -121,7 +121,7 @@ struct xsc_dev {
int ifindex;
int port_id; /* Probe dev */
void *dev_priv;
- char name[RTE_ETH_NAME_MAX_LEN];
+ char name[PCI_PRI_STR_SIZE];
void *bar_addr;
void *jumbo_buffer_pa;
void *jumbo_buffer_va;
next prev parent reply other threads:[~2025-01-20 19:06 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-20 11:15 [PATCH v6 00/15] XSC PMD for Yunsilicon NICs WanRenyong
2025-01-20 11:14 ` [PATCH v6 01/15] net/xsc: add xsc PMD framework WanRenyong
2025-01-22 13:39 ` Thomas Monjalon
2025-01-23 5:48 ` WanRenyong
2025-01-23 7:59 ` Thomas Monjalon
2025-01-23 9:19 ` WanRenyong
2025-01-23 14:41 ` Thomas Monjalon
2025-01-23 16:09 ` Stephen Hemminger
2025-01-24 16:26 ` WanRenyong
2025-01-20 11:14 ` [PATCH v6 02/15] net/xsc: add xsc device initialization WanRenyong
2025-01-20 11:14 ` [PATCH v6 03/15] net/xsc: add xsc mailbox WanRenyong
2025-01-20 18:18 ` Stephen Hemminger
2025-01-21 2:39 ` WanRenyong
2025-01-20 18:19 ` Stephen Hemminger
2025-01-21 3:31 ` WanRenyong
2025-01-20 11:14 ` [PATCH v6 04/15] net/xsc: add xsc dev ops to support VFIO driver WanRenyong
2025-01-20 11:14 ` [PATCH v6 05/15] net/xsc: add PCT interfaces WanRenyong
2025-01-20 18:24 ` Stephen Hemminger
2025-01-21 3:44 ` WanRenyong
2025-01-20 11:14 ` [PATCH v6 06/15] net/xsc: initialize xsc representors WanRenyong
2025-01-20 19:06 ` Stephen Hemminger [this message]
2025-01-21 5:27 ` WanRenyong
2025-01-20 11:14 ` [PATCH v6 07/15] net/xsc: add ethdev configure and RSS ops WanRenyong
2025-01-20 11:14 ` [PATCH v6 08/15] net/xsc: add Rx and Tx queue setup WanRenyong
2025-01-20 18:16 ` Stephen Hemminger
2025-01-21 3:21 ` WanRenyong
2025-01-20 11:14 ` [PATCH v6 09/15] net/xsc: add ethdev start WanRenyong
2025-01-20 11:14 ` [PATCH v6 10/15] net/xsc: add ethdev stop and close WanRenyong
2025-01-20 11:14 ` [PATCH v6 11/15] net/xsc: add ethdev Rx burst WanRenyong
2025-01-20 11:14 ` [PATCH v6 12/15] net/xsc: add ethdev Tx burst WanRenyong
2025-01-20 11:15 ` [PATCH v6 13/15] net/xsc: add basic stats ops WanRenyong
2025-01-20 11:15 ` [PATCH v6 14/15] net/xsc: add ethdev infos get WanRenyong
2025-01-20 11:15 ` [PATCH v6 15/15] net/xsc: add ethdev link and MTU ops WanRenyong
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=20250120110619.33edcdec@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=jacky@yunsilicon.com \
--cc=nana@yunsilicon.com \
--cc=qianr@yunsilicon.com \
--cc=thomas@monjalon.net \
--cc=wanry@yunsilicon.com \
--cc=weihg@yunsilicon.com \
--cc=xudw@yunsilicon.com \
--cc=zhangxx@yunsilicon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.