Navigation Menu

Skip to content

Commit

Permalink
contrib/libvhost-user: Fix bad printf format specifiers
Browse files Browse the repository at this point in the history
We should use printf format specifier "%u" instead of "%d" for
argument of type "unsigned int".

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Alex Chen <alex.chen@huawei.com>
Message-Id: <5FA28106.6000901@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
AlexChen authored and mstsirkin committed Nov 17, 2020
1 parent 727a063 commit 5fd6921
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions contrib/libvhost-user/libvhost-user.c
Expand Up @@ -701,7 +701,7 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
return false;
}

DPRINT("Adding region: %d\n", dev->nregions);
DPRINT("Adding region: %u\n", dev->nregions);
DPRINT(" guest_phys_addr: 0x%016"PRIx64"\n",
msg_region->guest_phys_addr);
DPRINT(" memory_size: 0x%016"PRIx64"\n",
Expand Down Expand Up @@ -848,7 +848,7 @@ vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg *vmsg)
VhostUserMemory m = vmsg->payload.memory, *memory = &m;
dev->nregions = memory->nregions;

DPRINT("Nregions: %d\n", memory->nregions);
DPRINT("Nregions: %u\n", memory->nregions);
for (i = 0; i < dev->nregions; i++) {
void *mmap_addr;
VhostUserMemoryRegion *msg_region = &memory->regions[i];
Expand Down Expand Up @@ -938,7 +938,7 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)
return vu_set_mem_table_exec_postcopy(dev, vmsg);
}

DPRINT("Nregions: %d\n", memory->nregions);
DPRINT("Nregions: %u\n", memory->nregions);
for (i = 0; i < dev->nregions; i++) {
void *mmap_addr;
VhostUserMemoryRegion *msg_region = &memory->regions[i];
Expand Down Expand Up @@ -1049,8 +1049,8 @@ vu_set_vring_num_exec(VuDev *dev, VhostUserMsg *vmsg)
unsigned int index = vmsg->payload.state.index;
unsigned int num = vmsg->payload.state.num;

DPRINT("State.index: %d\n", index);
DPRINT("State.num: %d\n", num);
DPRINT("State.index: %u\n", index);
DPRINT("State.num: %u\n", num);
dev->vq[index].vring.num = num;

return false;
Expand Down Expand Up @@ -1105,8 +1105,8 @@ vu_set_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg)
unsigned int index = vmsg->payload.state.index;
unsigned int num = vmsg->payload.state.num;

DPRINT("State.index: %d\n", index);
DPRINT("State.num: %d\n", num);
DPRINT("State.index: %u\n", index);
DPRINT("State.num: %u\n", num);
dev->vq[index].shadow_avail_idx = dev->vq[index].last_avail_idx = num;

return false;
Expand All @@ -1117,7 +1117,7 @@ vu_get_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg)
{
unsigned int index = vmsg->payload.state.index;

DPRINT("State.index: %d\n", index);
DPRINT("State.index: %u\n", index);
vmsg->payload.state.num = dev->vq[index].last_avail_idx;
vmsg->size = sizeof(vmsg->payload.state);

Expand Down Expand Up @@ -1478,8 +1478,8 @@ vu_set_vring_enable_exec(VuDev *dev, VhostUserMsg *vmsg)
unsigned int index = vmsg->payload.state.index;
unsigned int enable = vmsg->payload.state.num;

DPRINT("State.index: %d\n", index);
DPRINT("State.enable: %d\n", enable);
DPRINT("State.index: %u\n", index);
DPRINT("State.enable: %u\n", enable);

if (index >= dev->max_queues) {
vu_panic(dev, "Invalid vring_enable index: %u", index);
Expand Down Expand Up @@ -1728,7 +1728,7 @@ vu_handle_vring_kick(VuDev *dev, VhostUserMsg *vmsg)
return false;
}

DPRINT("Got kick message: handler:%p idx:%d\n",
DPRINT("Got kick message: handler:%p idx:%u\n",
dev->vq[index].handler, index);

if (!dev->vq[index].started) {
Expand Down Expand Up @@ -1772,7 +1772,7 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
DPRINT("Request: %s (%d)\n", vu_request_to_string(vmsg->request),
vmsg->request);
DPRINT("Flags: 0x%x\n", vmsg->flags);
DPRINT("Size: %d\n", vmsg->size);
DPRINT("Size: %u\n", vmsg->size);

if (vmsg->fd_num) {
int i;
Expand Down

0 comments on commit 5fd6921

Please sign in to comment.