FreeSWITCH: Add switch_strerror_r() to fix problems with XSI and GNU variants of strerror_r().

GNU variant of strerror_r() returns char *, while the XSI version returns int.

To make things worse, glibc ships both and added a unused result warning
in recent versions (2.16) causing the build to fail.

Add our own custom wrapper that always returns a pointer to the message buffer
and additionally make XSI versions of strerror_r() GNU compatible by
returning "Unknown error xxx" if no error message is available.

Fixes:
    src/switch_rtp.c: In function 'rtp_common_read':
    src/switch_rtp.c:3313:15: error: ignoring return value of 'strerror_r',
    declared with attribute warn_unused_result [-Werror=unused-result]
    cc1: all warnings being treated as errors

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This commit is contained in:
Stefan Knoblich
2012-08-14 14:11:44 +02:00
parent 3d9d42b798
commit 8bcf3b4fb8
4 changed files with 44 additions and 2 deletions
+10
View File
@@ -837,6 +837,16 @@ SWITCH_DECLARE(char *) switch_format_number(const char *num);
SWITCH_DECLARE(unsigned int) switch_atoui(const char *nptr);
SWITCH_DECLARE(unsigned long) switch_atoul(const char *nptr);
/**
* Portable version of strerror_r(), work around for the incompatible
* return type of GNU and XSI variants.
* \param[in] errnum Error number
* \param[both] buf Buffer for error message
* \param[in] buflen Size of message buffer
* \return Pointer to message buffer, returning error message or "Unknown error xxx" if none found
*/
SWITCH_DECLARE(char *) switch_strerror_r(int errnum, char *buf, switch_size_t buflen);
SWITCH_END_EXTERN_C
#endif
/* For Emacs: