summaryrefslogtreecommitdiff
path: root/include/uapi/linux/virtio_ring.h
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2015-07-02 10:21:22 +0300
committerMichael S. Tsirkin <mst@redhat.com>2015-07-07 14:27:04 +0300
commitd768f32aec8c0ebb8499ffca89cfed8f5f1a4432 (patch)
tree3518c844a175fa03ec7cc9d6c0d1012d2dd3eadb /include/uapi/linux/virtio_ring.h
parent908a5544cd29ed60114ed60bded6dbe8cdd56326 (diff)
downloadlinux-d768f32aec8c0ebb8499ffca89cfed8f5f1a4432.tar.xz
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>
Diffstat (limited to 'include/uapi/linux/virtio_ring.h')
-rw-r--r--include/uapi/linux/virtio_ring.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h
index 915980ac68df..c07295969b7e 100644
--- a/include/uapi/linux/virtio_ring.h
+++ b/include/uapi/linux/virtio_ring.h
@@ -31,6 +31,9 @@
* SUCH DAMAGE.
*
* Copyright Rusty Russell IBM Corporation 2007. */
+#ifndef __KERNEL__
+#include <stdint.h>
+#endif
#include <linux/types.h>
#include <linux/virtio_types.h>
@@ -143,7 +146,7 @@ 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(__virtio16)
+ vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
+ align-1) & ~(align - 1));
}