summaryrefslogtreecommitdiffstats
path: root/subprojects/libvhost-user/libvhost-user.c
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/libvhost-user/libvhost-user.c')
-rw-r--r--subprojects/libvhost-user/libvhost-user.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index ffed4729a3..d6ee6e7d91 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -45,6 +45,17 @@
#include "libvhost-user.h"
/* usually provided by GLib */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#if !defined(__clang__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4)
+#define G_GNUC_PRINTF(format_idx, arg_idx) \
+ __attribute__((__format__(gnu_printf, format_idx, arg_idx)))
+#else
+#define G_GNUC_PRINTF(format_idx, arg_idx) \
+ __attribute__((__format__(__printf__, format_idx, arg_idx)))
+#endif
+#else /* !__GNUC__ */
+#define G_GNUC_PRINTF(format_idx, arg_idx)
+#endif /* !__GNUC__ */
#ifndef MIN
#define MIN(x, y) ({ \
typeof(x) _min1 = (x); \
@@ -151,7 +162,7 @@ vu_request_to_string(unsigned int req)
}
}
-static void
+static void G_GNUC_PRINTF(2, 3)
vu_panic(VuDev *dev, const char *msg, ...)
{
char *buf = NULL;
@@ -651,7 +662,8 @@ generate_faults(VuDev *dev) {
if (ioctl(dev->postcopy_ufd, UFFDIO_REGISTER, &reg_struct)) {
vu_panic(dev, "%s: Failed to userfault region %d "
- "@%p + size:%zx offset: %zx: (ufd=%d)%s\n",
+ "@%" PRIx64 " + size:%" PRIx64 " offset: %" PRIx64
+ ": (ufd=%d)%s\n",
__func__, i,
dev_region->mmap_addr,
dev_region->size, dev_region->mmap_offset,
@@ -700,7 +712,7 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
if (vmsg->size < VHOST_USER_MEM_REG_SIZE) {
close(vmsg->fds[0]);
vu_panic(dev, "VHOST_USER_ADD_MEM_REG requires a message size of at "
- "least %d bytes and only %d bytes were received",
+ "least %zu bytes and only %d bytes were received",
VHOST_USER_MEM_REG_SIZE, vmsg->size);
return false;
}
@@ -826,7 +838,7 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
if (vmsg->size < VHOST_USER_MEM_REG_SIZE) {
vmsg_close_fds(vmsg);
vu_panic(dev, "VHOST_USER_REM_MEM_REG requires a message size of at "
- "least %d bytes and only %d bytes were received",
+ "least %zu bytes and only %d bytes were received",
VHOST_USER_MEM_REG_SIZE, vmsg->size);
return false;
}