From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnYaV-0000wQ-5l for qemu-devel@nongnu.org; Fri, 23 Sep 2016 18:04:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnYaT-0003nf-IY for qemu-devel@nongnu.org; Fri, 23 Sep 2016 18:04:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnYaT-0003nY-CS for qemu-devel@nongnu.org; Fri, 23 Sep 2016 18:04:53 -0400 Date: Sat, 24 Sep 2016 01:04:51 +0300 From: "Michael S. Tsirkin" Message-ID: <1474668213-15643-13-git-send-email-mst@redhat.com> References: <1474668213-15643-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1474668213-15643-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL v2 12/19] virtio: use unsigned int for virtqueue_get_avail_bytes() index List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Cornelia Huck From: Stefan Hajnoczi 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 Reviewed-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Cornelia Huck --- 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 10c2f3d..973d0c2 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -416,7 +416,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; -- MST