vfio: Include libgen.h for basename API
PATCH v2 1/1 vfio: Include libgen.h for basename API
Glibc has two implementation one based on POSIX which is used when libgen.h is included and second implementation is GNU implementation which is used when string.h is included. The functions are no identical in behavior. Musl C library does not implement the GNU version, but it has provided a declaration in string.h but this has been corrected in latest musl [1] which exposes places where it was being used from string.h to error out especially when -Wimplicit-function-declaration is treated as error.
| ../qemu-8.1.2/hw/vfio/pci.c:3030:18: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
| 3030 | group_name = basename(group_path);
clang-17 treats this warning as error by default
[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
---
v2: Add missing link for [1]
hw/vfio/pci.c | 1 + hw/vfio/platform.c | 1 + 2 files changed, 2 insertions(+)
hw/vfio/pci.c +1 -0
@@ -19,6 +19,7 @@*/ #include "qemu/osdep.h" +#include <libgen.h> #include <linux/vfio.h> #include <sys/ioctl.h>
hw/vfio/platform.c +1 -0
@@ -16,6 +16,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include <libgen.h> #include <sys/ioctl.h> #include <linux/vfio.h>
Signature · 1 line
2.43.0
Hello,
Quoted 12 lines · Khem Raj
Glibc has two implementation one based on POSIX which is used when
libgen.his included and second implementation is GNU implementation which is used whenstring.his included. The functions are no identical in behavior. Musl C library does not implement the GNU version, but it has provided a declaration instring.hbut this has been corrected in latest musl [1] which exposes places where it was being used fromstring.hto error out especially when -Wimplicit-function-declaration is treated as error.|
../qemu-8.1.2/hw/vfio/pci.c:3030:18: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
| 3030 |group_name=basename(group_path);
Quoted 7 lines
clang-17 treats this warning as error by default
[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
Signed-off-by Khem Raj <[email protected]>---
v2: Add missing link for [1]
Thanks for the fix. The upstream code has changed though and I think we should be using g_path_get_basename() instead.
Could you please rebase ? Or I will do it in the QEMU 9.0 cycle. This is too late for QEMU 8.2 anyhow.
Thanks,
C.
Quoted 29 lines
hw/vfio/pci.c | 1 + hw/vfio/platform.c | 1 + 2 files changed, 2 insertions(+)hw/vfio/pci.c +1
-0@@ -19,6 +19,7 @@*/ #include "qemu/osdep.h" +#include <libgen.h> #include <linux/vfio.h> #include <sys/ioctl.h> hw/vfio/platform.c +1
-0@@ -16,6 +16,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include <libgen.h> #include <sys/ioctl.h> #include <linux/vfio.h>