Message ID | 20240727-musl-v2-1-b106252a1cba@gmx.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix compilation with musl-libc based toolchains | expand |
On Sat, 27 Jul 2024 19:11:02 +0200 J. Neuschäfer <j.neuschaefer@gmx.net> wrote: Hi, > There are two versions of the basename function: The POSIX version is > defined in <libgen.h>, and glibc additionally provides a GNU-specific > version in <string.h>. That's right, the Linux manpage confirms that. It seems like on GLIBC Linux we get the GNU version, since we implicitly include string.h, and define _GNU_SOURCE. The manpage talks about the differences between the two: the POSIX version can modify the string, and it differs when the last character is a '/'. Both cases do not apply to us here, so we can use either version: > musl-libc only provides the POSIX version, > resulting in a compilation failure: > > vfio/core.c:538:22: error: implicit declaration of function 'basename' [-Werror=implicit-function-declaration] > 538 | group_name = basename(group_path); > | ^~~~~~~~ > > Reviewed-by: Alyssa Ross <hi@alyssa.is> > Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Cheers, Andre > --- > vfio/core.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/vfio/core.c b/vfio/core.c > index 3ff2c0b..8f88489 100644 > --- a/vfio/core.c > +++ b/vfio/core.c > @@ -3,6 +3,7 @@ > #include "kvm/ioport.h" > > #include <linux/list.h> > +#include <libgen.h> > > #define VFIO_DEV_DIR "/dev/vfio" > #define VFIO_DEV_NODE VFIO_DEV_DIR "/vfio" > > -- > 2.43.0 >
diff --git a/vfio/core.c b/vfio/core.c index 3ff2c0b..8f88489 100644 --- a/vfio/core.c +++ b/vfio/core.c @@ -3,6 +3,7 @@ #include "kvm/ioport.h" #include <linux/list.h> +#include <libgen.h> #define VFIO_DEV_DIR "/dev/vfio" #define VFIO_DEV_NODE VFIO_DEV_DIR "/vfio"