summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>2016-08-29 15:24:51 +0200
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-08-29 20:03:52 +0200
commit3f79cf87485bd25a1ae958a18c27266af1b36272 (patch)
tree5938698df418bfa8cc63fcfd6ba7bf5c9c6d41d8
parent3791ed5fe02d9f330e1b981c53ae169f6fdb271f (diff)
eina: fix behaviour break of eina_error_msg_get()
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.
-rw-r--r--src/lib/eina/eina_error.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/eina/eina_error.c b/src/lib/eina/eina_error.c
index 79c934afdb..779739d4ea 100644
--- a/src/lib/eina/eina_error.c
+++ b/src/lib/eina/eina_error.c
@@ -315,8 +315,13 @@ eina_error_msg_get(Eina_Error error)
315 315
316#ifdef HAVE_STRERROR_R 316#ifdef HAVE_STRERROR_R
317# ifndef STRERROR_R_CHAR_P 317# ifndef STRERROR_R_CHAR_P
318 if (strerror_r(error, buf, sizeof(buf)) == 0) /* XSI */ 318 int ret;
319
320 ret = strerror_r(error, buf, sizeof(buf)); /* XSI */
321 if (ret == 0)
319 str = buf; 322 str = buf;
323 else if (ret == EINVAL)
324 return NULL;
320# else /* STRERROR_R_CHAR_P */ 325# else /* STRERROR_R_CHAR_P */
321 str = strerror_r(error, buf, sizeof(buf)); /* GNU */ 326 str = strerror_r(error, buf, sizeof(buf)); /* GNU */
322# endif /* ! STRERROR_R_CHAR_P */ 327# endif /* ! STRERROR_R_CHAR_P */