* [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long
@ 2014-09-24 5:20 Stefan Weil
2014-09-24 7:24 ` Markus Armbruster
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Stefan Weil @ 2014-09-24 5:20 UTC (permalink / raw)
To: Peter Maydell; +Cc: Paolo Bonzini, Fam Zheng, qemu-devel, Stefan Weil
Compiler warning (w32, w64):
include/hw/virtio/virtio_ring.h:142:26: warning:
cast from pointer to integer of different size [-Wpointer-to-int-cast]
When sizeof(long) < sizeof(void *), this is not only a warning but a
real program error.
Add also missing blanks in the same statement.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
Peter, could you please apply this bug fix directly without pull request?
Thanks
Stefan
include/hw/virtio/virtio_ring.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/hw/virtio/virtio_ring.h b/include/hw/virtio/virtio_ring.h
index 8f58bc9..0b42e6e 100644
--- a/include/hw/virtio/virtio_ring.h
+++ b/include/hw/virtio/virtio_ring.h
@@ -139,8 +139,8 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
vr->num = num;
vr->desc = p;
vr->avail = p + num*sizeof(struct vring_desc);
- vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(uint16_t)
- + align-1) & ~(align - 1));
+ vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(uint16_t)
+ + align - 1) & ~(align - 1));
}
static inline unsigned vring_size(unsigned int num, unsigned long align)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long
2014-09-24 5:20 [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long Stefan Weil
@ 2014-09-24 7:24 ` Markus Armbruster
2014-09-24 8:46 ` Fam Zheng
2014-09-24 9:53 ` Stefan Hajnoczi
2 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2014-09-24 7:24 UTC (permalink / raw)
To: Stefan Weil; +Cc: Peter Maydell, Fam Zheng, qemu-devel, Paolo Bonzini
Stefan Weil <sw@weilnetz.de> writes:
> Compiler warning (w32, w64):
>
> include/hw/virtio/virtio_ring.h:142:26: warning:
> cast from pointer to integer of different size [-Wpointer-to-int-cast]
>
> When sizeof(long) < sizeof(void *), this is not only a warning but a
> real program error.
>
> Add also missing blanks in the same statement.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long
2014-09-24 5:20 [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long Stefan Weil
2014-09-24 7:24 ` Markus Armbruster
@ 2014-09-24 8:46 ` Fam Zheng
2014-09-24 12:44 ` Peter Maydell
2014-09-24 9:53 ` Stefan Hajnoczi
2 siblings, 1 reply; 6+ messages in thread
From: Fam Zheng @ 2014-09-24 8:46 UTC (permalink / raw)
To: Stefan Weil; +Cc: Peter Maydell, qemu-devel, Paolo Bonzini
On Wed, 09/24 07:20, Stefan Weil wrote:
> Compiler warning (w32, w64):
>
> include/hw/virtio/virtio_ring.h:142:26: warning:
> cast from pointer to integer of different size [-Wpointer-to-int-cast]
>
> When sizeof(long) < sizeof(void *), this is not only a warning but a
> real program error.
>
> Add also missing blanks in the same statement.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> Peter, could you please apply this bug fix directly without pull request?
>
> Thanks
> Stefan
>
> include/hw/virtio/virtio_ring.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/hw/virtio/virtio_ring.h b/include/hw/virtio/virtio_ring.h
> index 8f58bc9..0b42e6e 100644
> --- a/include/hw/virtio/virtio_ring.h
> +++ b/include/hw/virtio/virtio_ring.h
> @@ -139,8 +139,8 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
> vr->num = num;
> vr->desc = p;
> vr->avail = p + num*sizeof(struct vring_desc);
> - vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(uint16_t)
> - + align-1) & ~(align - 1));
> + vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(uint16_t)
> + + align - 1) & ~(align - 1));
> }
>
> static inline unsigned vring_size(unsigned int num, unsigned long align)
> --
> 1.7.10.4
>
That was from copy&paste /usr/include/linux/virtio_ring.h. The patch looks good
to me, should linux also need this fix?
Reviewed-by: Fam Zheng <famz@redhat.com>
Fam
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long
2014-09-24 5:20 [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long Stefan Weil
2014-09-24 7:24 ` Markus Armbruster
2014-09-24 8:46 ` Fam Zheng
@ 2014-09-24 9:53 ` Stefan Hajnoczi
2 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2014-09-24 9:53 UTC (permalink / raw)
To: Stefan Weil; +Cc: Peter Maydell, Fam Zheng, qemu-devel, Paolo Bonzini
[-- Attachment #1: Type: text/plain, Size: 699 bytes --]
On Wed, Sep 24, 2014 at 07:20:02AM +0200, Stefan Weil wrote:
> Compiler warning (w32, w64):
>
> include/hw/virtio/virtio_ring.h:142:26: warning:
> cast from pointer to integer of different size [-Wpointer-to-int-cast]
>
> When sizeof(long) < sizeof(void *), this is not only a warning but a
> real program error.
>
> Add also missing blanks in the same statement.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> Peter, could you please apply this bug fix directly without pull request?
>
> Thanks
> Stefan
>
> include/hw/virtio/virtio_ring.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long
2014-09-24 8:46 ` Fam Zheng
@ 2014-09-24 12:44 ` Peter Maydell
2014-09-25 1:12 ` Fam Zheng
0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2014-09-24 12:44 UTC (permalink / raw)
To: Fam Zheng; +Cc: Stefan Weil, QEMU Developers, Paolo Bonzini
On 24 September 2014 01:46, Fam Zheng <famz@redhat.com> wrote:
> On Wed, 09/24 07:20, Stefan Weil wrote:
>> Compiler warning (w32, w64):
>>
>> include/hw/virtio/virtio_ring.h:142:26: warning:
>> cast from pointer to integer of different size [-Wpointer-to-int-cast]
>>
>> When sizeof(long) < sizeof(void *), this is not only a warning but a
>> real program error.
>>
>> Add also missing blanks in the same statement.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>
>> Peter, could you please apply this bug fix directly without pull request?
Applied to master, thanks.
>> diff --git a/include/hw/virtio/virtio_ring.h b/include/hw/virtio/virtio_ring.h
>> index 8f58bc9..0b42e6e 100644
>> --- a/include/hw/virtio/virtio_ring.h
>> +++ b/include/hw/virtio/virtio_ring.h
>> @@ -139,8 +139,8 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
>> vr->num = num;
>> vr->desc = p;
>> vr->avail = p + num*sizeof(struct vring_desc);
>> - vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(uint16_t)
>> - + align-1) & ~(align - 1));
>> + vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(uint16_t)
>> + + align - 1) & ~(align - 1));
>> }
>>
>> static inline unsigned vring_size(unsigned int num, unsigned long align)
>> --
>> 1.7.10.4
>>
>
> That was from copy&paste /usr/include/linux/virtio_ring.h. The patch looks good
> to me, should linux also need this fix?
In Linux the "long" type is always the same as the size of a pointer;
it's only Windows that went for the LLP64 model rather than LP64.
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long
2014-09-24 12:44 ` Peter Maydell
@ 2014-09-25 1:12 ` Fam Zheng
0 siblings, 0 replies; 6+ messages in thread
From: Fam Zheng @ 2014-09-25 1:12 UTC (permalink / raw)
To: Peter Maydell; +Cc: Stefan Weil, QEMU Developers, Paolo Bonzini
On Wed, 09/24 05:44, Peter Maydell wrote:
> On 24 September 2014 01:46, Fam Zheng <famz@redhat.com> wrote:
> > On Wed, 09/24 07:20, Stefan Weil wrote:
> >> Compiler warning (w32, w64):
> >>
> >> include/hw/virtio/virtio_ring.h:142:26: warning:
> >> cast from pointer to integer of different size [-Wpointer-to-int-cast]
> >>
> >> When sizeof(long) < sizeof(void *), this is not only a warning but a
> >> real program error.
> >>
> >> Add also missing blanks in the same statement.
> >>
> >> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> >> ---
> >>
> >> Peter, could you please apply this bug fix directly without pull request?
>
> Applied to master, thanks.
>
> >> diff --git a/include/hw/virtio/virtio_ring.h b/include/hw/virtio/virtio_ring.h
> >> index 8f58bc9..0b42e6e 100644
> >> --- a/include/hw/virtio/virtio_ring.h
> >> +++ b/include/hw/virtio/virtio_ring.h
> >> @@ -139,8 +139,8 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
> >> vr->num = num;
> >> vr->desc = p;
> >> vr->avail = p + num*sizeof(struct vring_desc);
> >> - vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(uint16_t)
> >> - + align-1) & ~(align - 1));
> >> + vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(uint16_t)
> >> + + align - 1) & ~(align - 1));
> >> }
> >>
> >> static inline unsigned vring_size(unsigned int num, unsigned long align)
> >> --
> >> 1.7.10.4
> >>
> >
> > That was from copy&paste /usr/include/linux/virtio_ring.h. The patch looks good
> > to me, should linux also need this fix?
>
> In Linux the "long" type is always the same as the size of a pointer;
> it's only Windows that went for the LLP64 model rather than LP64.
>
Okay, Thanks for explaining!
Fam
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-09-25 1:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-24 5:20 [Qemu-devel] [PATCH] virtio: Fix wrong type cast from pointer to long Stefan Weil
2014-09-24 7:24 ` Markus Armbruster
2014-09-24 8:46 ` Fam Zheng
2014-09-24 12:44 ` Peter Maydell
2014-09-25 1:12 ` Fam Zheng
2014-09-24 9:53 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).