Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
	Andrey Albershteyn <aalbersh@redhat.com>,
	"A. Wilcox" <AWilcox@wilcox-tech.com>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2] xfs_scrub: fix strerror_r usage yet again
Date: Thu, 25 Sep 2025 00:23:48 -0700	[thread overview]
Message-ID: <aNTuBDBU4q42J03E@infradead.org> (raw)
In-Reply-To: <20250924005353.GW8096@frogsfrogsfrogs>

On Tue, Sep 23, 2025 at 05:53:53PM -0700, Darrick J. Wong wrote:
> On Mon, Sep 22, 2025 at 10:01:17AM -0700, Christoph Hellwig wrote:
> > The autoconf maigc looks good (as good as autoconf can look anyway),
> > but why is this code using strerror_r to start with?  AFAIK on Linux
> > strerror is using thread local storage since the damn of time, so
> > just doing this as:
> > 
> > 	fprintf(stream, _("%s."), strerror(error));
> > 
> > should be perfectly fine, while also simpler and more portable.
> 
> But there's no guarantee that the implementation does this, is there?
> The manpage doesn't say anything like that.

To me this pretty clear reads that the return string is stable until
the next call to strerror as long as you only use it in the calling
thread:

"The strerror() function returns a pointer to a string that describes
the error code passed in the argument errnum,  ...
This string must not be modified by the application, and the returned
pointer will be invalidated on a subsequent call to strerror() or
strerror_l(), or if the thread that obtained the string exits.  No
other library function, including perror(3), will modify this string."


  reply	other threads:[~2025-09-25  7:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19 16:14 [PATCH v2] xfs_scrub: fix strerror_r usage yet again Darrick J. Wong
2025-09-20 11:21 ` A. Wilcox
2025-09-22 17:01 ` Christoph Hellwig
2025-09-24  0:53   ` Darrick J. Wong
2025-09-25  7:23     ` Christoph Hellwig [this message]
2025-09-25 20:04       ` Darrick J. Wong
2025-09-25 20:58         ` Holger Hoffstätte
2025-09-26 16:27           ` Darrick J. Wong
2025-10-03 10:07             ` Andrey Albershteyn
2025-09-29  6:34         ` Christoph Hellwig

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=aNTuBDBU4q42J03E@infradead.org \
    --to=hch@infradead.org \
    --cc=AWilcox@wilcox-tech.com \
    --cc=aalbersh@redhat.com \
    --cc=djwong@kernel.org \
    --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