Summary: strerror_r() does not exist on Windows, but strerror_s() does
Test Plan: compilation
Reviewers: cedric, bu5hm4n, zmike
Reviewed By: zmike
Subscribers: zmike, bu5hm4n, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8279
eina_error_msg_get() must return NULL if an incorrect error is provided.
The XSI strerror_r() returns EINVAL when an invalid error is passed to
it, so we can end the function here. If we kept on, we would have tested
against the 'unknown_prefix' ("Unknown error ") which is implementation
defined, and registered a new error when the invalid error message
didn't match the 'unknown_prefix'. This new error message would have
been returned, which is not what we expected.
This case arised on Mac OS X where the 'unkwown prefix' is
"Unknown error: " instead of "Unknown error ".
It fixes eina test suite on Mac OS X.
As pointed out in the mailing list, it was introduced in this release,
so it's better to remove the symbol instead of deprecating it.
People should use ETIMEDOUT directly.
So, first, the wrong strerror_r() was detected on
Mac OS X. Instead of using a complex set of macros
to try to detect which strerror_r() to use, when
it is defined, let the autotools handle that clerverness
for us.
we have some duplication of errors between Eina_Error and errno.h,
however we should use Eina_Error to extend the traditional errno.h
system.
then change eina_error_msg_register() and
eina_error_msg_static_register() to return a magic bit to state the
number was registered, and on other functions test this bit in order
to operate on registered values, otherwise fallback to errno.h, such
as strerror().
It also deprecates 2 clear duplicated errors:
- EINA_ERROR_OUT_OF_MEMORY -> ENOMEM
- EINA_ERROR_TIMEOUT -> ETIMEDOUT
There are two details when using strerror():
- old behavior did not return strings for non-error, such as
"Success" or "Unknown error ${N}"
- thread-safety issues: since we must be thread safe, then use
strerror_r() and eina_stringshare_add() that value, keeping a hash
of cached values