From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 917051B3A3; Thu, 1 Nov 2018 14:40:31 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3B500224AE; Thu, 1 Nov 2018 09:40:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 01 Nov 2018 09:40:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=RyWw1GL5CbTG7t6JgSJg/sVQww2NwfHTwQtCvm1slog=; b=TG1yFAbM3FyX gfG0wVFWqoXWbHd64Knx1ihlNJVdWKfdS/nDxL85mqgizIIXKc8p+uDmryaGsMVQ oebgSSCNHDs/2OdvMQVuifDrpqUd6LnlEPeKVqoLqLTP1M2mch+TPq0Q2m3jMY0Q /PGckSNedGms0QNvxapuUtf3H5Q9efg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=RyWw1GL5CbTG7t6JgSJg/sVQww2NwfHTwQtCvm1sl og=; b=S9S1RFeKS2jNBWlkYKrREpqMQNMe6+ZnjNBbxIKx/n0JKsoXnU/RWSGjA 141VKTaAult3C2BPQo+ZzXY0Rll2cKa4rxwFzcT/EzsorU32tPWs1E1GHOjEGRZ8 yqWM3VLJh4aPMKkcGCP4KtpWo3dUPlrYFz9O9HWudQo4a/xSrUJ7oodvnnpZW2ZM 8xIBF/pJMVycFF6jcWeXQNjLLmlIe4DvGT0mKeqxsWkk0ADvMhsVWCpBd8LjCeaY FJFyrDM1i6R/fNn1dyx80AUVFp5gJwIaYalZsOCDeyBWr0Z5FBPW55vLErGXQhym X9uY8IpmDfnMcQLXq8tegYNzAfbsA== X-ME-Sender: X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 226CE103AB; Thu, 1 Nov 2018 09:40:30 -0400 (EDT) From: Thomas Monjalon To: Ferruh Yigit Cc: dev@dpdk.org, Bruce Richardson , stable@dpdk.org Date: Thu, 01 Nov 2018 14:40:29 +0100 Message-ID: <2447028.TNc9xFLSYW@xps> In-Reply-To: <4957093e-f4f5-4c5b-27eb-bb1a86d6f74e@intel.com> References: <20181031171928.61110-1-ferruh.yigit@intel.com> <1852957.HSzrH3FQxP@xps> <4957093e-f4f5-4c5b-27eb-bb1a86d6f74e@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] eal: fix API to get error string X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2018 13:40:31 -0000 01/11/2018 13:46, Ferruh Yigit: > On 10/31/2018 6:43 PM, Thomas Monjalon wrote: > > 31/10/2018 19:26, Ferruh Yigit: > >> On 10/31/2018 6:26 PM, Ferruh Yigit wrote: > >>> On 10/31/2018 5:16 PM, Thomas Monjalon wrote: > >>>> 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@dpdk.org > >>>>> > >>>>> Signed-off-by: Ferruh Yigit > >>>>> --- > >>>>> --- 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? > >>> > >>> "man strerror_r" has more details, but briefly, > >>> > >>> The XSI-compliant strerror_r() function returns 0 on success. GNU one returns > >>> the pointer to string. > >>> > >>> The XSI-compliant can return an empty buffer, GNU one always return a string, > >>> either proper error string or "Unknown .." one. > > > > You say "GNU one always return a string" > > The comment says: > > _GNU_SOURCE version, error string is not always strored in "ret" buffer > > Yes, GNU one always return a char pointer to a string but that pointer may not > be in the "ret" buffer. OK So I suggest only 2 minor changes: - strored -> stored - add a comment to explain that the error message from return value is enough > >> strerror_r() not portable. An alternative can be not using it at all... > > > > It's fine to use it.