Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: "A. Wilcox" <AWilcox@wilcox-tech.com>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r
Date: Fri, 19 Sep 2025 09:25:05 -0700	[thread overview]
Message-ID: <20250919162505.GP8096@frogsfrogsfrogs> (raw)
In-Reply-To: <sgkgqvif3vdcmgd357pvupw7uqiyirtpp55gq6t2adb2csbltm@5tbqs6ilgmvn>

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
> > > > 
> > > > 
> > > 
> > 
> 
> 

      reply	other threads:[~2025-09-19 16:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20250919162505.GP8096@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=AWilcox@wilcox-tech.com \
    --cc=aalbersh@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /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