[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 6/9] virtio: use unsigned int for virtqueue_get_ava
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [RFC v2 6/9] virtio: use unsigned int for virtqueue_get_avail_bytes() index |
Date: |
Tue, 29 Mar 2016 17:12:58 +0100 |
The virtio code uses int, unsigned int, and uint16_t for virtqueue
indices. The uint16_t is used for the low-level descriptor layout in
virtio_ring.h while code that isn't concerned with descriptor layout can
use unsigned int.
Use of int is problematic because it can result in signed/unsigned
comparison and incompatible int*/unsigned int* pointer types.
Make the virtqueue_get_avail_bytes() 'i' variable unsigned int. This
eliminates the need to introduce casts and modify code further in the
patches that follow.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/virtio/virtio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index a7459c2..07ce02b 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -389,7 +389,7 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int
*in_bytes,
unsigned int max, num_bufs, indirect = 0;
VRingDesc desc;
hwaddr desc_pa;
- int i;
+ unsigned int i;
max = vq->vring.num;
num_bufs = total_bufs;
--
2.5.5
- [Qemu-devel] [RFC v2 0/9] virtio: avoid exit() when device enters invalid states, Stefan Hajnoczi, 2016/03/29
- [Qemu-devel] [RFC v2 1/9] virtio: fix stray tab character, Stefan Hajnoczi, 2016/03/29
- [Qemu-devel] [RFC v2 2/9] include: update virtio_config.h Linux header, Stefan Hajnoczi, 2016/03/29
- [Qemu-devel] [RFC v2 3/9] virtio: stop virtqueue processing if device is broken, Stefan Hajnoczi, 2016/03/29
- [Qemu-devel] [RFC v2 6/9] virtio: use unsigned int for virtqueue_get_avail_bytes() index,
Stefan Hajnoczi <=
- [Qemu-devel] [RFC v2 4/9] virtio: handle virtqueue_map_desc() errors, Stefan Hajnoczi, 2016/03/29
- [Qemu-devel] [RFC v2 5/9] virtio: handle virtqueue_get_avail_bytes() errors, Stefan Hajnoczi, 2016/03/29
- [Qemu-devel] [RFC v2 9/9] virtio: handle virtqueue_get_head() errors, Stefan Hajnoczi, 2016/03/29
- [Qemu-devel] [RFC v2 7/9] virtio: handle virtqueue_read_next_desc() errors, Stefan Hajnoczi, 2016/03/29
- [Qemu-devel] [RFC v2 8/9] virtio: handle virtqueue_num_heads() errors, Stefan Hajnoczi, 2016/03/29