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 2E3AD4608D; Mon, 20 Jan 2025 20:06:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE9EE402AC; Mon, 20 Jan 2025 20:06:24 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id 02C1D4027A for ; Mon, 20 Jan 2025 20:06:23 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2f441791e40so6219874a91.3 for ; Mon, 20 Jan 2025 11:06:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737399982; x=1738004782; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=4Zdkm1cyI47Th+f+Rkuhyc5vbB/aV/Gjzav4hFSLMKQ=; b=fg+5fF9ZrxSTQbq6jUVmObtOSSvGeeO/m+k7tGfzGMO5q6kTwOxIk7csHAJ4v4Yvge 6ttxyi2V5cbqYxXiTdWlfhzIcOPV6FJwCrCg4+MvrNTPuDCgdDpo9tQP7iLjOHrXYOCe gSyjEmsx9zVNwAzsbmnBrj9A6DDvE5a2GdS0KKdxeWAhfcdy/pwQz9qx40e4LTmu0SAu MhpIcrOq5z1lzCbcXqHr8acqjLkdmTC60yW+ghbaNru/9niAoUtllFJPyzXJcYwz3tqT WCuUn9mhlF3DhTGzlFr2a2TKagniJfGGBSomjYI8p/fwMHbSeEeoxrqCITUcg8o0Er1p qt8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737399982; x=1738004782; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Zdkm1cyI47Th+f+Rkuhyc5vbB/aV/Gjzav4hFSLMKQ=; b=U+l0v+GI1aMU8xlNo5T/jEJURhy0SNu7nwjgUcAECAVLBZ8+WnsdsBQa9aorxfk0ZC nBRaVuVoloka6EfRJYJg9avn3tYYamZ3ksbfioSrpB997GhapGaiBOMlcUzS2Yy2NL3W Dtg2nOgP6dgH71UMPoHoCGcSy6oUZFB1w8gcm3ybTKTL3vurQY1fxlR2/g4D2w6Q692Q PlAz2VViytVxWeR8ICi/pYHrpSagnPZnl3sz6Jn7sYWfRkjEl6eAxqbNF16Mr7MRPYSv 2gtsnFBjDnSsqAnEFILkH9C9aAPmoEZVAkVJ9ajccsiEsfUM/ZRavBj7wcQaUTlp8oJW kYgg== X-Gm-Message-State: AOJu0YxoMABwIA1cLmxOtqfD8+7OTwUStN6gB2UW2ChYpDTHCfLAezss UNpNTpUM8o0VGhnm8d0snjbBu5kr09XliT99TFYYz1KprKShHc4L7sP4Oyt93Ik= X-Gm-Gg: ASbGncsLm8eu7eQFbFx1HzE+wGa065gETcSa+qF5WzOMwRFbIEAMo8SHUEIShxlvdIM lYMHuNauBVkAcIWSisfy10k+hhwO1Rx3k7XinwsLvmcR4PrCXG14XPmlgWiWazUzRuAN5/s6de3 LQ1q3iWLUsm8KWjaHpygzUGfVri2iLtH0tqWRFxzxmVCIVOQoDZ5d37vsYFQcX5kn0xANzvKY+k yJblZtqo4Jpx+sB5bwgQhXCmWGD0riZrzrEKyVSX8tuXc6U8bDU1hg2d47XN5aOiyOBH7wRtdOQ U6Ujfh1lT0ri5IehOI/C07AqE2VxEdHpy/1zrKu1E5Y66rc= X-Google-Smtp-Source: AGHT+IG4D7MY86YOFoVYNm/zPhogqpEP62uOvcnCyrzbnLaoF/qTP9XzELVBmWWM1LBsonBczHxbAw== X-Received: by 2002:a17:90b:520d:b0:2ee:8e75:4ae1 with SMTP id 98e67ed59e1d1-2f782cbfcadmr18776105a91.21.1737399982035; Mon, 20 Jan 2025 11:06:22 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f77611a28asm8928063a91.10.2025.01.20.11.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 11:06:21 -0800 (PST) Date: Mon, 20 Jan 2025 11:06:19 -0800 From: Stephen Hemminger To: "WanRenyong" Cc: , , , , , , , , Subject: Re: [PATCH v6 06/15] net/xsc: initialize xsc representors Message-ID: <20250120110619.33edcdec@hermes.local> In-Reply-To: <20250120111443.1048479-7-wanry@yunsilicon.com> References: <20250120111431.1048479-1-wanry@yunsilicon.com> <20250120111443.1048479-7-wanry@yunsilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 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, RTE= _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 fut= ure 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 di= rective output may be truncated writing 5 bytes into a region of size betwe= en 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/xs= c_ethdev.c:834:8: ../drivers/net/xsc/xsc_ethdev.c:787:17: note: =E2=80=98snprintf=E2=80=99 ou= tput 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 i= s 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 fi= lled 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;