From patchwork Tue Apr 12 13:25:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 8810551 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 082CBC0553 for ; Tue, 12 Apr 2016 13:33:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71AF22021F for ; Tue, 12 Apr 2016 13:33:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8D4B200FF for ; Tue, 12 Apr 2016 13:33:20 +0000 (UTC) Received: from localhost ([::1]:49607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apyRU-0001xZ-4Z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Apr 2016 09:33:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apyKN-0002ul-CN for qemu-devel@nongnu.org; Tue, 12 Apr 2016 09:26:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1apyKJ-0005Vg-Iq for qemu-devel@nongnu.org; Tue, 12 Apr 2016 09:25:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apyKJ-0005Va-DL for qemu-devel@nongnu.org; Tue, 12 Apr 2016 09:25:55 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11E4F118E0D; Tue, 12 Apr 2016 13:25:55 +0000 (UTC) Received: from localhost (ovpn-112-60.ams2.redhat.com [10.36.112.60]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3CDPq3P016060; Tue, 12 Apr 2016 09:25:54 -0400 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Tue, 12 Apr 2016 14:25:31 +0100 Message-Id: <1460467534-29147-8-git-send-email-stefanha@redhat.com> In-Reply-To: <1460467534-29147-1-git-send-email-stefanha@redhat.com> References: <1460467534-29147-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 12 Apr 2016 13:25:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 07/10] virtio: use unsigned int for virtqueue_get_avail_bytes() index X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , Fam Zheng , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 48f759e..493d6a7 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -392,7 +392,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;