From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54749 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OqeUr-0002B7-IS for qemu-devel@nongnu.org; Wed, 01 Sep 2010 00:00:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OqeUm-0006OI-Ak for qemu-devel@nongnu.org; Wed, 01 Sep 2010 00:00:25 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:40947) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OqeUm-0006OD-5b for qemu-devel@nongnu.org; Wed, 01 Sep 2010 00:00:20 -0400 Received: by vws19 with SMTP id 19so6363776vws.4 for ; Tue, 31 Aug 2010 21:00:19 -0700 (PDT) MIME-Version: 1.0 Sender: camm@ualberta.ca In-Reply-To: References: <1283164293-11820-1-git-send-email-Jes.Sorensen@redhat.com> Date: Tue, 31 Aug 2010 22:00:19 -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: "Hao, Xudong" Cc: "Jes.Sorensen@redhat.com" , "qemu-devel@nongnu.org" On Tue, Aug 31, 2010 at 9:56 PM, Cam Macdonell wrote: > On Tue, Aug 31, 2010 at 6:51 PM, Hao, Xudong wrote= : >> Hao, Xudong wrote: >>> Jes.Sorensen@redhat.com 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 =A0case DOORBELL: >>>> =A0 =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 =A0IVSHMEM_DPRINTF("Invalid destinatio= n VM ID (%d)\n", >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dest); break; >>>> =A0 =A0 =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 < >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0s->peers[dest].nb_eventfds) { >>>> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IVSHMEM_DPRINTF("Writing %" PRId64 = " to VM %d on >>>> vector %d\n", write_one, dest, vector); if >>>> (write(s->peers[dest].eventfds[vector], >>> >>> This patch works for me. >>> >> >> Jes, correct result is this patch works for me on x86_64 system. However= , in i386 system, there is another bug: >> >> ... >> =A0CC =A0 =A0x86_64-softmmu/ivshmem.o >> =A0CC =A0 =A0x86_64-softmmu/fpu/softfloat-native.o >> =A0CC =A0 =A0x86_64-softmmu/op_helper.o >> cc1: warnings being treated as errors >> /home/build/gitrepo/qemu/hw/ivshmem.c: In function 'check_shm_size. >> /home/build/gitrepo/qemu/hw/ivshmem.c:357: warning: format '%ld' expects= type 'long int', but argt 5 has type '__off64_t >> make[1]: *** [ivshmem.o] Error 1 >> make[1]: *** Waiting for unfinished jobs.... >> make: *** [subdir-x86_64-softmmu] Error 2 > > Hmm, that was causing problems on 32-bit systems, not 64-bit. =A0Is this > with gcc 4.1.2? Oh sorry, I read too fast, you did say it was on 32-bit. Avi's patch will do the trick. Cam