Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Thomas Perale <thomas.perale@mind.be>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH kvmtool] vfio: include libgen.h (for musl compatibility)
Date: Mon, 30 Jun 2025 10:02:58 +0100	[thread overview]
Message-ID: <aGJSwh8CqUUF2CgZ@raptor> (raw)
In-Reply-To: <20250629202221.893360-1-thomas.perale@mind.be>

Hi,

On Sun, Jun 29, 2025 at 10:22:21PM +0200, Thomas Perale wrote:
> Starting GCC14 'implicit-function-declaration' are treated as errors by
> default. When building kvmtool with musl libc, the following error
> occurs due to missing declaration of 'basename':
> 
> vfio/core.c:537:22: error: implicit declaration of function ‘basename’ [-Wimplicit-function-declaration]
>   537 |         group_name = basename(group_path);
>       |                      ^~~~~~~~
> vfio/core.c:537:22: warning: nested extern declaration of ‘basename’ [-Wnested-externs]
> vfio/core.c:537:20: error: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
>   537 |         group_name = basename(group_path);
>       |                    ^
> 
> This patch fixes the issue by including the appropriate header, ensuring
> compatibility with musl and GCC14.
> 
> Signed-off-by: Thomas Perale <thomas.perale@mind.be>
> Signed-off-by: Thomas Perale <perale.thomas@gmail.com>
> ---
>  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>

Looking at man 3 basename, there are two version of basename, one is the POSIX
version (this is the one you get by including libgen.h), the other one is the
GNU version.  I don't think kvmtool cares about the differences (group_path is
never '/', and it's not a static string), so if the POSIX version makes
compilation with musl possible:

Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>

Also checked that this is the only occurence of basename in the sources.

Thanks,
Alex

>  
>  #define VFIO_DEV_DIR		"/dev/vfio"
>  #define VFIO_DEV_NODE		VFIO_DEV_DIR "/vfio"
> -- 
> 2.50.0
> 
> 

  reply	other threads:[~2025-06-30  9:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-29 20:22 [PATCH kvmtool] vfio: include libgen.h (for musl compatibility) Thomas Perale
2025-06-30  9:02 ` Alexandru Elisei [this message]
2025-06-30  9:04   ` Alexandru Elisei
2025-07-21 14:35 ` Will Deacon

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=aGJSwh8CqUUF2CgZ@raptor \
    --to=alexandru.elisei@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=thomas.perale@mind.be \
    /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