-----Original Message----- > Date: Wed, 31 Oct 2018 17:19:28 +0000 > From: Ferruh Yigit <ferruh.yi...@intel.com> > To: Bruce Richardson <bruce.richard...@intel.com> > CC: dev@dpdk.org, Ferruh Yigit <ferruh.yi...@intel.com>, sta...@dpdk.org > Subject: [dpdk-dev] [PATCH] eal: fix API to get error string > X-Mailer: git-send-email 2.17.2 > > External Email > > 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: sta...@dpdk.org > > Signed-off-by: Ferruh Yigit <ferruh.yi...@intel.com> > --- > lib/librte_eal/common/eal_common_errno.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/lib/librte_eal/common/eal_common_errno.c > b/lib/librte_eal/common/eal_common_errno.c > index 56b492f5f..fbbc71b0b 100644 > --- a/lib/librte_eal/common/eal_common_errno.c > +++ b/lib/librte_eal/common/eal_common_errno.c > @@ -38,9 +38,17 @@ rte_strerror(int errnum) > case E_RTE_NO_CONFIG: > return "Missing rte_config structure"; > 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);
Probably this will fail in musl c version. https://git.musl-libc.org/cgit/musl/tree/src/string/strerror_r.c Another alternative of this patch. http://patches.dpdk.org/patch/47706/ > +#endif > } > > return ret; > -- > 2.17.2 >