From: Michael S. Tsirkin Date: Mon, 5 Oct 2009 20:46:11 +0000 (+0200) Subject: qemu/pci: clarify pci config load routine X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=05fcfada5e45b900c32ca6bccf0ce52cb5422509;p=qmiga%2Fqemu.git qemu/pci: clarify pci config load routine 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 Signed-off-by: Anthony Liguori --- diff --git a/hw/pci.c b/hw/pci.c index bd65db2239..d63285a96a 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);