Patchwork [18/41] virtio: change config_len type to int32_t

login
register
mail settings
Submitter Juan Quintela
Date Dec. 2, 2009, 12:04 p.m.
Message ID <e4dd7cf757cdb8b5438449fb088fedb9e383c6ed.1259754427.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/40023/
State New
Headers show

Comments

Juan Quintela - Dec. 2, 2009, 12:04 p.m.
size_t changes between 32 and 64 bits, making it bad for a field
that needs to be on the 'wire'.  This value will never be near int32_t
limit.

Stored values are very small ints, it is backwards compatible

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/virtio.c |    4 ++--
 hw/virtio.h |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Patch

diff --git a/hw/virtio.c b/hw/virtio.c
index bb93e8c..fd617ff 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -640,7 +640,7 @@  void virtio_save(VirtIODevice *vdev, QEMUFile *f)
     qemu_put_8s(f, &vdev->isr);
     qemu_put_be16s(f, &vdev->queue_sel);
     qemu_put_be32s(f, &vdev->features);
-    qemu_put_be32(f, vdev->config_len);
+    qemu_put_sbe32s(f, &vdev->config_len);
     qemu_put_buffer(f, vdev->config, vdev->config_len);

     qemu_put_sbe32s(f, &vdev->num_pci_queues);
@@ -697,7 +697,7 @@  int virtio_load(VirtIODevice *vdev, QEMUFile *f)
     qemu_get_8s(f, &vdev->isr);
     qemu_get_be16s(f, &vdev->queue_sel);
     qemu_get_be32s(f, &vdev->features);
-    vdev->config_len = qemu_get_be32(f);
+    qemu_get_sbe32s(f, &vdev->config_len);
     qemu_get_buffer(f, vdev->config, vdev->config_len);

     qemu_get_sbe32s(f, &vdev->num_pci_queues);
diff --git a/hw/virtio.h b/hw/virtio.h
index d849f44..f56f672 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -96,7 +96,7 @@  struct VirtIODevice
     uint8_t isr;
     uint16_t queue_sel;
     uint32_t features;
-    size_t config_len;
+    int32_t config_len;
     void *config;
     uint16_t config_vector;
     int nvectors;