public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: device-utils: include libgen.h for musl
@ 2024-11-19  1:43 Dominique Martinet
  2024-11-19  4:31 ` Qu Wenruo
  2024-11-20 20:05 ` David Sterba
  0 siblings, 2 replies; 4+ messages in thread
From: Dominique Martinet @ 2024-11-19  1:43 UTC (permalink / raw)
  To: linux-btrfs, wqu; +Cc: Dominique Martinet

musl 1.2.5 no longer defines basename in strings.h and requires including
libgen.h as specified by POSIX, and builds now fail with this without it:
common/device-utils.c: In function 'device_get_partition_size_sysfs':
common/device-utils.c:345:16: warning: implicit declaration of function 'basename' [-Wimplicit-function-declaration]
  345 |         name = basename(path);
      |                ^~~~~~~~
common/device-utils.c:345:14: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  345 |         name = basename(path);
      |              ^

Link: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16106
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
---

This was fixed in alpine for a while but the patch never seems to have
been sent (at least a quick search didn't turn it up)

It doesn't break anything for other libcs so probably harmless as is.

 common/device-utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/device-utils.c b/common/device-utils.c
index c39e6d6166ad..56924acd7901 100644
--- a/common/device-utils.c
+++ b/common/device-utils.c
@@ -22,6 +22,7 @@
 #include <linux/blkzoned.h>
 #endif
 #include <linux/fs.h>
+#include <libgen.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
--
2.39.5



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

* Re: [PATCH] btrfs-progs: device-utils: include libgen.h for musl
  2024-11-19  1:43 [PATCH] btrfs-progs: device-utils: include libgen.h for musl Dominique Martinet
@ 2024-11-19  4:31 ` Qu Wenruo
  2024-11-20 20:05 ` David Sterba
  1 sibling, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2024-11-19  4:31 UTC (permalink / raw)
  To: Dominique Martinet, linux-btrfs, wqu



在 2024/11/19 12:13, Dominique Martinet 写道:
> musl 1.2.5 no longer defines basename in strings.h and requires including
> libgen.h as specified by POSIX, and builds now fail with this without it:
> common/device-utils.c: In function 'device_get_partition_size_sysfs':
> common/device-utils.c:345:16: warning: implicit declaration of function 'basename' [-Wimplicit-function-declaration]
>    345 |         name = basename(path);
>        |                ^~~~~~~~
> common/device-utils.c:345:14: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
>    345 |         name = basename(path);
>        |              ^
>
> Link: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16106
> Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>
> This was fixed in alpine for a while but the patch never seems to have
> been sent (at least a quick search didn't turn it up)
>
> It doesn't break anything for other libcs so probably harmless as is.
>
>   common/device-utils.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/common/device-utils.c b/common/device-utils.c
> index c39e6d6166ad..56924acd7901 100644
> --- a/common/device-utils.c
> +++ b/common/device-utils.c
> @@ -22,6 +22,7 @@
>   #include <linux/blkzoned.h>
>   #endif
>   #include <linux/fs.h>
> +#include <libgen.h>
>   #include <limits.h>
>   #include <stdio.h>
>   #include <stdlib.h>
> --
> 2.39.5
>
>
>


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

* Re: [PATCH] btrfs-progs: device-utils: include libgen.h for musl
  2024-11-19  1:43 [PATCH] btrfs-progs: device-utils: include libgen.h for musl Dominique Martinet
  2024-11-19  4:31 ` Qu Wenruo
@ 2024-11-20 20:05 ` David Sterba
  2024-11-20 22:23   ` Dominique Martinet
  1 sibling, 1 reply; 4+ messages in thread
From: David Sterba @ 2024-11-20 20:05 UTC (permalink / raw)
  To: Dominique Martinet; +Cc: linux-btrfs, wqu

On Tue, Nov 19, 2024 at 10:43:26AM +0900, Dominique Martinet wrote:
> musl 1.2.5 no longer defines basename in strings.h and requires including
> libgen.h as specified by POSIX, and builds now fail with this without it:
> common/device-utils.c: In function 'device_get_partition_size_sysfs':
> common/device-utils.c:345:16: warning: implicit declaration of function 'basename' [-Wimplicit-function-declaration]
>   345 |         name = basename(path);
>       |                ^~~~~~~~
> common/device-utils.c:345:14: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
>   345 |         name = basename(path);
>       |              ^
> 
> Link: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16106
> Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
> ---
> 
> This was fixed in alpine for a while but the patch never seems to have
> been sent (at least a quick search didn't turn it up)
> 
> It doesn't break anything for other libcs so probably harmless as is.
> 
>  common/device-utils.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/common/device-utils.c b/common/device-utils.c
> index c39e6d6166ad..56924acd7901 100644
> --- a/common/device-utils.c
> +++ b/common/device-utils.c
> @@ -22,6 +22,7 @@
>  #include <linux/blkzoned.h>
>  #endif
>  #include <linux/fs.h>
> +#include <libgen.h>

Please don't add libgen.h anywhere, this causes problems so the solution
we ended up was a one place with correct includes, which is
path-utils.c. Then path_basename() needs to be used instead of plain
basename() calls.

For reference:

- issue 778
- commit 884a609a77a6ddb7f0e0ba8789e0f0fc0e899dab
- commit d95a14949d80c7c7d6bb081d812ddcd39ba4b24d

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

* Re: [PATCH] btrfs-progs: device-utils: include libgen.h for musl
  2024-11-20 20:05 ` David Sterba
@ 2024-11-20 22:23   ` Dominique Martinet
  0 siblings, 0 replies; 4+ messages in thread
From: Dominique Martinet @ 2024-11-20 22:23 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs, wqu

David Sterba wrote on Wed, Nov 20, 2024 at 09:05:06PM +0100:
> > +#include <libgen.h>
> 
> Please don't add libgen.h anywhere, this causes problems so the solution
> we ended up was a one place with correct includes, which is
> path-utils.c. Then path_basename() needs to be used instead of plain
> basename() calls.

Argh, sorry.
I'm not sure what I built the other day that produced this warning,
master has been fixed for a while.. Please forget about this patch.

> For reference:
> 
> - issue 778
> - commit 884a609a77a6ddb7f0e0ba8789e0f0fc0e899dab
> - commit d95a14949d80c7c7d6bb081d812ddcd39ba4b24d

Thanks for the references, I'll go drop the patch from alpine so others
don't make the same mistake.

-- 
Dominique

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

end of thread, other threads:[~2024-11-20 22:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-19  1:43 [PATCH] btrfs-progs: device-utils: include libgen.h for musl Dominique Martinet
2024-11-19  4:31 ` Qu Wenruo
2024-11-20 20:05 ` David Sterba
2024-11-20 22:23   ` Dominique Martinet

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