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.
#ifdef HAVE_STRERROR_R
# ifndef STRERROR_R_CHAR_P
- if (strerror_r(error, buf, sizeof(buf)) == 0) /* XSI */
+ int ret;
+
+ ret = strerror_r(error, buf, sizeof(buf)); /* XSI */
+ if (ret == 0)
str = buf;
+ else if (ret == EINVAL)
+ return NULL;
# else /* STRERROR_R_CHAR_P */
str = strerror_r(error, buf, sizeof(buf)); /* GNU */
# endif /* ! STRERROR_R_CHAR_P */