Re: [PATCH v11 6/9] app/test: differentiate a strerror on different OS
From: Dmitry Kozlyuk <hidden>
Date: 2021-12-04 01:33:41
2021-12-02 16:06 (UTC-0800), Jie Zhou:
On Windows, strerror returns just "Unknown error" for errnum greater than MAX_ERRNO, while linux and freebsd returns "Unknown error <num>", which is the current expectation for errno_autotest. Differentiate the error string on Windows to remove a "duplicate error code" failure. Signed-off-by: Jie Zhou <redacted> --- app/test/test_errno.c | 12 +++++++++++- lib/eal/common/eal_common_errno.c | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-)
[...]
quoted hunk ↗ jump to hunk
diff --git a/lib/eal/common/eal_common_errno.c b/lib/eal/common/eal_common_errno.c index f86802705a..4c4abb802e 100644 --- a/lib/eal/common/eal_common_errno.c +++ b/lib/eal/common/eal_common_errno.c@@ -37,7 +37,11 @@ rte_strerror(int errnum) /* since some implementations of strerror_r throw an error * themselves if errnum is too big, we handle that case here */ if (errnum >= RTE_MAX_ERRNO) +#ifdef RTE_EXEC_ENV_WINDOWS + snprintf(ret, RETVAL_SZ, "Unknown error%s", sep);
"sep" is not needed here, is it?
+#else
snprintf(ret, RETVAL_SZ, "Unknown error%s %d", sep, errnum);
+#endif
else
switch (errnum){
case E_RTE_SECONDARY: