DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>,
	stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] eal: fix API to get error string
Date: Thu, 1 Nov 2018 12:46:35 +0000	[thread overview]
Message-ID: <4957093e-f4f5-4c5b-27eb-bb1a86d6f74e@intel.com> (raw)
In-Reply-To: <1852957.HSzrH3FQxP@xps>

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 <ferruh.yigit@intel.com>
>>>>> ---
>>>>> --- 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.

> 
> 
>> strerror_r() not portable. An alternative can be not using it at all...
> 
> It's fine to use it.
> 
> 

  reply	other threads:[~2018-11-01 12:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 17:19 Ferruh Yigit
2018-10-31 17:16 ` 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 [this message]
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 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4957093e-f4f5-4c5b-27eb-bb1a86d6f74e@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).