From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56139 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OqeOD-0008R6-FE for qemu-devel@nongnu.org; Tue, 31 Aug 2010 23:53:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OqeOB-0005Sa-Uk for qemu-devel@nongnu.org; Tue, 31 Aug 2010 23:53:33 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:36352) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OqeOB-0005SE-SM for qemu-devel@nongnu.org; Tue, 31 Aug 2010 23:53:31 -0400 Received: by vws19 with SMTP id 19so6360273vws.4 for ; Tue, 31 Aug 2010 20:53:29 -0700 (PDT) MIME-Version: 1.0 Sender: camm@ualberta.ca In-Reply-To: <1283164293-11820-1-git-send-email-Jes.Sorensen@redhat.com> References: <1283164293-11820-1-git-send-email-Jes.Sorensen@redhat.com> Date: Tue, 31 Aug 2010 21:53:29 -0600 Message-ID: From: Cam Macdonell Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH] hw/ivshmem.c don't check for negative values on unsigned data types List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes.Sorensen@redhat.com Cc: xudong.hao@intel.com, qemu-devel@nongnu.org On Mon, Aug 30, 2010 at 4:31 AM, wrote: > From: Jes Sorensen > > There is no need to check for dest < 0 or vector >=3D 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 > --- > =A0hw/ivshmem.c | =A0 =A04 ++-- > =A01 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, > > =A0 =A0 =A0 =A0 case DOORBELL: > =A0 =A0 =A0 =A0 =A0 =A0 /* check that dest VM ID is reasonable */ > - =A0 =A0 =A0 =A0 =A0 =A0if ((dest < 0) || (dest > s->max_peer)) { > + =A0 =A0 =A0 =A0 =A0 =A0if (dest > s->max_peer) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IVSHMEM_DPRINTF("Invalid destination VM I= D (%d)\n", dest); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > =A0 =A0 =A0 =A0 =A0 =A0 } > > =A0 =A0 =A0 =A0 =A0 =A0 /* check doorbell range */ > - =A0 =A0 =A0 =A0 =A0 =A0if ((vector >=3D 0) && (vector < s->peers[dest].= nb_eventfds)) { > + =A0 =A0 =A0 =A0 =A0 =A0if (vector < s->peers[dest].nb_eventfds) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IVSHMEM_DPRINTF("Writing %" PRId64 " to V= M %d on vector %d\n", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 write_one, dest, vector); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (write(s->peers[dest].eventfds[vector]= , > -- > 1.7.2.2 > > Acked-by: Cam Macdonell I sent a patch yesterday that addressed it, but it is probably better to remove the tests that switched to signed 16-bit ints. Anthony, please apply this one. Cam