From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FB17460CC; Tue, 21 Jan 2025 06:27:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D298427DA; Tue, 21 Jan 2025 06:27:25 +0100 (CET) Received: from lf-2-11.ptr.blmpb.com (lf-2-11.ptr.blmpb.com [101.36.218.11]) by mails.dpdk.org (Postfix) with ESMTP id 2F36642707 for ; Tue, 21 Jan 2025 06:27:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1737437237; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=qP0LOUGcCvjIQ+4Uy4blg+WRcVbE4VkKX2wukc7H0h0=; b=kVqbKZMBSBdO4MrEF8JM/Hap9v/qGZ0Zh2p1bAQ7padlI7zYFaIuxSXtcne+QRJBc/0HpN k62+Re9YXYYMB0do97gVSQK0j2BaHkWafDjXpO7M8yEimBDtF0dX7vJzeKXXE1gVJ+qSJB XVReRpc3VbWoQj8Qlxs53wfaFyqd6UcFKA3EmxcIbtbWT2q9nNb6rmfGOEN27iqZ14QPrY UNJdwSdzCA1DvTmnIxigo6LXM4mbfh6vbxga6STSGV9nBI5sazbOr9S4mRM4I3OgrBmulP 1pP0Yoj2xrhwILvWo21EtyNvPBfPedA7CvDxI2PRuwCDjdGCADFrvGpH+zghsg== Cc: , , , , , , , , Date: Tue, 21 Jan 2025 13:27:14 +0800 Mime-Version: 1.0 References: <20250120111431.1048479-1-wanry@yunsilicon.com> <20250120111443.1048479-7-wanry@yunsilicon.com> <20250120110619.33edcdec@hermes.local> Content-Transfer-Encoding: quoted-printable To: "Stephen Hemminger" X-Original-From: WanRenyong User-Agent: Mozilla Thunderbird From: "WanRenyong" Subject: Re: [PATCH v6 06/15] net/xsc: initialize xsc representors Content-Type: text/plain; charset=UTF-8 X-Lms-Return-Path: Message-Id: <196f1fd9-f05c-4233-ac20-9d79b9ed48b6@yunsilicon.com> In-Reply-To: <20250120110619.33edcdec@hermes.local> Received: from [127.0.0.1] ([218.1.186.193]) by smtp.feishu.cn with ESMTPS; Tue, 21 Jan 2025 13:27:15 +0800 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2025/1/21 3:06, Stephen Hemminger wrote: > On Mon, 20 Jan 2025 19:14:44 +0800 > "WanRenyong" wrote: > >> +static int >> +xsc_ethdev_init_representors(struct rte_eth_dev *eth_dev) >> +{ >> + struct xsc_ethdev_priv *priv =3D TO_XSC_ETHDEV_PRIV(eth_dev); >> + struct rte_eth_devargs eth_da =3D { .nb_representor_ports =3D 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 =3D &priv->pci_dev->device; >> + if (dev->devargs !=3D NULL) { >> + ret =3D 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 =3D priv->xdev; >> + ret =3D xsc_dev_repr_ports_probe(xdev, eth_da.nb_representor_ports, RT= E_MAX_ETHPORTS); >> + if (ret !=3D 0) { >> + PMD_DRV_LOG(ERR, "Failed to probe %d xsc device representors", >> + eth_da.nb_representor_ports); >> + return ret; >> + } >> + >> + /* PF rep init */ >> + repr_port =3D &xdev->repr_ports[xdev->num_repr_ports - 1]; >> + ret =3D xsc_ethdev_init_one_representor(eth_dev, repr_port); >> + if (ret !=3D 0) { >> + PMD_DRV_LOG(ERR, "Failed to init backing representor"); >> + return ret; >> + } >> + >> + /* VF rep init */ >> + for (i =3D 0; i < eth_da.nb_representor_ports; i++) { >> + repr_port =3D &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 f= uture > to not disable warnings there. > > ../drivers/net/xsc/xsc_ethdev.c: In function =E2=80=98xsc_ethdev_init=E2= =80=99: > ../drivers/net/xsc/xsc_ethdev.c:787:49: warning: =E2=80=98_rep_=E2=80=99 = directive output may be truncated writing 5 bytes into a region of size bet= ween 1 and 64 [-Wformat-truncation=3D] > 787 | snprintf(name, sizeof(name), "%s_rep_%d", > | ^~~~~ > In function =E2=80=98xsc_ethdev_init_representors=E2=80=99, > inlined from =E2=80=98xsc_ethdev_init=E2=80=99 at ../drivers/net/xsc= /xsc_ethdev.c:834:8: > ../drivers/net/xsc/xsc_ethdev.c:787:17: note: =E2=80=98snprintf=E2=80=99 = 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 spa= ce) > 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; Hello Stephen Hemminger, Thanks for your review. Your suggestion is correct. In fact, xdev->name is initialized to the=20 PCI address , it will work if size of xdev->name defined as=20 PCI_PRI_STR_SIZE. I will=C2=A0 modify it in the next version. --=20 Best regards, WanRenyong