From patchwork Thu Mar 10 16:56:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 8558771 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3F6D4C0553 for ; Thu, 10 Mar 2016 16:57:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3DAC20377 for ; Thu, 10 Mar 2016 16:57:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0071D2034C for ; Thu, 10 Mar 2016 16:57:32 +0000 (UTC) Received: from localhost ([::1]:49758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ae3tz-0000Wd-EO for patchwork-qemu-devel@patchwork.kernel.org; Thu, 10 Mar 2016 11:57:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ae3sd-0006eh-6P for qemu-devel@nongnu.org; Thu, 10 Mar 2016 11:56:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ae3sc-0007RT-6x for qemu-devel@nongnu.org; Thu, 10 Mar 2016 11:56:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ae3sc-0007RN-1O for qemu-devel@nongnu.org; Thu, 10 Mar 2016 11:56:06 -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 998F48C576; Thu, 10 Mar 2016 16:56:05 +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 u2AGu4eN030273; Thu, 10 Mar 2016 11:56:05 -0500 From: Alex Williamson To: qemu-devel@nongnu.org Date: Thu, 10 Mar 2016 09:56:04 -0700 Message-ID: <20160310165604.29980.88461.stgit@gimli.home> In-Reply-To: <20160310165407.29980.72106.stgit@gimli.home> References: <20160310165407.29980.72106.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-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);