]> Git Repo - qemu.git/commitdiff
qemu/pci: clarify pci config load routine
authorMichael S. Tsirkin <[email protected]>
Mon, 5 Oct 2009 20:46:11 +0000 (22:46 +0200)
committerAnthony Liguori <[email protected]>
Tue, 6 Oct 2009 19:36:13 +0000 (14:36 -0500)
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 <[email protected]>
Cc: Juan Quintela <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
hw/pci.c

index bd65db223926c80dac19790e4e04f86ee61e2209..d63285a96ac50fc108c08e5eb7114c858bdbbe7e 100644 (file)
--- 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);
 
This page took 0.030111 seconds and 4 git commands to generate.