On Wed, Dec 21, 2022 at 3:20 PM Alvaro Karsz <alvaro.karsz@xxxxxxxxxxxxx> wrote: > > The buffer size and the size passed to snprintf don't match, causing > clang warnings. > > This patch increases a little bit the size of the buffer, and uses > sizeof() to get the buffer size. > > This patch should be applied on top of the following patch: > > virtio: vdpa: new SolidNET DPU driver, > by Alvaro Karsz alvaro.karsz@xxxxxxxxxxxxx > > Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx> > Signed-off-by: Alvaro Karsz <alvaro.karsz@xxxxxxxxxxxxx> Acked-by: Jason Wang <jasowang@xxxxxxxxxx> Thanks > --- > drivers/vdpa/solidrun/snet_main.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/vdpa/solidrun/snet_main.c b/drivers/vdpa/solidrun/snet_main.c > index d438a89b359..9ceacf96de0 100644 > --- a/drivers/vdpa/solidrun/snet_main.c > +++ b/drivers/vdpa/solidrun/snet_main.c > @@ -540,7 +540,7 @@ static const struct vdpa_config_ops snet_config_ops = { > > static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) > { > - char name[25]; > + char name[50]; > int ret, i, mask = 0; > /* We don't know which BAR will be used to communicate.. > * We will map every bar with len > 0. > @@ -558,7 +558,7 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) > return -ENODEV; > } > > - snprintf(name, SNET_NAME_SIZE, "psnet[%s]-bars", pci_name(pdev)); > + snprintf(name, sizeof(name), "psnet[%s]-bars", pci_name(pdev)); > ret = pcim_iomap_regions(pdev, mask, name); > if (ret) { > SNET_ERR(pdev, "Failed to request and map PCI BARs\n"); > @@ -575,10 +575,10 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) > > static int snet_open_vf_bar(struct pci_dev *pdev, struct snet *snet) > { > - char name[20]; > + char name[50]; > int ret; > > - snprintf(name, SNET_NAME_SIZE, "snet[%s]-bar", pci_name(pdev)); > + snprintf(name, sizeof(name), "snet[%s]-bar", pci_name(pdev)); > /* Request and map BAR */ > ret = pcim_iomap_regions(pdev, BIT(snet->psnet->cfg.vf_bar), name); > if (ret) { > -- > 2.32.0 > _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization