Re: [PATCH v2] xfs_scrub: Use POSIX-conformant strerror_r

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Isn't C fun?
Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>

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




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux