[1/3] vhost: fix build for powerpc

Message ID 20230831121058.725577-2-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series enable PPC in test-meson-builds on ubuntu |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson Aug. 31, 2023, 12:10 p.m. UTC
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: a9120db8b98b ("vhost: add VDUSE device startup")
Cc: maxime.coquelin@redhat.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/vhost/vduse.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Comments

Bruce Richardson Sept. 1, 2023, 2:59 p.m. UTC | #1
+PPC maintainer

On Thu, Aug 31, 2023 at 01:10:56PM +0100, Bruce Richardson wrote:
> 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: a9120db8b98b ("vhost: add VDUSE device startup")
> Cc: maxime.coquelin@redhat.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  lib/vhost/vduse.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
> index 73ed424232..e2b6d35d37 100644
> --- a/lib/vhost/vduse.c
> +++ b/lib/vhost/vduse.c
> @@ -162,9 +162,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);
>  
> -- 
> 2.39.2
>
  
David Christensen Sept. 12, 2023, 6:30 p.m. UTC | #2
On 9/1/23 7:59 AM, Bruce Richardson wrote:
> +PPC maintainer
> 
> On Thu, Aug 31, 2023 at 01:10:56PM +0100, Bruce Richardson wrote:
>> 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: a9120db8b98b ("vhost: add VDUSE device startup")
>> Cc: maxime.coquelin@redhat.com
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>> ---

Tested-by: David Christensen <drc@linux.vnet.ibm.com>
  
Maxime Coquelin Sept. 29, 2023, 2:47 p.m. UTC | #3
On 8/31/23 14:10, Bruce Richardson wrote:
> 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: a9120db8b98b ("vhost: add VDUSE device startup")
> Cc: maxime.coquelin@redhat.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>   lib/vhost/vduse.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
> index 73ed424232..e2b6d35d37 100644
> --- a/lib/vhost/vduse.c
> +++ b/lib/vhost/vduse.c
> @@ -162,9 +162,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);
>   

It is surprising PRIx64 does not work on other architectures.
I don't see a better solution, so:

Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
index 73ed424232..e2b6d35d37 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -162,9 +162,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);