* [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r
@ 2025-09-06 8:12 A. Wilcox
2025-09-12 7:14 ` Christoph Hellwig
2025-09-12 15:00 ` Darrick J. Wong
0 siblings, 2 replies; 6+ messages in thread
From: A. Wilcox @ 2025-09-06 8:12 UTC (permalink / raw)
To: linux-xfs; +Cc: A. Wilcox
When building xfsprogs with musl libc, strerror_r returns int as
specified in POSIX. This differs from the glibc extension that returns
char*. Successful calls will return 0, which will be dereferenced as a
NULL pointer by (v)fprintf.
Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
---
scrub/common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scrub/common.c b/scrub/common.c
index 14cd677b..9437d0ab 100644
--- a/scrub/common.c
+++ b/scrub/common.c
@@ -126,7 +126,8 @@ __str_out(
fprintf(stream, "%s%s: %s: ", stream_start(stream),
_(err_levels[level].string), descr);
if (error) {
- fprintf(stream, _("%s."), strerror_r(error, buf, DESCR_BUFSZ));
+ strerror_r(error, buf, DESCR_BUFSZ);
+ fprintf(stream, _("%s."), buf);
} else {
va_start(args, format);
vfprintf(stream, format, args);
--
2.49.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r
2025-09-06 8:12 [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r A. Wilcox
@ 2025-09-12 7:14 ` Christoph Hellwig
2025-09-12 15:00 ` Darrick J. Wong
1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2025-09-12 7:14 UTC (permalink / raw)
To: A. Wilcox; +Cc: linux-xfs
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r
2025-09-06 8:12 [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r A. Wilcox
2025-09-12 7:14 ` Christoph Hellwig
@ 2025-09-12 15:00 ` Darrick J. Wong
2025-09-18 16:27 ` Darrick J. Wong
1 sibling, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2025-09-12 15:00 UTC (permalink / raw)
To: A. Wilcox; +Cc: linux-xfs
On Sat, Sep 06, 2025 at 03:12:07AM -0500, A. Wilcox wrote:
> When building xfsprogs with musl libc, strerror_r returns int as
> specified in POSIX. This differs from the glibc extension that returns
> char*. Successful calls will return 0, which will be dereferenced as a
> NULL pointer by (v)fprintf.
>
> Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
Isn't C fun?
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> scrub/common.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/scrub/common.c b/scrub/common.c
> index 14cd677b..9437d0ab 100644
> --- a/scrub/common.c
> +++ b/scrub/common.c
> @@ -126,7 +126,8 @@ __str_out(
> fprintf(stream, "%s%s: %s: ", stream_start(stream),
> _(err_levels[level].string), descr);
> if (error) {
> - fprintf(stream, _("%s."), strerror_r(error, buf, DESCR_BUFSZ));
> + strerror_r(error, buf, DESCR_BUFSZ);
> + fprintf(stream, _("%s."), buf);
> } else {
> va_start(args, format);
> vfprintf(stream, format, args);
> --
> 2.49.0
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r
2025-09-12 15:00 ` Darrick J. Wong
@ 2025-09-18 16:27 ` Darrick J. Wong
2025-09-19 10:52 ` Andrey Albershteyn
0 siblings, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2025-09-18 16:27 UTC (permalink / raw)
To: A. Wilcox; +Cc: linux-xfs, Andrey Albershteyn
On Fri, Sep 12, 2025 at 08:00:44AM -0700, Darrick J. Wong wrote:
> On Sat, Sep 06, 2025 at 03:12:07AM -0500, A. Wilcox wrote:
> > When building xfsprogs with musl libc, strerror_r returns int as
> > specified in POSIX. This differs from the glibc extension that returns
> > char*. Successful calls will return 0, which will be dereferenced as a
> > NULL pointer by (v)fprintf.
> >
> > Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
>
> Isn't C fun?
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Ohh yes it is, this patch broke the build for me:
common.c: In function ‘__str_out’:
common.c:129:17: error: ignoring return value of ‘strerror_r’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
129 | strerror_r(error, buf, DESCR_BUFSZ);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<sigh> xfsprogs can't get the XSI version because it defines GNU_SOURCE,
and you can't shut up gcc by casting the whole expression to void.
Do you folks remove the -D_GNU_SOURCE from builddefs.in when building
against musl? Or do you leave the definition alone, taking advantage of
the fact that #define'ing a symbol is not a guarantee of functionality?
--D
> --D
>
> > ---
> > scrub/common.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/scrub/common.c b/scrub/common.c
> > index 14cd677b..9437d0ab 100644
> > --- a/scrub/common.c
> > +++ b/scrub/common.c
> > @@ -126,7 +126,8 @@ __str_out(
> > fprintf(stream, "%s%s: %s: ", stream_start(stream),
> > _(err_levels[level].string), descr);
> > if (error) {
> > - fprintf(stream, _("%s."), strerror_r(error, buf, DESCR_BUFSZ));
> > + strerror_r(error, buf, DESCR_BUFSZ);
> > + fprintf(stream, _("%s."), buf);
> > } else {
> > va_start(args, format);
> > vfprintf(stream, format, args);
> > --
> > 2.49.0
> >
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r
2025-09-18 16:27 ` Darrick J. Wong
@ 2025-09-19 10:52 ` Andrey Albershteyn
2025-09-19 16:25 ` Darrick J. Wong
0 siblings, 1 reply; 6+ messages in thread
From: Andrey Albershteyn @ 2025-09-19 10:52 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: A. Wilcox, linux-xfs
On 2025-09-18 09:27:44, Darrick J. Wong wrote:
> On Fri, Sep 12, 2025 at 08:00:44AM -0700, Darrick J. Wong wrote:
> > On Sat, Sep 06, 2025 at 03:12:07AM -0500, A. Wilcox wrote:
> > > When building xfsprogs with musl libc, strerror_r returns int as
> > > specified in POSIX. This differs from the glibc extension that returns
> > > char*. Successful calls will return 0, which will be dereferenced as a
> > > NULL pointer by (v)fprintf.
> > >
> > > Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
> >
> > Isn't C fun?
> > Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
>
> Ohh yes it is, this patch broke the build for me:
do you build gcc + musl?
- Andrey
>
> common.c: In function ‘__str_out’:
> common.c:129:17: error: ignoring return value of ‘strerror_r’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
> 129 | strerror_r(error, buf, DESCR_BUFSZ);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> <sigh> xfsprogs can't get the XSI version because it defines GNU_SOURCE,
> and you can't shut up gcc by casting the whole expression to void.
>
> Do you folks remove the -D_GNU_SOURCE from builddefs.in when building
> against musl? Or do you leave the definition alone, taking advantage of
> the fact that #define'ing a symbol is not a guarantee of functionality?
>
> --D
>
> > --D
> >
> > > ---
> > > scrub/common.c | 3 ++-
> > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/scrub/common.c b/scrub/common.c
> > > index 14cd677b..9437d0ab 100644
> > > --- a/scrub/common.c
> > > +++ b/scrub/common.c
> > > @@ -126,7 +126,8 @@ __str_out(
> > > fprintf(stream, "%s%s: %s: ", stream_start(stream),
> > > _(err_levels[level].string), descr);
> > > if (error) {
> > > - fprintf(stream, _("%s."), strerror_r(error, buf, DESCR_BUFSZ));
> > > + strerror_r(error, buf, DESCR_BUFSZ);
> > > + fprintf(stream, _("%s."), buf);
> > > } else {
> > > va_start(args, format);
> > > vfprintf(stream, format, args);
> > > --
> > > 2.49.0
> > >
> > >
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r
2025-09-19 10:52 ` Andrey Albershteyn
@ 2025-09-19 16:25 ` Darrick J. Wong
0 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2025-09-19 16:25 UTC (permalink / raw)
To: Andrey Albershteyn; +Cc: A. Wilcox, linux-xfs
On Fri, Sep 19, 2025 at 12:52:46PM +0200, Andrey Albershteyn wrote:
> On 2025-09-18 09:27:44, Darrick J. Wong wrote:
> > On Fri, Sep 12, 2025 at 08:00:44AM -0700, Darrick J. Wong wrote:
> > > On Sat, Sep 06, 2025 at 03:12:07AM -0500, A. Wilcox wrote:
> > > > When building xfsprogs with musl libc, strerror_r returns int as
> > > > specified in POSIX. This differs from the glibc extension that returns
> > > > char*. Successful calls will return 0, which will be dereferenced as a
> > > > NULL pointer by (v)fprintf.
> > > >
> > > > Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
> > >
> > > Isn't C fun?
> > > Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
> >
> > Ohh yes it is, this patch broke the build for me:
>
> do you build gcc + musl?
I don't even know /how/ to do that, even on Debian.
--D
> - Andrey
>
> >
> > common.c: In function ‘__str_out’:
> > common.c:129:17: error: ignoring return value of ‘strerror_r’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
> > 129 | strerror_r(error, buf, DESCR_BUFSZ);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > <sigh> xfsprogs can't get the XSI version because it defines GNU_SOURCE,
> > and you can't shut up gcc by casting the whole expression to void.
> >
> > Do you folks remove the -D_GNU_SOURCE from builddefs.in when building
> > against musl? Or do you leave the definition alone, taking advantage of
> > the fact that #define'ing a symbol is not a guarantee of functionality?
> >
> > --D
> >
> > > --D
> > >
> > > > ---
> > > > scrub/common.c | 3 ++-
> > > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/scrub/common.c b/scrub/common.c
> > > > index 14cd677b..9437d0ab 100644
> > > > --- a/scrub/common.c
> > > > +++ b/scrub/common.c
> > > > @@ -126,7 +126,8 @@ __str_out(
> > > > fprintf(stream, "%s%s: %s: ", stream_start(stream),
> > > > _(err_levels[level].string), descr);
> > > > if (error) {
> > > > - fprintf(stream, _("%s."), strerror_r(error, buf, DESCR_BUFSZ));
> > > > + strerror_r(error, buf, DESCR_BUFSZ);
> > > > + fprintf(stream, _("%s."), buf);
> > > > } else {
> > > > va_start(args, format);
> > > > vfprintf(stream, format, args);
> > > > --
> > > > 2.49.0
> > > >
> > > >
> > >
> >
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-19 16:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-06 8:12 [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r A. Wilcox
2025-09-12 7:14 ` Christoph Hellwig
2025-09-12 15:00 ` Darrick J. Wong
2025-09-18 16:27 ` Darrick J. Wong
2025-09-19 10:52 ` Andrey Albershteyn
2025-09-19 16:25 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox