vfio: fix cdev build with old Linux headers
PATCH 1/1 vfio: fix cdev build with old Linux headers
System headers may indirectly include linux/stddef.h before the imported UAPI headers.
Both versions share the _LINUX_STDDEF_H include guard, so the imported header is then skipped.
If the system header lacks __counted_by,
its fallback definition in the imported header is not processed, causing a compilation failure in vfio.h:
In file included from lib/eal/linux/eal_vfio_cdev.c:14:kernel/linux/uapi/linux/vfio.h:1524:51: error:
expected ':', ',', ';', '}' or '__attribute__' before '__counted_by'
Include the imported UAPI headers before the system headers so their compatibility definitions are available.
--- lib/eal/linux/eal_vfio_cdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/eal/linux/eal_vfio_cdev.c +3 -3
@@ -2,6 +2,9 @@* Copyright(c) 2010-2025 Intel Corporation */ +#include <uapi/linux/iommufd.h> +#include <uapi/linux/vfio.h> +#include <dirent.h> #include <fcntl.h> #include <limits.h>
@@ -10,9 +13,6 @@#include <sys/ioctl.h> #include <unistd.h> -#include <uapi/linux/iommufd.h> -#include <uapi/linux/vfio.h> -#include <rte_log.h> #include <rte_errno.h> #include <rte_memory.h>
Signature · 1 line
2.55.0
Quoted 14 lines · Thomas Monjalon
System headers may indirectly include
linux/stddef.hbefore the imported UAPI headers.
Both versions share the_LINUX_STDDEF_Hinclude guard, so the imported header is then skipped.If the system header lacks
__counted_by,
its fallback definition in the imported header is not processed, causing a compilation failure invfio.h:In file included from
lib/eal/linux/eal_vfio_cdev.c:14:kernel/linux/uapi/linux/vfio.h:1524:51: error:
expected ':', ',', ';', '}' or '__attribute__' before '__counted_by'
Quoted 6 lines
Include the imported UAPI headers before the system headers so their compatibility definitions are available.
Fixes d129414711aa ("vfio: introduce cdev mode")Signed-off-by Thomas Monjalon <[email protected]>
Strange we did not hit it earlier, but the fix lgtm.
I though I had fixed such issues.. but I probably missed (messed?) the new cdev file.
Signature · 1 line
David Marchand
Quoted 13 lines · Thomas Monjalon
System headers may indirectly include
linux/stddef.hbefore the imported UAPI headers.
Both versions share the_LINUX_STDDEF_Hinclude guard, so the imported header is then skipped.If the system header lacks
__counted_by,
its fallback definition in the imported header is not processed, causing a compilation failure invfio.h:In file included from
lib/eal/linux/eal_vfio_cdev.c:14:kernel/linux/uapi/linux/vfio.h:1524:51: error:
expected ':', ',', ';', '}' or '__attribute__' before '__counted_by'
Quoted 7 lines
Include the imported UAPI headers before the system headers so their compatibility definitions are available.
Fixes d129414711aa ("vfio: introduce cdev mode")Signed-off-by Thomas Monjalon <[email protected]>---
LGTM
Quoted 30 lines
lib/eal/linux/eal_vfio_cdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/eal/linux/eal_vfio_cdev.c +3
-3@@ -2,6 +2,9 @@* Copyright(c) 2010-2025 Intel Corporation */ +#include <uapi/linux/iommufd.h> +#include <uapi/linux/vfio.h> +#include <dirent.h> #include <fcntl.h> #include <limits.h> @@ -10,9 +13,6 @@#include <sys/ioctl.h> #include <unistd.h> -#include <uapi/linux/iommufd.h> -#include <uapi/linux/vfio.h> -#include <rte_log.h> #include <rte_errno.h> #include <rte_memory.h> Signature · 1 line
2.55.0
02/11/2026 16:34, Bruce Richardson:
Quoted 14 lines · Thomas Monjalon
Quoted 13 lines
System headers may indirectly include
linux/stddef.hbefore the imported UAPI headers.
Both versions share the_LINUX_STDDEF_Hinclude guard, so the imported header is then skipped.If the system header lacks
__counted_by,
its fallback definition in the imported header is not processed, causing a compilation failure invfio.h:In file included from
lib/eal/linux/eal_vfio_cdev.c:14:kernel/linux/uapi/linux/vfio.h:1524:51: error:
expected ':', ',', ';', '}' or '__attribute__' before '__counted_by'
Quoted 8 lines
Quoted 7 lines
Include the imported UAPI headers before the system headers so their compatibility definitions are available.
Fixes d129414711aa ("vfio: introduce cdev mode")Signed-off-by Thomas Monjalon <[email protected]>---
Acked-by Bruce Richardson <[email protected]>
Applied