提交 fc341792 authored 作者: Michael Jerris's avatar Michael Jerris

turn on higher warning level in msvc for the core and libteletone and resolve warnings.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@634 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 8d1967d7
......@@ -46,7 +46,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
......@@ -107,7 +107,7 @@
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
......
......@@ -267,7 +267,7 @@ int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
int sample;
int best_row;
int best_col;
int hit;
char hit;
int limit;
hit = 0;
......
......@@ -76,7 +76,7 @@ int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_ha
ts->user_data = user_data;
ts->volume = 1500;
ts->decay_step = 0;
if (!(ts->buffer = calloc(buflen, sizeof(teletone_audio_t)))) {
if ((ts->buffer = calloc(buflen, sizeof(teletone_audio_t))) == 0) {
return -1;
}
ts->datalen = buflen;
......@@ -220,7 +220,7 @@ int teletone_run(teletone_generation_session_t *ts, char *cmd)
continue;
}
if ((end = strchr(cur, ';'))) {
if ((end = strchr(cur, ';')) != 0) {
*end++ = '\0';
}
......@@ -283,11 +283,11 @@ int teletone_run(teletone_generation_session_t *ts, char *cmd)
if (*cur) {
char *next;
int i = 0;
if ((e = strchr(p, ')'))) {
if ((e = strchr(p, ')')) != 0) {
*e++ = '\0';
}
do {
if ((next = strchr(p, ','))) {
if ((next = strchr(p, ',')) != 0) {
*next++ = '\0';
}
if (i == 0) {
......
......@@ -76,6 +76,9 @@ extern "C" {
* @{
*/
typedef apr_size_t swtich_size_t;
typedef apr_int16_t switch_int16_t;
/**
* @defgroup switch_file_io File I/O Handling Functions
* @ingroup switch_apr
......
......@@ -80,7 +80,7 @@ SWITCH_DECLARE(int) switch_buffer_freespace(switch_buffer *buffer);
* \param buffer any buffer of type switch_buffer
* \return int ammount of buffer curently in use
*/
SWITCH_DECLARE(int) switch_buffer_inuse(switch_buffer *buffer);
SWITCH_DECLARE(size_t) switch_buffer_inuse(switch_buffer *buffer);
/*! \brief Read data from a switch_buffer up to the ammount of datalen if it is available. Remove read data from buffer.
* \param buffer any buffer of type switch_buffer
......
......@@ -249,7 +249,7 @@ SWITCH_DECLARE(switch_status) switch_channel_hangup(switch_channel *channel);
\param channel channel to test
\return number of digits in the queue
*/
SWITCH_DECLARE(int) switch_channel_has_dtmf(switch_channel *channel);
SWITCH_DECLARE(size_t) switch_channel_has_dtmf(switch_channel *channel);
/*!
\brief Queue DTMF on a given channel
......
......@@ -417,7 +417,7 @@ struct switch_codec_implementation {
/*! number of samples that denote one frame */
int samples_per_frame;
/*! number of bytes that denote one frame decompressed */
int bytes_per_frame;
size_t bytes_per_frame;
/*! number of bytes that denote one frame compressed */
int encoded_bytes_per_frame;
/*! number of channels represented */
......
......@@ -38,6 +38,10 @@
extern "C" {
#endif
#ifdef _MSC_VER
#pragma warning(disable:4152 4054 4100)
#endif
#if (_MSC_VER >= 1400) // VC8+
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
......
......@@ -123,7 +123,7 @@ SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char
\param pool the memory pool to use
\return SWITCH_STATUS_SUCCESS when successful
*/
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, unsigned int flags, switch_memory_pool *pool);
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, switch_int16_t flags, switch_memory_pool *pool);
/*!
\brief Wait for a socket
......
......@@ -41,8 +41,8 @@ SWITCH_DECLARE(switch_status) switch_buffer_create(switch_memory_pool *pool, swi
{
switch_buffer *new_buffer;
if ((new_buffer = switch_core_alloc(pool, sizeof(switch_buffer)))
&& (new_buffer->data = switch_core_alloc(pool, max_len))) {
if ((new_buffer = switch_core_alloc(pool, sizeof(switch_buffer))) != 0
&& (new_buffer->data = switch_core_alloc(pool, max_len)) != 0) {
new_buffer->datalen = max_len;
*buffer = new_buffer;
return SWITCH_STATUS_SUCCESS;
......@@ -67,7 +67,7 @@ SWITCH_DECLARE(int) switch_buffer_freespace(switch_buffer *buffer)
return (int) (buffer->datalen - buffer->used);
}
SWITCH_DECLARE(int) switch_buffer_inuse(switch_buffer *buffer)
SWITCH_DECLARE(size_t) switch_buffer_inuse(switch_buffer *buffer)
{
assert(buffer != NULL);
......
......@@ -42,7 +42,7 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_se
switch_caller_profile *profile = NULL;
if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile)))) {
if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile))) != 0) {
profile->dialplan = switch_core_session_strdup(session, dialplan);
profile->caller_id_name = switch_core_session_strdup(session, caller_id_name);
profile->caller_id_number = switch_core_session_strdup(session, caller_id_number);
......@@ -60,7 +60,7 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_
switch_caller_profile *tocopy)
{
switch_caller_profile *profile = NULL;
if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile)))) {
if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile))) != 0) {
profile->dialplan = switch_core_session_strdup(session, tocopy->dialplan);
profile->caller_id_name = switch_core_session_strdup(session, tocopy->caller_id_name);
profile->ani = switch_core_session_strdup(session, tocopy->ani);
......@@ -114,7 +114,7 @@ SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_cor
{
switch_caller_extension *caller_extension = NULL;
if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension)))) {
if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension))) != 0) {
caller_extension->extension_name = switch_core_session_strdup(session, extension_name);
caller_extension->extension_number = switch_core_session_strdup(session, extension_number);
caller_extension->current_application = caller_extension->last_application = caller_extension->applications;
......@@ -132,7 +132,7 @@ SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session
assert(session != NULL);
if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application)))) {
if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application))) != 0) {
caller_application->application_name = switch_core_session_strdup(session, application_name);
caller_application->application_data = switch_core_session_strdup(session, application_data);
if (!caller_extension->applications) {
......
......@@ -60,7 +60,7 @@ SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, swi
{
assert(pool != NULL);
if (!((*channel) = switch_core_alloc(pool, sizeof(switch_channel)))) {
if (((*channel) = switch_core_alloc(pool, sizeof(switch_channel))) == 0) {
return SWITCH_STATUS_MEMERR;
}
......@@ -112,9 +112,9 @@ SWITCH_DECLARE(switch_status) switch_channel_get_raw_mode(switch_channel *channe
}
SWITCH_DECLARE(int) switch_channel_has_dtmf(switch_channel *channel)
SWITCH_DECLARE(size_t) switch_channel_has_dtmf(switch_channel *channel)
{
int has;
size_t has;
assert(channel != NULL);
switch_mutex_lock(channel->dtmf_mutex);
......
......@@ -52,7 +52,7 @@ SWITCH_DECLARE(int) switch_config_open_file(switch_config *cfg, char *file_path)
path = path_buf;
}
if (!path || !(f = fopen(path, "r"))) {
if (!path || (f = fopen(path, "r")) == 0) {
return 0;
}
......@@ -93,7 +93,7 @@ SWITCH_DECLARE(int) switch_config_next_pair(switch_config *cfg, char **var, char
*var = cfg->buf;
if (**var == '[' && (end = strchr(*var, ']'))) {
if (**var == '[' && (end = strchr(*var, ']')) != 0) {
*end = '\0';
(*var)++;
switch_copy_string(cfg->category, *var, sizeof(cfg->category));
......@@ -109,10 +109,10 @@ SWITCH_DECLARE(int) switch_config_next_pair(switch_config *cfg, char **var, char
break;
}
if ((end = strchr(*var, '#'))) {
if ((end = strchr(*var, '#')) != 0) {
*end = '\0';
end--;
} else if ((end = strchr(*var, '\n'))) {
} else if ((end = strchr(*var, '\n')) != 0) {
if (*(end - 1) == '\r') {
end--;
}
......@@ -126,7 +126,7 @@ SWITCH_DECLARE(int) switch_config_next_pair(switch_config *cfg, char **var, char
}
*var = p;
if (!(*val = strchr(*var, '='))) {
if ((*val = strchr(*var, '=')) == 0) {
ret = -1;
//log_printf(0, server.log, "Invalid syntax on %s: line %d\n", cfg->path, cfg->lineno);
continue;
......
......@@ -66,11 +66,11 @@ static int switch_console_process(char *cmd)
return 1;
}
#endif
if ((arg = strchr(cmd, '\r')) || (arg = strchr(cmd, '\n'))) {
if ((arg = strchr(cmd, '\r')) != 0 || (arg = strchr(cmd, '\n')) != 0 ) {
*arg = '\0';
arg = NULL;
}
if ((arg = strchr(cmd, ' '))) {
if ((arg = strchr(cmd, ' ')) != 0) {
*arg++ = '\0';
}
if (switch_api_execute(cmd, arg, retbuf, sizeof(retbuf)) == SWITCH_STATUS_SUCCESS) {
......@@ -160,8 +160,8 @@ SWITCH_DECLARE(void) switch_console_loop(void)
}
memset(&cmd, 0, sizeof(cmd));
for (x = 0; sizeof(cmd); x++) {
cmd[x] = getchar();
for (x = 0; x < sizeof(cmd); x++) {
cmd[x] = (char)getchar();
if (cmd[x] == '\n') {
cmd[x] = '\0';
break;
......
差异被折叠。
......@@ -122,12 +122,12 @@ static int switch_events_match(switch_event *event, switch_event_node *node)
if (event->subclass && node->subclass) {
if (!strncasecmp(node->subclass->name, "file:", 5)) {
char *file_header;
if ((file_header = switch_event_get_header(event, "file"))) {
if ((file_header = switch_event_get_header(event, "file")) != 0) {
match = strstr(node->subclass->name + 5, file_header) ? 1 : 0;
}
} else if (!strncasecmp(node->subclass->name, "func:", 5)) {
char *func_header;
if ((func_header = switch_event_get_header(event, "function"))) {
if ((func_header = switch_event_get_header(event, "function")) != 0) {
match = strstr(node->subclass->name + 5, func_header) ? 1 : 0;
}
} else {
......@@ -221,7 +221,7 @@ SWITCH_DECLARE(switch_status) switch_event_reserve_subclass_detailed(char *owner
return SWITCH_STATUS_INUSE;
}
if (!(subclass = switch_core_alloc(RUNTIME_POOL, sizeof(*subclass)))) {
if ((subclass = switch_core_alloc(RUNTIME_POOL, sizeof(*subclass))) == 0) {
return SWITCH_STATUS_MEMERR;
}
......@@ -288,7 +288,7 @@ SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event,
return SWITCH_STATUS_GENERR;
}
if (!(*event = ALLOC(sizeof(switch_event)))) {
if ((*event = ALLOC(sizeof(switch_event))) == 0) {
return SWITCH_STATUS_MEMERR;
}
#ifdef MALLOC_EVENTS
......@@ -333,7 +333,7 @@ SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switc
} else {
switch_event_header *header, *hp;
if (!(header = ALLOC(sizeof(*header)))) {
if ((header = ALLOC(sizeof(*header))) == 0) {
return SWITCH_STATUS_MEMERR;
}
#ifdef MALLOC_EVENTS
......@@ -342,7 +342,7 @@ SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switc
header->name = DUP(header_name);
header->value = DUP(data);
if ((stack = SWITCH_STACK_TOP)) {
if (((stack = SWITCH_STACK_TOP)) != 0) {
header->next = event->headers;
event->headers = header;
} else {
......@@ -357,9 +357,6 @@ SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switc
return SWITCH_STATUS_SUCCESS;
}
return (ret >= 0) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
}
......@@ -379,9 +376,6 @@ SWITCH_DECLARE(switch_status) switch_event_add_body(switch_event *event, char *f
event->body = DUP(data);
return SWITCH_STATUS_SUCCESS;
}
return (ret >= 0) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
}
SWITCH_DECLARE(void) switch_event_destroy(switch_event **event)
......@@ -415,7 +409,7 @@ SWITCH_DECLARE(switch_status) switch_event_dup(switch_event **event, switch_even
(*event)->bind_user_data = todup->bind_user_data;
for (hp = todup->headers; hp && hp->next;) {
if (!(header = ALLOC(sizeof(*header)))) {
if ((header = ALLOC(sizeof(*header))) == 0) {
return SWITCH_STATUS_MEMERR;
}
#ifdef MALLOC_EVENTS
......@@ -546,8 +540,8 @@ SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event,
assert(RUNTIME_POOL != NULL);
if (subclass_name) {
if (!(subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) {
if (!(subclass = switch_core_alloc(RUNTIME_POOL, sizeof(*subclass)))) {
if ((subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name)) == 0) {
if ((subclass = switch_core_alloc(RUNTIME_POOL, sizeof(*subclass))) == 0) {
return SWITCH_STATUS_MEMERR;
} else {
subclass->owner = switch_core_strdup(RUNTIME_POOL, id);
......@@ -556,7 +550,7 @@ SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event,
}
}
if (event <= SWITCH_EVENT_ALL && (event_node = switch_core_alloc(RUNTIME_POOL, sizeof(switch_event_node)))) {
if (event <= SWITCH_EVENT_ALL && (event_node = switch_core_alloc(RUNTIME_POOL, sizeof(switch_event_node))) != 0) {
switch_mutex_lock(BLOCK);
/* <LOCKED> ----------------------------------------------- */
event_node->id = switch_core_strdup(RUNTIME_POOL, id);
......
......@@ -132,7 +132,7 @@ static switch_status switch_loadable_module_load_file(char *filename, switch_mem
break;
}
if (!(module = switch_core_permenant_alloc(sizeof(switch_loadable_module)))) {
if ((module = switch_core_permenant_alloc(sizeof(switch_loadable_module))) == 0) {
err = "Could not allocate memory\n";
break;
}
......@@ -201,7 +201,7 @@ static void process_module_file(char *dir, char *fname)
#endif
if (!(file = switch_core_strdup(loadable_modules.pool, fname))) {
if ((file = switch_core_strdup(loadable_modules.pool, fname)) == 0) {
return;
}
......@@ -405,7 +405,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
fname = finfo.name;
}
if (!(ptr = (char *) fname)) {
if ((ptr = (char *) fname) == 0) {
continue;
}
......@@ -512,7 +512,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool
switch_codec_interface *codec_interface;
for (x = 0; x < preflen; x++) {
if ((codec_interface = switch_loadable_module_get_codec_interface(prefs[x]))) {
if ((codec_interface = switch_loadable_module_get_codec_interface(prefs[x])) != 0 ) {
array[i++] = codec_interface;
}
}
......@@ -526,7 +526,7 @@ SWITCH_DECLARE(switch_status) switch_api_execute(char *cmd, char *arg, char *ret
switch_status status;
switch_event *event;
if ((api = switch_loadable_module_get_api_interface(cmd))) {
if ((api = switch_loadable_module_get_api_interface(cmd)) != 0) {
status = api->function(arg, retbuf, len);
} else {
status = SWITCH_STATUS_FALSE;
......
......@@ -53,7 +53,7 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
{
switch_audio_resampler *resampler;
if (!(resampler = switch_core_alloc(pool, sizeof(*resampler)))) {
if ((resampler = switch_core_alloc(pool, sizeof(*resampler))) == 0) {
return SWITCH_STATUS_MEMERR;
}
......
......@@ -75,7 +75,7 @@ SWITCH_DECLARE(char *) switch_cut_path(char *in)
for (i = delims; *i; i++) {
p = in;
while ((p = strchr(p, *i))) {
while ((p = strchr(p, *i)) != 0) {
ret = ++p;
}
}
......@@ -83,7 +83,7 @@ SWITCH_DECLARE(char *) switch_cut_path(char *in)
}
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock,
unsigned int flags, switch_memory_pool *pool)
switch_int16_t flags, switch_memory_pool *pool)
{
switch_pollset_t *pollset;
switch_status status;
......
......@@ -48,7 +48,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
......@@ -132,7 +132,7 @@
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;APR_DECLARE_EXPORT;APU_DECLARE_EXPORT;API_DECLARE_EXPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论