xfs_scrub: Use POSIX-conformant strerror_r
PATCH 1/1 xfs_scrub: Use POSIX-conformant strerror_r
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 <[email protected]>
--- scrub/common.c | 3 ++- scrub/inodes.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
scrub/common.c +2 -1
@@ -122,7 +122,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);
scrub/inodes.c +2 -2
@@ -65,9 +65,9 @@ bulkstat_for_inumbers( error = -xfrog_bulkstat (&ctx->mnt, breq);if (error) {char errbuf[DESCR_BUFSZ ]; +strerror_r (error, errbuf,DESCR_BUFSZ ); -str_info (ctx,descr_render (dsc),"%s" , -strerror_r (error, errbuf,DESCR_BUFSZ )); +str_info (ctx,descr_render (dsc),"%s" , errbuf); }/*
Signature · 1 line
2.40.0
scrub/inodes.c bulkstat_for_inumbers( · line 70
Quoted 10 lines
+++
b/scrub/inodes.cscrub/inodes.c +2
-2@@ -65,9 +65,9 @@ bulkstat_for_inumbers( error = -xfrog_bulkstat (&ctx->mnt, breq);if (error) {char errbuf[DESCR_BUFSZ ]; +strerror_r (error, errbuf,DESCR_BUFSZ ); -str_info (ctx,descr_render (dsc),"%s" , -strerror_r (error, errbuf,DESCR_BUFSZ )); +str_info (ctx,descr_render (dsc),"%s" , errbuf);
Please keep an empty line after the variable declaration. I'd skip the one between the strerror_r and str_info calls instead, though.
Otherwise this looks good to me.