Re: [PATCH kvmtool v2 1/2] Switch to POSIX version of basename()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 27 Jul 2024 19:11:02 +0200
J. Neuschäfer <j.neuschaefer@xxxxxxx> 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@xxxxxxxxx>
> Signed-off-by: J. Neuschäfer <j.neuschaefer@xxxxxxx>

Reviewed-by: Andre Przywara <andre.przywara@xxxxxxx>

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
> 






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux