Skip to content

Commit

Permalink
vhost: fix build for PowerPC
Browse files Browse the repository at this point in the history
When building on Ubuntu using the packaged powerpc compiler[1], a
warning is issued about the print format of the __u64 values.

../../lib/vhost/vduse.c: In function ‘vduse_vring_setup’:
../../lib/vhost/vhost.h:676:17: error: format ‘%llx’ expects argument of
type ‘long long unsigned int’, but argument 5 has type ‘__u64’ {aka
‘long unsigned int’} [-Werror=format=]
  676 |                 "VHOST_CONFIG: (%s) " fmt, prefix, ##args)
      |                 ^~~~~~~~~~~~~~~~~~~~~

Changing the format specifier to %lx, or to use PRIx64 breaks other
builds, so the safest solution is to explicitly typecast the printed
values to match the format string.

[1] powerpc64le-linux-gnu-gcc (Ubuntu 12.3.0-1ubuntu1~23.04) 12.3.0

Fixes: a9120db ("vhost: add VDUSE device startup")
Cc: [email protected]

Signed-off-by: Bruce Richardson <[email protected]>
Acked-by: Maxime Coquelin <[email protected]>
Tested-by: David Christensen <[email protected]>
  • Loading branch information
bruce-richardson authored and tmonjalo committed Oct 11, 2023
1 parent 69e1a90 commit b037cef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/vhost/vduse.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,12 @@ vduse_vring_setup(struct virtio_net *dev, unsigned int index)

VHOST_LOG_CONFIG(dev->ifname, INFO, "VQ %u info:\n", index);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tnum: %u\n", vq_info.num);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tdesc_addr: %llx\n", vq_info.desc_addr);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tdriver_addr: %llx\n", vq_info.driver_addr);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tdevice_addr: %llx\n", vq_info.device_addr);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tdesc_addr: %llx\n",
(unsigned long long)vq_info.desc_addr);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tdriver_addr: %llx\n",
(unsigned long long)vq_info.driver_addr);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tdevice_addr: %llx\n",
(unsigned long long)vq_info.device_addr);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tavail_idx: %u\n", vq_info.split.avail_index);
VHOST_LOG_CONFIG(dev->ifname, INFO, "\tready: %u\n", vq_info.ready);

Expand Down

0 comments on commit b037cef

Please sign in to comment.