aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2024-11-27 12:15:51 +0100
committerStefano Brivio <sbrivio@redhat.com>2024-11-27 16:49:21 +0100
commit00cc2303fd6ac4b72c19d1741dff72fd42c09a47 (patch)
treecb4a0a568a392925ed8b6b8b5679efeccac1cc11
parent6fae899cbbb3ec5bc9a0d5c7dde16131b2f85f05 (diff)
downloadpasst-00cc2303fd6ac4b72c19d1741dff72fd42c09a47.tar
passt-00cc2303fd6ac4b72c19d1741dff72fd42c09a47.tar.gz
passt-00cc2303fd6ac4b72c19d1741dff72fd42c09a47.tar.bz2
passt-00cc2303fd6ac4b72c19d1741dff72fd42c09a47.tar.lz
passt-00cc2303fd6ac4b72c19d1741dff72fd42c09a47.tar.xz
passt-00cc2303fd6ac4b72c19d1741dff72fd42c09a47.tar.zst
passt-00cc2303fd6ac4b72c19d1741dff72fd42c09a47.zip
Fix build on 32bit target
Fix the following errors when built with CFLAGS="-m32 -U__AVX2__": packet.c:57:23: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=] 57 | trace("packet offset plus length %lu from size %lu, " 58 | "%s:%i", start - p->buf + len + offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | size_t {aka unsigned int} packet.c:57:23: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=] 57 | trace("packet offset plus length %lu from size %lu, " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 58 | "%s:%i", start - p->buf + len + offset, 59 | p->buf_size, func, line); | ~~~~~~~~~~~ | | | size_t {aka unsigned int} vhost_user.c:139:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 139 | return (void *)(qemu_addr - r->qva + r->mmap_addr + | ^ vhost_user.c:439:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 439 | munmap((void *)r->mmap_addr, r->size + r->mmap_offset); | ^ vhost_user.c:900:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 900 | munmap((void *)r->mmap_addr, r->size + r->mmap_offset); | ^ virtio.c:111:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 111 | return (void *)(guest_addr - r->gpa + r->mmap_addr + | ^ vu_common.c:37:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 37 | char *m = (char *)dev_region->mmap_addr; | ^ Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--packet.c2
-rw-r--r--vhost_user.c11
-rw-r--r--virtio.c5
-rw-r--r--vu_common.c2
4 files changed, 12 insertions, 8 deletions
diff --git a/packet.c b/packet.c
index e5a78d0..03a11e6 100644
--- a/packet.c
+++ b/packet.c
@@ -54,7 +54,7 @@ static int packet_check_range(const struct pool *p, size_t offset, size_t len,
}
if (start + len + offset > p->buf + p->buf_size) {
- trace("packet offset plus length %lu from size %lu, "
+ trace("packet offset plus length %zu from size %zu, "
"%s:%i", start - p->buf + len + offset,
p->buf_size, func, line);
return -1;
diff --git a/vhost_user.c b/vhost_user.c
index 51c90db..4b8558f 100644
--- a/vhost_user.c
+++ b/vhost_user.c
@@ -136,8 +136,9 @@ static void *qva_to_va(struct vu_dev *dev, uint64_t qemu_addr)
if ((qemu_addr >= r->qva) && (qemu_addr < (r->qva + r->size))) {
/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
- return (void *)(qemu_addr - r->qva + r->mmap_addr +
- r->mmap_offset);
+ return (void *)(uintptr_t)(qemu_addr - r->qva +
+ r->mmap_addr +
+ r->mmap_offset);
}
}
@@ -436,7 +437,8 @@ static bool vu_set_mem_table_exec(struct vu_dev *vdev,
if (r->mmap_addr) {
/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
- munmap((void *)r->mmap_addr, r->size + r->mmap_offset);
+ munmap((void *)(uintptr_t)r->mmap_addr,
+ r->size + r->mmap_offset);
}
}
vdev->nregions = memory->nregions;
@@ -897,7 +899,8 @@ void vu_cleanup(struct vu_dev *vdev)
if (r->mmap_addr) {
/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
- munmap((void *)r->mmap_addr, r->size + r->mmap_offset);
+ munmap((void *)(uintptr_t)r->mmap_addr,
+ r->size + r->mmap_offset);
}
}
vdev->nregions = 0;
diff --git a/virtio.c b/virtio.c
index 0598ff4..a76de5e 100644
--- a/virtio.c
+++ b/virtio.c
@@ -108,8 +108,9 @@ static void *vu_gpa_to_va(struct vu_dev *dev, uint64_t *plen, uint64_t guest_add
if ((guest_addr + *plen) > (r->gpa + r->size))
*plen = r->gpa + r->size - guest_addr;
/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
- return (void *)(guest_addr - r->gpa + r->mmap_addr +
- r->mmap_offset);
+ return (void *)(uintptr_t)(guest_addr - r->gpa +
+ r->mmap_addr +
+ r->mmap_offset);
}
}
diff --git a/vu_common.c b/vu_common.c
index f2eb701..299b5a3 100644
--- a/vu_common.c
+++ b/vu_common.c
@@ -35,7 +35,7 @@ int vu_packet_check_range(void *buf, size_t offset, size_t len,
for (dev_region = buf; dev_region->mmap_addr; dev_region++) {
/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
- char *m = (char *)dev_region->mmap_addr;
+ char *m = (char *)(uintptr_t)dev_region->mmap_addr;
if (m <= start &&
start + offset + len <= m + dev_region->mmap_offset +