patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] eal: fix API to get error string
@ 2018-10-31 17:19 Ferruh Yigit
  2018-10-31 17:16 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Ferruh Yigit @ 2018-10-31 17:19 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Ferruh Yigit, stable

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@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@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);
+#endif
 		}
 
 	return ret;
-- 
2.17.2

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-11-02 17:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31 17:19 [dpdk-stable] [PATCH] eal: fix API to get error string Ferruh Yigit
2018-10-31 17:16 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
2018-10-31 18:26   ` Ferruh Yigit
2018-10-31 18:26     ` Ferruh Yigit
2018-10-31 18:43       ` Thomas Monjalon
2018-11-01 12:46         ` Ferruh Yigit
2018-11-01 13:40           ` Thomas Monjalon
2018-11-01 13:44             ` Ferruh Yigit
2018-11-02 16:05             ` Ferruh Yigit
2018-11-02  9:51 ` Jerin Jacob
2018-11-02 15:39   ` Ferruh Yigit
2018-11-02 15:45     ` Jerin Jacob
2018-11-02 15:49       ` Ferruh Yigit
2018-11-02 17:00       ` Ferruh Yigit
2018-11-02 17:19 ` [dpdk-stable] " Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).