From patchwork Mon Aug 30 10:31:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 63022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7253AB70FE for ; Mon, 30 Aug 2010 21:11:51 +1000 (EST) Received: from localhost ([127.0.0.1]:36301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oq2H8-0004pu-M6 for incoming@patchwork.ozlabs.org; Mon, 30 Aug 2010 07:11:42 -0400 Received: from [140.186.70.92] (port=58798 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oq2DM-00034q-Nj for qemu-devel@nongnu.org; Mon, 30 Aug 2010 07:07:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oq1eO-00066Q-FJ for qemu-devel@nongnu.org; Mon, 30 Aug 2010 06:31:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23016) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oq1eO-00066K-7F for qemu-devel@nongnu.org; Mon, 30 Aug 2010 06:31:40 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7UAVaCu024430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 30 Aug 2010 06:31:37 -0400 Received: from localhost6.localdomain6 ([10.3.121.6]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7UAVYXC010689; Mon, 30 Aug 2010 06:31:35 -0400 From: Jes.Sorensen@redhat.com To: qemu-devel@nongnu.org Date: Mon, 30 Aug 2010 12:31:33 +0200 Message-Id: <1283164293-11820-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: cam@cs.ualberta.ca, xudong.hao@intel.com Subject: [Qemu-devel] [PATCH] hw/ivshmem.c don't check for negative values on unsigned data types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen There is no need to check for dest < 0 or vector >= 0 as both are uint16_t. This should fix problems with broken build with aggressive compiler flags. Reported by Xudong Hao Signed-off-by: Jes Sorensen Acked-by: Cam Macdonell --- hw/ivshmem.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ivshmem.c b/hw/ivshmem.c index bbb5cba..afebbc3 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -199,13 +199,13 @@ static void ivshmem_io_writel(void *opaque, target_phys_addr_t addr, case DOORBELL: /* check that dest VM ID is reasonable */ - if ((dest < 0) || (dest > s->max_peer)) { + if (dest > s->max_peer) { IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest); break; } /* check doorbell range */ - if ((vector >= 0) && (vector < s->peers[dest].nb_eventfds)) { + if (vector < s->peers[dest].nb_eventfds) { IVSHMEM_DPRINTF("Writing %" PRId64 " to VM %d on vector %d\n", write_one, dest, vector); if (write(s->peers[dest].eventfds[vector],