[dpdk-dev] [PATCH] eal: fix API to get error string

Thomas Monjalon thomas at monjalon.net
Wed Oct 31 18:16:20 CET 2018


31/10/2018 18:19, Ferruh Yigit:
> rte_strerror uses strerror_r(), and strerror_r() has two version of it.
> - XSI-compliant version, (_POSIX_C_SOURCE >= 200112L) && !  _GNU_SOURCE
> - GNU-specific version
> 
> Those two has different return types, so the exiting return type check
> is not correct for GNU-specific version.
> 
> And this is causing failure in errno_autotest unit test.
> 
> Adding different implementation for FreeBSD and Linux.
> 
> Fixes: 016c32bd3e3d ("eal: cleanup strerror function")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit at intel.com>
> ---
> --- a/lib/librte_eal/common/eal_common_errno.c
> +++ b/lib/librte_eal/common/eal_common_errno.c
>  		default:
> +#ifdef RTE_EXEC_ENV_BSDAPP
>  			if (strerror_r(errnum, ret, RETVAL_SZ) != 0)
>  				snprintf(ret, RETVAL_SZ, "Unknown error%s %d",
>  						sep, errnum);
> +#else
> +			/*
> +			 * _GNU_SOURCE version, error string is not always
> +			 * strored in "ret" buffer, need to use return value
> +			 */
> +			ret = strerror_r(errnum, ret, RETVAL_SZ);
> +#endif

Why not use the return value in both cases?

Why not writing an error message in Linux case?





More information about the dev mailing list