diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2009-10-05 22:46:11 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-06 14:36:13 -0500 |
commit | 05fcfada5e45b900c32ca6bccf0ce52cb5422509 (patch) | |
tree | c72bc7bbac6624fc5da53897fc8bc18b5e600853 | |
parent | dc1c9fe8b759d4e70222d8f94838a6f6ef5c4ef1 (diff) | |
download | qemu-05fcfada5e45b900c32ca6bccf0ce52cb5422509.zip qemu-05fcfada5e45b900c32ca6bccf0ce52cb5422509.tar.gz qemu-05fcfada5e45b900c32ca6bccf0ce52cb5422509.tar.bz2 |
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 <mst@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | hw/pci.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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); |