From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7AFC691; Wed, 31 Oct 2018 17:19:45 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2018 09:19:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,447,1534834800"; d="scan'208";a="276036470" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.212]) by fmsmga005.fm.intel.com with ESMTP; 31 Oct 2018 09:19:43 -0700 From: Ferruh Yigit To: Bruce Richardson Cc: dev@dpdk.org, Ferruh Yigit , stable@dpdk.org Date: Wed, 31 Oct 2018 17:19:28 +0000 Message-Id: <20181031171928.61110-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-stable] [PATCH] eal: fix API to get error string X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2018 16:19:46 -0000 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 --- 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