public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: "J. Neuschäfer" <j.neuschaefer@gmx.net>
Cc: kvm@vger.kernel.org, Alyssa Ross <hi@alyssa.is>,
	Alexandru Elisei <Alexandru.Elisei@arm.com>,
	Will Deacon <will@kernel.org>,
	Julien Thierry <julien.thierry.kdev@gmail.com>
Subject: Re: [PATCH kvmtool v2 1/2] Switch to POSIX version of basename()
Date: Thu, 8 Aug 2024 13:17:53 +0100	[thread overview]
Message-ID: <20240808131753.1657f95c@donnerap.manchester.arm.com> (raw)
In-Reply-To: <20240727-musl-v2-1-b106252a1cba@gmx.net>

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
> 


  reply	other threads:[~2024-08-08 12:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-27 17:11 [PATCH kvmtool v2 0/2] Fix compilation with musl-libc based toolchains J. Neuschäfer
2024-07-27 17:11 ` [PATCH kvmtool v2 1/2] Switch to POSIX version of basename() J. Neuschäfer
2024-08-08 12:17   ` Andre Przywara [this message]
2024-07-27 17:11 ` [PATCH kvmtool v2 2/2] Get __WORDSIZE from <sys/reg.h> for musl compat J. Neuschäfer
2024-07-29 16:24   ` Alexandru Elisei
2024-07-30 15:02     ` Andre Przywara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240808131753.1657f95c@donnerap.manchester.arm.com \
    --to=andre.przywara@arm.com \
    --cc=Alexandru.Elisei@arm.com \
    --cc=hi@alyssa.is \
    --cc=j.neuschaefer@gmx.net \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox