From patchwork Wed Mar 9 19:53:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 595222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 79F64140662 for ; Thu, 10 Mar 2016 06:57:08 +1100 (AEDT) Received: from localhost ([::1]:43845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adkEE-0002Hy-Lu for incoming@patchwork.ozlabs.org; Wed, 09 Mar 2016 14:57:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adkB8-0004z7-4k for qemu-devel@nongnu.org; Wed, 09 Mar 2016 14:53:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adkB6-0007vx-Un for qemu-devel@nongnu.org; Wed, 09 Mar 2016 14:53:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33615) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adkB6-0007vk-PH for qemu-devel@nongnu.org; Wed, 09 Mar 2016 14:53:52 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 588446035; Wed, 9 Mar 2016 19:53:52 +0000 (UTC) Received: from gimli.home (ovpn-113-206.phx2.redhat.com [10.3.113.206]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u29JrpdA012892; Wed, 9 Mar 2016 14:53:52 -0500 From: Alex Williamson To: qemu-devel@nongnu.org Date: Wed, 09 Mar 2016 12:53:51 -0700 Message-ID: <20160309195351.11580.44843.stgit@gimli.home> In-Reply-To: <20160309195208.11580.57085.stgit@gimli.home> References: <20160309195208.11580.57085.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 09 Mar 2016 19:53:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: Kirti Wankhede , Neo Jia Subject: [Qemu-devel] [PULL 7/8] vfio/pci: replace fixed string limit by g_strdup_printf X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Neo Jia A trivial change to remove string limit by using g_strdup_printf Tested-by: Neo Jia Signed-off-by: Neo Jia Signed-off-by: Kirti Wankhede Signed-off-by: Alex Williamson --- hw/vfio/pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 30eb945..d091d8c 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -919,7 +919,7 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset = vdev->config_offset + PCI_ROM_ADDRESS; DeviceState *dev = DEVICE(vdev); - char name[32]; + char *name; int fd = vdev->vbasedev.fd; if (vdev->pdev.romfile || !vdev->pdev.rom_bar) { @@ -962,10 +962,11 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) trace_vfio_pci_size_rom(vdev->vbasedev.name, size); - snprintf(name, sizeof(name), "vfio[%s].rom", vdev->vbasedev.name); + name = g_strdup_printf("vfio[%s].rom", vdev->vbasedev.name); memory_region_init_io(&vdev->pdev.rom, OBJECT(vdev), &vfio_rom_ops, vdev, name, size); + g_free(name); pci_register_bar(&vdev->pdev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_SPACE_MEMORY, &vdev->pdev.rom);