Message ID | 20241119014326.3639742-1-dominique.martinet@atmark-techno.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | btrfs-progs: device-utils: include libgen.h for musl | expand |
在 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 > > >
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
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.
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>
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(+) -- 2.39.5