Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio: Fix typecast of pointer in vring_init()

The virtio_ring.h header is used in userspace programs (ie. QEMU),
too. Here we can not assume that sizeof(pointer) is the same as
sizeof(long), e.g. when compiling for Windows, so the typecast in
vring_init() should be done with (uintptr_t) instead of (unsigned long).

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Thomas Huth and committed by
Michael S. Tsirkin
d768f32a 908a5544

+4 -1
+4 -1
include/uapi/linux/virtio_ring.h
··· 31 31 * SUCH DAMAGE. 32 32 * 33 33 * Copyright Rusty Russell IBM Corporation 2007. */ 34 + #ifndef __KERNEL__ 35 + #include <stdint.h> 36 + #endif 34 37 #include <linux/types.h> 35 38 #include <linux/virtio_types.h> 36 39 ··· 146 143 vr->num = num; 147 144 vr->desc = p; 148 145 vr->avail = p + num*sizeof(struct vring_desc); 149 - vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__virtio16) 146 + vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16) 150 147 + align-1) & ~(align - 1)); 151 148 } 152 149