forked from enlightenment/efl
eina_error: provide a fallback when strerror_r() is not available.
This commit is contained in:
parent
9348a84aa0
commit
602a98c8b9
|
@ -38,6 +38,7 @@
|
||||||
#include "eina_error.h"
|
#include "eina_error.h"
|
||||||
#include "eina_stringshare.h"
|
#include "eina_stringshare.h"
|
||||||
#include "eina_lock.h"
|
#include "eina_lock.h"
|
||||||
|
#include "eina_str.h"
|
||||||
#ifdef EINA_HAVE_THREADS
|
#ifdef EINA_HAVE_THREADS
|
||||||
#include "eina_hash.h"
|
#include "eina_hash.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -321,6 +322,16 @@ eina_error_msg_get(Eina_Error error)
|
||||||
# else /* STRERROR_R_CHAR_P */
|
# else /* STRERROR_R_CHAR_P */
|
||||||
str = strerror_r(error, buf, sizeof(buf)); /* GNU */
|
str = strerror_r(error, buf, sizeof(buf)); /* GNU */
|
||||||
# endif /* ! STRERROR_R_CHAR_P */
|
# endif /* ! STRERROR_R_CHAR_P */
|
||||||
|
#else
|
||||||
|
/* not so good fallback. Usually strerror(err) will
|
||||||
|
* return a const string if a known error (what we use),
|
||||||
|
* and will return a pointer to a global modified string
|
||||||
|
* formatted with "Unknown error XXXX".. which we just
|
||||||
|
* ignore... so while it's not super-correct, this
|
||||||
|
* should work well.
|
||||||
|
*/
|
||||||
|
eina_strlcpy(buf, strerror(error), sizeof(buf));
|
||||||
|
str = buf;
|
||||||
#endif /* HAVE_STRERROR_R */
|
#endif /* HAVE_STRERROR_R */
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
|
|
Loading…
Reference in New Issue