From 3f79cf87485bd25a1ae958a18c27266af1b36272 Mon Sep 17 00:00:00 2001 From: Jean Guyomarc'h Date: Mon, 29 Aug 2016 15:24:51 +0200 Subject: [PATCH] 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. --- src/lib/eina/eina_error.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/eina/eina_error.c b/src/lib/eina/eina_error.c index 79c934a..779739d 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) #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 */ -- 2.7.4