mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] vfio: selftests: Include <libgen.h> for basename() on non-glibc builds
@ 2026-08-24 22:28 Hisam Mehboob
  2026-09-25 20:49 ` Alex Williamson
  0 siblings, 1 reply; 2+ messages in thread
From: Hisam Mehboob @ 2026-08-24 22:28 UTC (permalink / raw)
  To: kvm
  Cc: dmatlack, alex, shuah, seanjc, jrhilke, rananta, vipinsh,
	linux-kselftest, linux-kernel, Hisam Mehboob

sysfs.c calls basename() but does not include its declaration.
Glibc exposes basename() through <string.h> with _GNU_SOURCE, while
musl declares it in <libgen.h>.

With musl, this results in an implicit-function-declaration error and
subsequent type-mismatch errors at the callers.

Include <libgen.h> so the declaration is available on both glibc and
musl. This is safe at both call sites: the arguments are local writable
char[PATH_MAX] buffers filled by readlink_safe().

Link: https://lore.kernel.org/kvm/CALzav=fs4bqMM7BXNPXqhtbqGzA+LW5fgx2-1Q5=sTN5+krYhw@mail.gmail.com/
Fixes: a262fc49e0aa ("KVM: selftests: Build and link selftests/vfio/lib into KVM selftests")
Reviewed-by: David Matlack <dmatlack@google.com>
Signed-off-by: Hisam Mehboob <hisamshar@gmail.com>
---
v2:
  - Changed subject prefix from "selftests/vfio:" to "vfio: selftests:"
  - Added David's Reviewed-by tag.

 tools/testing/selftests/vfio/lib/sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/vfio/lib/sysfs.c b/tools/testing/selftests/vfio/lib/sysfs.c
index 11415448b2e2..daf117a299a6 100644
--- a/tools/testing/selftests/vfio/lib/sysfs.c
+++ b/tools/testing/selftests/vfio/lib/sysfs.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <fcntl.h>
+#include <libgen.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] vfio: selftests: Include <libgen.h> for basename() on non-glibc builds
  2026-08-24 22:28 [PATCH v2] vfio: selftests: Include <libgen.h> for basename() on non-glibc builds Hisam Mehboob
@ 2026-09-25 20:49 ` Alex Williamson
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Williamson @ 2026-09-25 20:49 UTC (permalink / raw)
  To: Hisam Mehboob
  Cc: kvm, dmatlack, shuah, seanjc, jrhilke, rananta, vipinsh,
	linux-kselftest, linux-kernel, alex

On Tue, 25 Aug 2026 03:28:47 +0500
Hisam Mehboob <hisamshar@gmail.com> wrote:

> sysfs.c calls basename() but does not include its declaration.
> Glibc exposes basename() through <string.h> with _GNU_SOURCE, while
> musl declares it in <libgen.h>.
> 
> With musl, this results in an implicit-function-declaration error and
> subsequent type-mismatch errors at the callers.
> 
> Include <libgen.h> so the declaration is available on both glibc and
> musl. This is safe at both call sites: the arguments are local writable
> char[PATH_MAX] buffers filled by readlink_safe().
> 
> Link: https://lore.kernel.org/kvm/CALzav=fs4bqMM7BXNPXqhtbqGzA+LW5fgx2-1Q5=sTN5+krYhw@mail.gmail.com/
> Fixes: a262fc49e0aa ("KVM: selftests: Build and link selftests/vfio/lib into KVM selftests")
> Reviewed-by: David Matlack <dmatlack@google.com>
> Signed-off-by: Hisam Mehboob <hisamshar@gmail.com>
> ---
> v2:
>   - Changed subject prefix from "selftests/vfio:" to "vfio: selftests:"
>   - Added David's Reviewed-by tag.
> 
>  tools/testing/selftests/vfio/lib/sysfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/vfio/lib/sysfs.c b/tools/testing/selftests/vfio/lib/sysfs.c
> index 11415448b2e2..daf117a299a6 100644
> --- a/tools/testing/selftests/vfio/lib/sysfs.c
> +++ b/tools/testing/selftests/vfio/lib/sysfs.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  #include <fcntl.h>
> +#include <libgen.h>
>  #include <unistd.h>
>  #include <stdlib.h>
>  #include <string.h>

Applied to vfio next for v7.4.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-25 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-24 22:28 [PATCH v2] vfio: selftests: Include <libgen.h> for basename() on non-glibc builds Hisam Mehboob
2026-09-25 20:49 ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®