From patchwork Fri Mar 11 16:01:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 8567141 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 04CB49F1C0 for ; Fri, 11 Mar 2016 16:01:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BFC9D2034C for ; Fri, 11 Mar 2016 16:01:40 +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 CFFFC20272 for ; Fri, 11 Mar 2016 16:01:39 +0000 (UTC) Received: from localhost ([::1]:56101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aePVT-0003QF-4i for patchwork-qemu-devel@patchwork.kernel.org; Fri, 11 Mar 2016 11:01:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aePV5-000361-IK for qemu-devel@nongnu.org; Fri, 11 Mar 2016 11:01:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aePV4-0001RX-7F for qemu-devel@nongnu.org; Fri, 11 Mar 2016 11:01:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aePV4-0001RL-2l for qemu-devel@nongnu.org; Fri, 11 Mar 2016 11:01:14 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id A0233486B1 for ; Fri, 11 Mar 2016 16:01:13 +0000 (UTC) Received: from gimli.home (ovpn-113-206.phx2.redhat.com [10.3.113.206]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2BG1DSP006481; Fri, 11 Mar 2016 11:01:13 -0500 From: Alex Williamson To: qemu-devel@nongnu.org Date: Fri, 11 Mar 2016 09:01:13 -0700 Message-ID: <20160311160113.30825.61429.stgit@gimli.home> In-Reply-To: <20160311155841.30825.6907.stgit@gimli.home> References: <20160311155841.30825.6907.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 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);