From d193789a2cb6a5b706952fd0e0ad7f0794c2914d Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Mon, 30 May 2011 00:07:32 -0500 Subject: [PATCH] fix several problems discovered with code analysis --- src/include/switch_utils.h | 6 +++--- src/switch_core_session.c | 8 ++++++-- src/switch_utils.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 88c13379b3..f798e92386 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -793,9 +793,9 @@ SWITCH_DECLARE(int) switch_split_user_domain(char *in, char **user, char **domai /* malloc or DIE macros */ #ifdef NDEBUG -#define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%s", __FILE__, __LINE__),abort(), 0), ptr ) -#define switch_zmalloc(ptr, len) (void)( (!!(ptr = calloc(1, (len)))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%s", __FILE__, __LINE__),abort(), 0), ptr) -#define switch_strdup(ptr, s) (void)( (!!(ptr = strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%s", __FILE__, __LINE__),abort(), 0), ptr) +#define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr ) +#define switch_zmalloc(ptr, len) (void)( (!!(ptr = calloc(1, (len)))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) +#define switch_strdup(ptr, s) (void)( (!!(ptr = strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr) #else #if (_MSC_VER >= 1500) // VC9+ #define switch_malloc(ptr, len) (void)(assert(((ptr) = malloc((len)))),ptr);__analysis_assume( ptr ) diff --git a/src/switch_core_session.c b/src/switch_core_session.c index ade22d2f32..ea07a7805e 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -616,6 +616,10 @@ static const char *message_names[] = { "APPLICATION_EXEC_COMPLETE", "PHONE_EVENT", "T38_DESCRIPTION" + "UDPTL_MODE", + "CLEAR_PROGRESS", + "JITTER_BUFFER", + "RECOVERY_REFRESH", "INVALID" }; @@ -644,8 +648,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(swit message->_line = line; } - if (message->message_id > SWITCH_MESSAGE_INVALID) { - message->message_id = SWITCH_MESSAGE_INVALID; + if (message->message_id > SWITCH_MESSAGE_INVALID-1) { + message->message_id = SWITCH_MESSAGE_INVALID-1; } switch_log_printf(SWITCH_CHANNEL_ID_LOG, message->_file, message->_func, message->_line, diff --git a/src/switch_utils.c b/src/switch_utils.c index 99d1d98275..906a02eba6 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -2669,7 +2669,7 @@ SWITCH_DECLARE(switch_bool_t) switch_dow_cmp(const char *exp, int val) /* Save the previous token and move to the next one */ range_start = prev; } else if (cur == DOW_ERR) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse error for [%s] at position %td (%.6s)\n", exp, p - exp, p); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse error for [%s] at position %ld (%.6s)\n", exp, (long) (p - exp), p); break; } else { /* Valid day found */