From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MuuTi-0005gL-Im for qemu-devel@nongnu.org; Mon, 05 Oct 2009 16:48:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MuuTd-0005fn-BF for qemu-devel@nongnu.org; Mon, 05 Oct 2009 16:48:17 -0400 Received: from [199.232.76.173] (port=51590 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MuuTd-0005fk-7w for qemu-devel@nongnu.org; Mon, 05 Oct 2009 16:48:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31587) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MuuTc-0007Y1-P8 for qemu-devel@nongnu.org; Mon, 05 Oct 2009 16:48:13 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n95KmB6j014129 for ; Mon, 5 Oct 2009 16:48:12 -0400 Date: Mon, 5 Oct 2009 22:46:11 +0200 From: "Michael S. Tsirkin" Message-ID: <20091005204611.GA4384@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] qemu/pci: clarify pci config load routine List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, quintela@redhat.com PCI load routine has to be called with size equal to 256 (otherwise it will crash in weird ways). So assert this, making code clearer. Also avoid dynamically sized array on stack - good for portability. Signed-off-by: Michael S. Tsirkin Cc: Juan Quintela --- hw/pci.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index ade778f..196297a 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -193,14 +193,15 @@ int pci_bus_num(PCIBus *s) static int get_pci_config_device(QEMUFile *f, void *pv, size_t size) { PCIDevice *s = container_of(pv, PCIDevice, config); - uint8_t config[size]; + uint8_t config[PCI_CONFIG_SPACE_SIZE]; int i; - qemu_get_buffer(f, config, size); - for (i = 0; i < size; ++i) + assert(size == sizeof config); + qemu_get_buffer(f, config, sizeof config); + for (i = 0; i < sizeof config; ++i) if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) return -EINVAL; - memcpy(s->config, config, size); + memcpy(s->config, config, sizeof config); pci_update_mappings(s); -- 1.6.5.rc2