Skip to contentSkip to conversation

vfio: selftests: fix format conversion compiler warning

PATCH In review Ted Logan 4 participants 6 messages Jan 28 – Jan 29

Subsystems (4)
lore
Share & tools
lore

Ted Logan

author
#0 lore raw

PATCH 1/1 vfio: selftests: fix format conversion compiler warning

Use the standard format conversion macro PRIx64 to generate the appropriate format conversion for 64-bit integers. Fixes a compiler warning with -Wformat on i386.

---
Compiler warning fixed by patch:

   In file included from tools/testing/selftests/vfio/lib/include/libvfio.h:6:
   tools/testing/selftests/vfio/lib/include/libvfio/iommu.h:49:2: warning: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]
      49 |         VFIO_ASSERT_EQ(__iommu_unmap(iommu, region, NULL), 0);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:32:37: note: expanded from macro 'VFIO_ASSERT_EQ'
      32 | #define VFIO_ASSERT_EQ(_a, _b, ...) VFIO_ASSERT_OP(_a, _b, ==, ##__VA_ARGS__)
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:27:22: note: expanded from macro 'VFIO_ASSERT_OP'
      26 |         fprintf(stderr, "  Observed: %#lx %s %#lx\n",                           \
         |                                              ~~~~
      27 |                         (u64)__lhs, #_op, (u64)__rhs);                          \
         |                                           ^~~~~~~~~~
---
 tools/testing/selftests/vfio/lib/include/libvfio/assert.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/vfio/lib/include/libvfio/assert.h +2 -1
index f4ebd122d9b6..a2d610e22acd 100644
@@ -2,6 +2,7 @@
 #ifndef SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_ASSERT_H
 #define SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_ASSERT_H
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/ioctl.h>
@@ -23,7 +24,7 @@
 										\
 	fprintf(stderr, "%s:%u: Assertion Failure\n\n", __FILE__, __LINE__);	\
 	fprintf(stderr, "  Expression: " #_lhs " " #_op " " #_rhs "\n");	\
-	fprintf(stderr, "  Observed: %#lx %s %#lx\n",				\
+	fprintf(stderr, "  Observed: %#" PRIx64 " %s %#" PRIx64 "\n",		\
 			(u64)__lhs, #_op, (u64)__rhs);				\
 	fprintf(stderr, "  [errno: %d - %s]\n", errno, strerror(errno));	\
 	VFIO_LOG_AND_EXIT(__VA_ARGS__);						\
Signature · 1 line
2.47.3
maintainer
#1 lore raw
Quoted 8 lines · Ted Logan

Use the standard format conversion macro PRIx64 to generate the appropriate format conversion for 64-bit integers. Fixes a compiler warning with -Wformat on i386.

Thanks for the patch.

I've been seeing these i386 reports as well. I find the PRIx64, etc. format specifiers make format strings very hard to read. And I think there were some other issues when building VFIO selftests with i386 the last time I tried.

I was thinking instead we should just not support i386 builds of VFIO selftests. But I hadn't gotten around to figuring out the right Makefile magic to make that happen.

#2 lore raw
Quoted 12 lines · David Matlack
Quoted 8 lines · Ted Logan

Use the standard format conversion macro PRIx64 to generate the appropriate format conversion for 64-bit integers. Fixes a compiler warning with -Wformat on i386.

Thanks for the patch.

Quoted 8 lines

I've been seeing these i386 reports as well. I find the PRIx64, etc. format specifiers make format strings very hard to read. And I think there were some other issues when building VFIO selftests with i386 the last time I tried.

I was thinking instead we should just not support i386 builds of VFIO selftests. But I hadn't gotten around to figuring out the right Makefile magic to make that happen.

There are other 32-bit CPUs besides i386.
Or do only support X86?

Signature · 1 line
~Randy
maintainer
#3 lore raw
Quoted 18 lines · Randy Dunlap
Quoted 17 lines · David Matlack
Quoted 8 lines · Ted Logan

Use the standard format conversion macro PRIx64 to generate the appropriate format conversion for 64-bit integers. Fixes a compiler warning with -Wformat on i386.

Thanks for the patch.

I've been seeing these i386 reports as well. I find the PRIx64, etc. format specifiers make format strings very hard to read. And I think there were some other issues when building VFIO selftests with i386 the last time I tried.

Quoted 6 lines
Quoted 3 lines

I was thinking instead we should just not support i386 builds of VFIO selftests. But I hadn't gotten around to figuring out the right Makefile magic to make that happen.

There are other 32-bit CPUs besides i386.
Or do only support X86?

At this point I would only call x86_64 and arm64 as supported. At least that is all I have access to and tested.

If there is legitimate desire to run these tests on 32-bit CPUs, then we can support it.

Alex, do you test on 32-bit CPUs?

maintainer
#4 lore raw
Quoted 26 lines · On Wed, 28 Jan 2026 11:21:52 -0800 David Matlack <[email protected]> wrote:
Quoted 18 lines · Randy Dunlap
Quoted 17 lines · David Matlack
Quoted 8 lines · Ted Logan

Use the standard format conversion macro PRIx64 to generate the appropriate format conversion for 64-bit integers. Fixes a compiler warning with -Wformat on i386.

Thanks for the patch.

I've been seeing these i386 reports as well. I find the PRIx64, etc. format specifiers make format strings very hard to read. And I think there were some other issues when building VFIO selftests with i386 the last time I tried.

Quoted 6 lines
Quoted 3 lines

I was thinking instead we should just not support i386 builds of VFIO selftests. But I hadn't gotten around to figuring out the right Makefile magic to make that happen.

There are other 32-bit CPUs besides i386.
Or do only support X86?

Quoted 7 lines

At this point I would only call x86_64 and arm64 as supported. At least that is all I have access to and tested.

If there is legitimate desire to run these tests on 32-bit CPUs, then we can support it.

Alex, do you test on 32-bit CPUs?

No, I haven't tested 32-bit in a very long time. I'd like to think it works, but I'm not aware of any worthwhile use case. Thanks,

Alex

maintainer
#5 lore raw
Quoted 33 lines · Alex Williamson
Quoted 29 lines · On Wed, 28 Jan 2026 11:21:52 -0800 David Matlack <[email protected]> wrote:
Quoted 18 lines · Randy Dunlap
Quoted 17 lines · David Matlack
Quoted 8 lines · Ted Logan

Use the standard format conversion macro PRIx64 to generate the appropriate format conversion for 64-bit integers. Fixes a compiler warning with -Wformat on i386.

Thanks for the patch.

I've been seeing these i386 reports as well. I find the PRIx64, etc. format specifiers make format strings very hard to read. And I think there were some other issues when building VFIO selftests with i386 the last time I tried.

Quoted 6 lines
Quoted 3 lines

I was thinking instead we should just not support i386 builds of VFIO selftests. But I hadn't gotten around to figuring out the right Makefile magic to make that happen.

There are other 32-bit CPUs besides i386.
Or do only support X86?

At this point I would only call x86_64 and arm64 as supported. At least that is all I have access to and tested.

Quoted 7 lines
Quoted 4 lines

If there is legitimate desire to run these tests on 32-bit CPUs, then we can support it.

Alex, do you test on 32-bit CPUs?

No, I haven't tested 32-bit in a very long time. I'd like to think it works, but I'm not aware of any worthwhile use case.

Ok, thanks. Then let's defer making the selftests code 32-bit compatible until there's a use-case / demand.

Ted, would you be able to send another to change to opt-out VFIO selftests from 32-bit builds to avoid future kernel test robot reports?