]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: Use POSIX-conformant strerror_r
authorA. Wilcox <AWilcox@Wilcox-Tech.com>
Sat, 6 Sep 2025 08:12:07 +0000 (03:12 -0500)
committerAndrey Albershteyn <aalbersh@kernel.org>
Thu, 18 Sep 2025 10:09:05 +0000 (12:09 +0200)
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
scrub/common.c

index 14cd677ba5e9c440d64fc0c81017698478879f95..9437d0abb8698b437a2f64b75c8a67ab4cfc98c7 100644 (file)
@@ -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);