From 184f395553c12ace7c613e9b302879cd12ee063e Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Mon, 20 Sep 2010 09:25:14 -0500 Subject: [PATCH] fix several code analysis problems and mask several that are required --- libs/esl/src/esl.c | 3 +++ libs/esl/src/esl_config.c | 2 +- libs/esl/src/esl_event.c | 3 +++ libs/libteletone/src/libteletone_generate.c | 3 +++ src/include/switch.h | 3 +++ src/include/switch_utils.h | 12 ++++++++++++ src/mod/applications/mod_spandsp/mod_spandsp_dsp.c | 4 ++-- src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c | 2 +- src/switch_console.c | 2 +- 9 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c index 160fe2d759..75a52d6bd2 100644 --- a/libs/esl/src/esl.c +++ b/libs/esl/src/esl.c @@ -36,7 +36,10 @@ #define closesocket(x) close(x) #include #else +#pragma warning (disable:6386) +/* These warnings need to be ignored warning in sdk header */ #include +#pragma warning (default:6386) #endif diff --git a/libs/esl/src/esl_config.c b/libs/esl/src/esl_config.c index 4616356f7f..2e24007799 100644 --- a/libs/esl/src/esl_config.c +++ b/libs/esl/src/esl_config.c @@ -110,7 +110,7 @@ ESL_DECLARE(int) esl_config_next_pair(esl_config_t *cfg, char **var, char **val) *var = *val = NULL; - if (!cfg->path) { + if (!cfg || !cfg->file) { return 0; } diff --git a/libs/esl/src/esl_event.c b/libs/esl/src/esl_event.c index 2e1d8a302a..db7c581ee9 100644 --- a/libs/esl/src/esl_event.c +++ b/libs/esl/src/esl_event.c @@ -513,6 +513,9 @@ ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, es char *encode_buf = NULL; /* used for url encoding of variables to make sure unsafe things stay out of the serialized copy */ int clen = 0; + if (!event || !event->headers) + return ESL_FAIL; + *str = NULL; dlen = blocksize * 2; diff --git a/libs/libteletone/src/libteletone_generate.c b/libs/libteletone/src/libteletone_generate.c index 8098e3605c..3977ca521d 100644 --- a/libs/libteletone/src/libteletone_generate.c +++ b/libs/libteletone/src/libteletone_generate.c @@ -413,6 +413,9 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm *e++ = '\0'; } do { + if (!p) { + break; + } if ((next = strchr(p, ',')) != 0) { *next++ = '\0'; } diff --git a/src/include/switch.h b/src/include/switch.h index 7143c61d91..81684c59b0 100644 --- a/src/include/switch.h +++ b/src/include/switch.h @@ -91,7 +91,10 @@ #include #pragma warning(pop) #else +/* work around for warnings in vs 2010 */ +#pragma warning (disable:6386) #include +#pragma warning (default:6386) #endif #else #include diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 4dc7ed7f1b..45703ab49c 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -139,6 +139,9 @@ static inline char *switch_strchr_strict(const char *in, char find, const char * #define switch_is_valid_rate(_tmp) (_tmp == 8000 || _tmp == 12000 || _tmp == 16000 || _tmp == 24000 || _tmp == 32000 || _tmp == 11025 || _tmp == 22050 || _tmp == 44100 || _tmp == 48000) +#ifdef _MSC_VER +#pragma warning(disable:6011) +#endif static inline int switch_string_has_escaped_data(const char *in) { const char *i = strchr(in, '\\'); @@ -153,6 +156,9 @@ static inline int switch_string_has_escaped_data(const char *in) return 0; } +#ifdef _MSC_VER +#pragma warning(default:6011) +#endif SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size_t ilen, unsigned char *out, switch_size_t olen); SWITCH_DECLARE(switch_size_t) switch_b64_decode(char *in, char *out, switch_size_t olen); @@ -455,6 +461,9 @@ static inline char *switch_safe_strdup(const char *it) } +#ifdef _MSC_VER +#pragma warning(disable:6011) +#endif static inline char *switch_lc_strdup(const char *it) { char *dup; @@ -487,6 +496,9 @@ static inline char *switch_uc_strdup(const char *it) return NULL; } +#ifdef _MSC_VER +#pragma warning(default:6011) +#endif /*! diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c index 096d967ff0..aa7d05cf9e 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c @@ -549,8 +549,8 @@ static switch_status_t do_config(void) if (id == -1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unable to add tone_descriptor: %s, tone: %s. (too many tones)\n", name, tone_name); return SWITCH_STATUS_FALSE; - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Adding tone_descriptor: %s, tone: %s(%d)\n", name, tone_name, id);} + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Adding tone_descriptor: %s, tone: %s(%d)\n", name, tone_name, id); /* add elements to tone */ for (element = switch_xml_child(tone, "element"); element; element = switch_xml_next(element)) { const char *freq1_attr = switch_xml_attr(element, "freq1"); diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c index 139fe217a3..4b36e1435e 100644 --- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c +++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c @@ -2724,7 +2724,7 @@ static switch_status_t recog_asr_open(switch_asr_handle_t *ah, const char *codec name++; name = switch_core_sprintf(ah->memory_pool, "%s ASR-%d", name, speech_channel_number); } else { - name = switch_core_sprintf(ah->memory_pool, "ASR-%d", name, speech_channel_number); + name = switch_core_sprintf(ah->memory_pool, "ASR-%d", speech_channel_number); } /* Allocate the channel */ diff --git a/src/switch_console.c b/src/switch_console.c index 06a7e0de7a..9f13823198 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -493,7 +493,7 @@ static int comp_callback(void *pArg, int argc, char **argv, char **columnNames) argc = switch_separate_string(list, ':', argv, (sizeof(argv) / sizeof(argv[0]))); - for (i = 0; i < argc; i++) { + for (i = 0; (int)i < argc; i++) { if (!cur || !strncmp(argv[i], cur, strlen(cur))) { r_argv[0] = argv[i]; comp_callback(h, 1, r_argv, r_cols);