diff mbox series

[v2,1/6] libvduse: Fix some compile errors with clang

Message ID 20220614051532.92-2-xieyongji@bytedance.com (mailing list archive)
State New, archived
Headers show
Series Some fixes and improvements for vduse-blk | expand

Commit Message

Yongji Xie June 14, 2022, 5:15 a.m. UTC
This fixes some compile errors with clang:

../subprojects/libvduse/libvduse.c:578:20: error: unused function
'vring_used_flags_set_bit' [-Werror,-Wunused-function]
static inline void vring_used_flags_set_bit(VduseVirtq *vq, int mask)
                   ^
../subprojects/libvduse/libvduse.c:587:20: error: unused function
'vring_used_flags_unset_bit' [-Werror,-Wunused-function]
static inline void vring_used_flags_unset_bit(VduseVirtq *vq, int mask)

../subprojects/libvduse/libvduse.c:325:20: error: cast to pointer from
integer of different size [-Werror=int-to-pointer-cast]
   325 |             munmap((void *)dev->regions[i].mmap_addr,
       |                    ^
../subprojects/libvduse/libvduse.c: In function 'vduse_dev_create':
../subprojects/libvduse/libvduse.c:1318:54: error: format '%lu' expects
argument of type 'long unsigned int', but argument 3 has type 'uint64_t'
{aka 'long long unsigned int'} [-Werror=format=]
 1318 |         fprintf(stderr, "Failed to set api version %lu: %s\n",
      |                                                    ~~^
      |                                                      |
      |                                                      long unsigned int
      |                                                    %llu
 1319 |                 version, strerror(errno));
      |                 ~~~~~~~
      |                 |
      |                 uint64_t {aka long long unsigned int}

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
 subprojects/libvduse/libvduse.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/subprojects/libvduse/libvduse.c b/subprojects/libvduse/libvduse.c
index 78bb777402..dd1faffe66 100644
--- a/subprojects/libvduse/libvduse.c
+++ b/subprojects/libvduse/libvduse.c
@@ -27,6 +27,7 @@ 
 #include <unistd.h>
 #include <limits.h>
 #include <fcntl.h>
+#include <inttypes.h>
 
 #include <sys/ioctl.h>
 #include <sys/eventfd.h>
@@ -322,7 +323,7 @@  static void vduse_iova_remove_region(VduseDev *dev, uint64_t start,
 
         if (start <= dev->regions[i].iova &&
             last >= (dev->regions[i].iova + dev->regions[i].size - 1)) {
-            munmap((void *)dev->regions[i].mmap_addr,
+            munmap((void *)(uintptr_t)dev->regions[i].mmap_addr,
                    dev->regions[i].mmap_offset + dev->regions[i].size);
             dev->regions[i].mmap_addr = 0;
             dev->num_regions--;
@@ -575,24 +576,6 @@  void vduse_queue_notify(VduseVirtq *vq)
     }
 }
 
-static inline void vring_used_flags_set_bit(VduseVirtq *vq, int mask)
-{
-    uint16_t *flags;
-
-    flags = (uint16_t *)((char*)vq->vring.used +
-                         offsetof(struct vring_used, flags));
-    *flags = htole16(le16toh(*flags) | mask);
-}
-
-static inline void vring_used_flags_unset_bit(VduseVirtq *vq, int mask)
-{
-    uint16_t *flags;
-
-    flags = (uint16_t *)((char*)vq->vring.used +
-                         offsetof(struct vring_used, flags));
-    *flags = htole16(le16toh(*flags) & ~mask);
-}
-
 static inline void vring_set_avail_event(VduseVirtq *vq, uint16_t val)
 {
     *((uint16_t *)&vq->vring.used->ring[vq->vring.num]) = htole16(val);
@@ -1315,7 +1298,7 @@  VduseDev *vduse_dev_create(const char *name, uint32_t device_id,
 
     version = VDUSE_API_VERSION;
     if (ioctl(ctrl_fd, VDUSE_SET_API_VERSION, &version)) {
-        fprintf(stderr, "Failed to set api version %lu: %s\n",
+        fprintf(stderr, "Failed to set api version %" PRIu64 ": %s\n",
                 version, strerror(errno));
         goto err_dev;
     }