[PATCH] vfio: selftests: fix format conversion compiler warning

Ted Logan posted 1 patch 1 week, 2 days ago
tools/testing/selftests/vfio/lib/include/libvfio/assert.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] vfio: selftests: fix format conversion compiler warning
Posted by Ted Logan 1 week, 2 days ago
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.

Signed-off-by: Ted Logan <tedlogan@fb.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202601211830.aBEjmEFD-lkp@intel.com/

---
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(-)

diff --git a/tools/testing/selftests/vfio/lib/include/libvfio/assert.h b/tools/testing/selftests/vfio/lib/include/libvfio/assert.h
index f4ebd122d9b6..a2d610e22acd 100644
--- a/tools/testing/selftests/vfio/lib/include/libvfio/assert.h
+++ b/tools/testing/selftests/vfio/lib/include/libvfio/assert.h
@@ -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__);						\
-- 
2.47.3
Re: [PATCH] vfio: selftests: fix format conversion compiler warning
Posted by David Matlack 1 week, 2 days ago
On Wed, Jan 28, 2026 at 10:38 AM Ted Logan <tedlogan@fb.com> wrote:
>
> 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.
>
> Signed-off-by: Ted Logan <tedlogan@fb.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202601211830.aBEjmEFD-lkp@intel.com/

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.
Re: [PATCH] vfio: selftests: fix format conversion compiler warning
Posted by Randy Dunlap 1 week, 2 days ago

On 1/28/26 11:06 AM, David Matlack wrote:
> On Wed, Jan 28, 2026 at 10:38 AM Ted Logan <tedlogan@fb.com> wrote:
>>
>> 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.
>>
>> Signed-off-by: Ted Logan <tedlogan@fb.com>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202601211830.aBEjmEFD-lkp@intel.com/
> 
> 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.

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

-- 
~Randy

Re: [PATCH] vfio: selftests: fix format conversion compiler warning
Posted by David Matlack 1 week, 2 days ago
On Wed, Jan 28, 2026 at 11:12 AM Randy Dunlap <rdunlap@infradead.org> wrote:
> On 1/28/26 11:06 AM, David Matlack wrote:
> > On Wed, Jan 28, 2026 at 10:38 AM Ted Logan <tedlogan@fb.com> wrote:
> >>
> >> 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.
> >>
> >> Signed-off-by: Ted Logan <tedlogan@fb.com>
> >> Reported-by: kernel test robot <lkp@intel.com>
> >> Closes: https://lore.kernel.org/oe-kbuild-all/202601211830.aBEjmEFD-lkp@intel.com/
> >
> > 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.
>
> 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?
Re: [PATCH] vfio: selftests: fix format conversion compiler warning
Posted by Alex Williamson 1 week, 1 day ago
On Wed, 28 Jan 2026 11:21:52 -0800
David Matlack <dmatlack@google.com> wrote:

> On Wed, Jan 28, 2026 at 11:12 AM Randy Dunlap <rdunlap@infradead.org> wrote:
> > On 1/28/26 11:06 AM, David Matlack wrote:  
> > > On Wed, Jan 28, 2026 at 10:38 AM Ted Logan <tedlogan@fb.com> wrote:  
> > >>
> > >> 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.
> > >>
> > >> Signed-off-by: Ted Logan <tedlogan@fb.com>
> > >> Reported-by: kernel test robot <lkp@intel.com>
> > >> Closes: https://lore.kernel.org/oe-kbuild-all/202601211830.aBEjmEFD-lkp@intel.com/  
> > >
> > > 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.  
> >
> > 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?

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
Re: [PATCH] vfio: selftests: fix format conversion compiler warning
Posted by David Matlack 1 week, 1 day ago
On Thu, Jan 29, 2026 at 10:50 AM Alex Williamson <alex@shazbot.org> wrote:
>
> On Wed, 28 Jan 2026 11:21:52 -0800
> David Matlack <dmatlack@google.com> wrote:
>
> > On Wed, Jan 28, 2026 at 11:12 AM Randy Dunlap <rdunlap@infradead.org> wrote:
> > > On 1/28/26 11:06 AM, David Matlack wrote:
> > > > On Wed, Jan 28, 2026 at 10:38 AM Ted Logan <tedlogan@fb.com> wrote:
> > > >>
> > > >> 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.
> > > >>
> > > >> Signed-off-by: Ted Logan <tedlogan@fb.com>
> > > >> Reported-by: kernel test robot <lkp@intel.com>
> > > >> Closes: https://lore.kernel.org/oe-kbuild-all/202601211830.aBEjmEFD-lkp@intel.com/
> > > >
> > > > 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.
> > >
> > > 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?
>
> 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?