qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] hw/ivshmem.c don't check for negative values on


From: Cam Macdonell
Subject: [Qemu-devel] Re: [PATCH] hw/ivshmem.c don't check for negative values on unsigned data types
Date: Tue, 31 Aug 2010 21:56:24 -0600

On Tue, Aug 31, 2010 at 6:51 PM, Hao, Xudong <address@hidden> wrote:
> Hao, Xudong wrote:
>> address@hidden wrote:
>>> From: Jes Sorensen <address@hidden>
>>>
>>> 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 <address@hidden>
>>>
>>> Signed-off-by: Jes Sorensen <address@hidden> ---
>>>  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],
>>
>> 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:
>
> ...
>  CC    x86_64-softmmu/ivshmem.o
>  CC    x86_64-softmmu/fpu/softfloat-native.o
>  CC    x86_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.  Is this
with gcc 4.1.2?  Please the try the following patch from Avi that
should add the necessary cast.

http://www.mail-archive.com/address@hidden/msg40715.html

Cam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]