aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-04-07 09:45:55 +0100
committerGitHub <noreply@github.com>2021-04-07 09:45:55 +0100
commited6deba2b8a496e5c3047d3d46208109ac762e4b (patch)
tree3f4d5df13b26f98f0dacd7283b9af32de2885a78
parent5db87e77d11bf60cdec904775f12bbfbf98765d3 (diff)
downloadlibvfio-user-ed6deba2b8a496e5c3047d3d46208109ac762e4b.zip
libvfio-user-ed6deba2b8a496e5c3047d3d46208109ac762e4b.tar.gz
libvfio-user-ed6deba2b8a496e5c3047d3d46208109ac762e4b.tar.bz2
mark vfu_log() with format attribute (#426)
Fix up all resulting fallout. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
-rw-r--r--include/libvfio-user.h3
-rw-r--r--lib/dma.c10
-rw-r--r--lib/dma.h7
-rw-r--r--lib/irq.c2
-rw-r--r--lib/libvfio-user.c14
-rw-r--r--lib/pci.c4
-rw-r--r--lib/tran_sock.c6
7 files changed, 24 insertions, 22 deletions
diff --git a/include/libvfio-user.h b/include/libvfio-user.h
index 97618a8..90dd21a 100644
--- a/include/libvfio-user.h
+++ b/include/libvfio-user.h
@@ -184,7 +184,8 @@ typedef void (vfu_log_fn_t)(vfu_ctx_t *vfu_ctx, int level, const char *msg);
* Log to the logging function configured for this context.
*/
void
-vfu_log(vfu_ctx_t *vfu_ctx, int level, const char *fmt, ...);
+vfu_log(vfu_ctx_t *vfu_ctx, int level, const char *fmt, ...) \
+ __attribute__((format(printf, 3, 4)));
/**
* Set up logging information.
diff --git a/lib/dma.c b/lib/dma.c
index 3e6e0a0..4390b5a 100644
--- a/lib/dma.c
+++ b/lib/dma.c
@@ -157,7 +157,7 @@ MOCK_DEFINE(dma_controller_remove_region)(dma_controller_t *dma,
err = dma_unregister(data, &region->info);
if (err != 0) {
vfu_log(dma->vfu_ctx, LOG_ERR,
- "failed to dma_unregister() DMA region [%#lx, %#lx): %s\n",
+ "failed to dma_unregister() DMA region [%p, %p): %s\n",
region->info.iova.iov_base, iov_end(&region->info.iova),
strerror(err));
return err;
@@ -188,7 +188,7 @@ dma_controller_remove_regions(dma_controller_t *dma)
dma_memory_region_t *region = &dma->regions[i];
vfu_log(dma->vfu_ctx, LOG_DEBUG, "removing DMA region "
- "iova=[%#lx, %#lx) vaddr=%#lx mapping=[%#lx, %#lx)",
+ "iova=[%p, %p) vaddr=%p mapping=[%p, %p)",
region->info.iova.iov_base, iov_end(&region->info.iova),
region->info.vaddr,
region->info.mapping.iov_base, iov_end(&region->info.mapping));
@@ -239,8 +239,8 @@ dma_map_region(dma_controller_t *dma, dma_memory_region_t *region)
region->info.mapping.iov_len = mmap_len;
region->info.vaddr = mmap_base + (region->offset - offset);
- vfu_log(dma->vfu_ctx, LOG_DEBUG, "mapped DMA region iova=[%#lx, %#lx) "
- "vaddr=%#lx page_size=%#lx mapping=[%#lx, %#lx)",
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "mapped DMA region iova=[%p, %p) "
+ "vaddr=%p page_size=%#lx mapping=[%p, %p)",
region->info.iova.iov_base, iov_end(&region->info.iova),
region->info.vaddr, region->info.page_size,
region->info.mapping.iov_base, iov_end(&region->info.mapping));
@@ -301,7 +301,7 @@ MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
(region->info.iova.iov_base >= dma_addr &&
region->info.iova.iov_base < dma_addr + size)) {
vfu_log(dma->vfu_ctx, LOG_INFO, "new DMA region %s overlaps with "
- "DMA region [%#lx, %#lx)", rstr, region->info.iova.iov_base,
+ "DMA region [%p, %p)", rstr, region->info.iova.iov_base,
iov_end(&region->info.iova));
goto err;
}
diff --git a/lib/dma.h b/lib/dma.h
index cd37bf3..7ff5f13 100644
--- a/lib/dma.h
+++ b/lib/dma.h
@@ -270,7 +270,7 @@ dma_map_sg(dma_controller_t *dma, const dma_sg_t *sg, struct iovec *iov,
return -EFAULT;
}
- vfu_log(dma->vfu_ctx, LOG_DEBUG, "map %#lx-%#lx\n",
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "map %p-%p\n",
sg->dma_addr + sg->offset,
sg->dma_addr + sg->offset + sg->length);
iov[i].iov_base = region->info.vaddr + sg[i].offset;
@@ -301,8 +301,9 @@ dma_unmap_sg(dma_controller_t *dma, const dma_sg_t *sg,
/* bad region */
continue;
}
- vfu_log(dma->vfu_ctx, LOG_DEBUG, "unmap %#lx-%#lx\n",
- sg[i].dma_addr + sg[i].offset, sg[i].dma_addr + sg[i].offset + sg[i].length);
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "unmap %p-%p\n",
+ sg[i].dma_addr + sg[i].offset,
+ sg[i].dma_addr + sg[i].offset + sg[i].length);
r->refcnt--;
}
return;
diff --git a/lib/irq.c b/lib/irq.c
index 8dc1381..9e0a428 100644
--- a/lib/irq.c
+++ b/lib/irq.c
@@ -311,7 +311,7 @@ device_set_irqs_validate(vfu_ctx_t *vfu_ctx, struct vfio_irq_set *irq_set,
invalid:
vfu_log(vfu_ctx, LOG_DEBUG, "invalid SET_IRQS (%d): action=%u data_type=%u "
- "index=%u start=%u count=%u nr_fds=%u", line, a_type, d_type,
+ "index=%u start=%u count=%u nr_fds=%zu", line, a_type, d_type,
irq_set->index, irq_set->start, irq_set->count, nr_fds);
return -EINVAL;
}
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index b5c7739..0440351 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -154,7 +154,7 @@ dev_get_caps(vfu_ctx_t *vfu_ctx, vfu_reg_info_t *vfu_reg, bool is_migr_reg,
for (i = 0; i < nr_mmap_areas; i++) {
struct iovec *iov = &vfu_reg->mmap_areas[i];
- vfu_log(vfu_ctx, LOG_DEBUG, "%s: area %d [%#llx, %#llx)", __func__,
+ vfu_log(vfu_ctx, LOG_DEBUG, "%s: area %d [%p, %p)", __func__,
i, iov->iov_base, iov_end(iov));
(*fds)[i] = vfu_reg->fd;
@@ -222,7 +222,7 @@ region_access(vfu_ctx_t *vfu_ctx, size_t region_index, char *buf,
vfu_region_access_cb_t *cb = vfu_ctx->reg_info[region_index].cb;
if (cb == NULL) {
- vfu_log(vfu_ctx, LOG_ERR, "no callback for region %d",
+ vfu_log(vfu_ctx, LOG_ERR, "no callback for region %zu",
region_index);
return -EINVAL;
}
@@ -247,7 +247,7 @@ is_valid_region_access(vfu_ctx_t *vfu_ctx, size_t size, uint16_t cmd,
assert(ra != NULL);
if (size < sizeof(*ra)) {
- vfu_log(vfu_ctx, LOG_ERR, "message size too small (%d)", size);
+ vfu_log(vfu_ctx, LOG_ERR, "message size too small (%zu)", size);
return false;
}
@@ -260,14 +260,14 @@ is_valid_region_access(vfu_ctx_t *vfu_ctx, size_t size, uint16_t cmd,
index = ra->region;
if (index >= vfu_ctx->nr_regions) {
- vfu_log(vfu_ctx, LOG_ERR, "bad region index %u", index);
+ vfu_log(vfu_ctx, LOG_ERR, "bad region index %zu", index);
return false;
}
// FIXME: need to audit later for wraparound
if (ra->offset + ra->count > vfu_ctx->reg_info[index].size) {
vfu_log(vfu_ctx, LOG_ERR, "out of bounds region access %#lx-%#lx "
- "(size %#lx)", ra->offset, ra->offset + ra->count,
+ "(size %u)", ra->offset, ra->offset + ra->count,
vfu_ctx->reg_info[index].size);
return false;
@@ -276,7 +276,7 @@ is_valid_region_access(vfu_ctx_t *vfu_ctx, size_t size, uint16_t cmd,
if (device_is_stopped_and_copying(vfu_ctx->migration) &&
!is_migr_reg(vfu_ctx, index)) {
vfu_log(vfu_ctx, LOG_ERR,
- "cannot access region %u while device in stop-and-copy state",
+ "cannot access region %zu while device in stop-and-copy state",
index);
return false;
}
@@ -1361,7 +1361,7 @@ vfu_setup_region(vfu_ctx_t *vfu_ctx, int region_idx, size_t size,
if (region_idx == VFU_PCI_DEV_MIGR_REGION_IDX &&
size < vfu_get_migr_register_area_size()) {
- vfu_log(vfu_ctx, LOG_ERR, "invalid migration region size %d", size);
+ vfu_log(vfu_ctx, LOG_ERR, "invalid migration region size %zu", size);
return ERROR_INT(EINVAL);
}
diff --git a/lib/pci.c b/lib/pci.c
index f16f9dd..0cb041b 100644
--- a/lib/pci.c
+++ b/lib/pci.c
@@ -259,7 +259,7 @@ pci_hdr_write(vfu_ctx_t *vfu_ctx, const char *buf, size_t count, loff_t offset)
ret = handle_erom_write(vfu_ctx, cfg_space, buf, count);
break;
default:
- vfu_log(vfu_ctx, LOG_INFO, "PCI config write %#x-%#lx not handled\n",
+ vfu_log(vfu_ctx, LOG_INFO, "PCI config write %#lx-%#lx not handled\n",
offset, offset + count);
ret = -EINVAL;
}
@@ -316,7 +316,7 @@ pci_nonstd_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count,
if (is_write) {
vfu_log(vfu_ctx, LOG_ERR, "no callback for write to config space "
- "offset %u size %zu\n", offset, count);
+ "offset %lu size %zu\n", offset, count);
return -EINVAL;
}
diff --git a/lib/tran_sock.c b/lib/tran_sock.c
index 46b5f6b..99504c8 100644
--- a/lib/tran_sock.c
+++ b/lib/tran_sock.c
@@ -569,7 +569,7 @@ recv_version(vfu_ctx_t *vfu_ctx, int sock, uint16_t *msg_idp,
}
if (hdr.cmd != VFIO_USER_VERSION) {
- vfu_log(vfu_ctx, LOG_ERR, "msg%#hx: invalid cmd %hu (expected %hu)",
+ vfu_log(vfu_ctx, LOG_ERR, "msg%#hx: invalid cmd %hu (expected %u)",
*msg_idp, hdr.cmd, VFIO_USER_VERSION);
ret = -EINVAL;
goto out;
@@ -583,7 +583,7 @@ recv_version(vfu_ctx_t *vfu_ctx, int sock, uint16_t *msg_idp,
}
if (cversion->major != LIB_VFIO_USER_MAJOR) {
- vfu_log(vfu_ctx, LOG_ERR, "unsupported client major %hu (must be %hu)",
+ vfu_log(vfu_ctx, LOG_ERR, "unsupported client major %hu (must be %u)",
cversion->major, LIB_VFIO_USER_MAJOR);
ret = -ENOTSUP;
goto out;
@@ -821,7 +821,7 @@ tran_sock_recv_body(vfu_ctx_t *vfu_ctx, const struct vfio_user_header *hdr,
free(data);
return -ENOMSG;
} else if (ret != (int)body_size) {
- vfu_log(vfu_ctx, LOG_ERR, "msg%#hx: short read: expected=%d, actual=%d",
+ vfu_log(vfu_ctx, LOG_ERR, "msg%#hx: short read: expected=%zu, actual=%d",
hdr->msg_id, body_size, ret);
free(data);
return -ECONNRESET;