From a293512f6050085dfe56ef95078af71730df186a Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Mon, 13 Aug 2012 21:30:10 -0500 Subject: [PATCH 1/4] FS-4219 --resolve --- libs/win32/util.vbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/win32/util.vbs b/libs/win32/util.vbs index a6f3cf835d..e7815da529 100644 --- a/libs/win32/util.vbs +++ b/libs/win32/util.vbs @@ -376,7 +376,7 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest) If strLastCommit <> "" And strLastCommitHuman <> "" And strRevision <> "" Then 'Bild version string strGitVer = "git~" & strLastCommit & "~" & strRevision - strVerHuman = "; git at commit " & strRevision & " on " & strLastCommitHuman + strVerHuman = strVerRev & "; git at commit " & strRevision & " on " & strLastCommitHuman 'Check for local changes, if found, append to git revision string If ShowUnclean Then From 3d9d42b7980be68f7090193d800f94dbd003af47 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Mon, 13 Aug 2012 21:31:46 -0500 Subject: [PATCH 2/4] FS-4517 --resolve --- libs/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/.gitignore b/libs/.gitignore index 786ae26637..98fdf1df61 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -880,6 +880,7 @@ missing /yaml/tests/run-parser /yaml/tests/run-scanner /zeromq-*/ +/jpeg-8d/ # build products we should remove !/apr-util/xml/expat/conftools/config.guess From 8bcf3b4fb858a838e5a623ec417a93540fa43f2b Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Tue, 14 Aug 2012 14:11:44 +0200 Subject: [PATCH 3/4] 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 --- configure.in | 7 +++++++ src/include/switch_utils.h | 10 ++++++++++ src/switch_rtp.c | 4 ++-- src/switch_utils.c | 25 +++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 0345dd208c..87d868b7a0 100644 --- a/configure.in +++ b/configure.in @@ -495,6 +495,13 @@ AC_CHECK_FUNCS([gethostname vasprintf mmap mlock mlockall usleep getifaddrs time AC_CHECK_FUNCS([sched_setscheduler setpriority setrlimit setgroups initgroups]) AC_CHECK_FUNCS([wcsncmp setgroups asprintf setenv pselect gettimeofday localtime_r gmtime_r strcasecmp stricmp _stricmp]) +# Check availability and return type of strerror_r +# (NOTE: apr-1-config sets -D_GNU_SOURCE at build-time, need to run the check with it too) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" +AC_FUNC_STRERROR_R +CPPFLAGS="$save_CPPFLAGS" + AX_HAVE_CPU_SET AC_CHECK_LIB(rt, clock_gettime, [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])]) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 40560a0434..6b1824a153 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -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: diff --git a/src/switch_rtp.c b/src/switch_rtp.c index f0749d8087..1c23efc714 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -3310,8 +3310,8 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ if (!SWITCH_STATUS_IS_BREAK(poll_status) && poll_status != SWITCH_STATUS_TIMEOUT) { char tmp[128] = ""; - strerror_r(poll_status, tmp, sizeof(tmp)); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Poll failed with error: %d [%s]\n", poll_status, tmp); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Poll failed with error: %d [%s]\n", + poll_status, switch_strerror_r(poll_status, tmp, sizeof(tmp))); ret = -1; goto end; } diff --git a/src/switch_utils.c b/src/switch_utils.c index 157ce177f2..b0c4e1a287 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -2968,6 +2968,31 @@ SWITCH_DECLARE(unsigned long) switch_atoul(const char *nptr) else return (unsigned long) tmp; } + +SWITCH_DECLARE(char *) switch_strerror_r(int errnum, char *buf, switch_size_t buflen) +{ +#ifdef HAVE_STRERROR_R +#ifdef STRERROR_R_CHAR_P + /* GNU variant returning char *, avoids warn-unused-result error */ + return strerror_r(errnum, buf, buflen); +#else + /* + * XSI variant returning int, with GNU compatible error string, + * if no message could be found + */ + if (strerror_r(errnum, buf, buflen)) { + switch_snprintf(buf, buflen, "Unknown error %d", errnum); + } + return buf; +#endif /* STRERROR_R_CHAR_P */ +#else + /* Fallback, copy string into private buffer */ + switch_copy_string(buf, strerror(errnum), buflen); + return buf; +#endif +} + + /* For Emacs: * Local Variables: * mode:c From eca5c0ad73b60cd4a3408454ea920f356ef83b19 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Tue, 14 Aug 2012 14:54:06 +0200 Subject: [PATCH 4/4] FreeSWITCH: Add WIN32 strerror_s() variant to custom switch_strerror_r() helper function and fix more strerror_r() users. Convert mod_xml_cdr, mod_json_cdr and mod_conference to the new function. Signed-off-by: Stefan Knoblich --- .../applications/mod_conference/mod_conference.c | 8 ++------ .../event_handlers/mod_json_cdr/mod_json_cdr.c | 16 ++++------------ src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c | 16 ++++------------ src/switch_utils.c | 6 ++++++ 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index fccdefd46e..bc60091964 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1029,12 +1029,8 @@ static void conference_cdr_render(conference_obj_t *conference) fd = -1; } else { char ebuf[512] = { 0 }; -#ifdef WIN32 - strerror_s(ebuf, sizeof(ebuf), errno); -#else - strerror_r(errno, ebuf, sizeof(ebuf)); -#endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", + path, switch_strerror_r(errno, ebuf, sizeof(ebuf))); } diff --git a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c index e07871b88d..7b1cf2a6a9 100644 --- a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c +++ b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c @@ -253,12 +253,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) } } else { char ebuf[512] = { 0 }; -#ifdef WIN32 - strerror_s(ebuf, sizeof(ebuf), errno); -#else - strerror_r(errno, ebuf, sizeof(ebuf)); -#endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", + path, switch_strerror_r(errno, ebuf, sizeof(ebuf))); } switch_safe_free(path); } @@ -412,12 +408,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) break; } else { char ebuf[512] = { 0 }; -#ifdef WIN32 - strerror_s(ebuf, sizeof(ebuf), errno); -#else - strerror_r(errno, ebuf, sizeof(ebuf)); -#endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s! [%s]\n", path, ebuf); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s! [%s]\n", + path, switch_strerror_r(errno, ebuf, sizeof(ebuf))); } diff --git a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c index 44379444e3..28f4ae2e44 100644 --- a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c +++ b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c @@ -244,12 +244,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) fd = -1; } else { char ebuf[512] = { 0 }; -#ifdef WIN32 - strerror_s(ebuf, sizeof(ebuf), errno); -#else - strerror_r(errno, ebuf, sizeof(ebuf)); -#endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", + path, switch_strerror_r(errno, ebuf, sizeof(ebuf))); } switch_safe_free(path); } @@ -400,12 +396,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) fd = -1; } else { char ebuf[512] = { 0 }; -#ifdef WIN32 - strerror_s(ebuf, sizeof(ebuf), errno); -#else - strerror_r(errno, ebuf, sizeof(ebuf)); -#endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error![%s]\n", ebuf); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error![%s]\n", + switch_strerror_r(errno, ebuf, sizeof(ebuf))); } } } diff --git a/src/switch_utils.c b/src/switch_utils.c index b0c4e1a287..d877061e39 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -2985,6 +2985,12 @@ SWITCH_DECLARE(char *) switch_strerror_r(int errnum, char *buf, switch_size_t bu } return buf; #endif /* STRERROR_R_CHAR_P */ +#elif defined(WIN32) + /* WIN32 variant */ + if (strerror_s(buf, buflen, errnum)) { + switch_snprintf(buf, buflen, "Unknown error %d", errnum); + } + return buf; #else /* Fallback, copy string into private buffer */ switch_copy_string(buf, strerror(errnum), buflen);