FS-2216 partial with renaming

This commit is contained in:
Jeff Lenk 2012-01-08 14:19:16 -06:00
parent bcf7d477e2
commit 24288832b1
16 changed files with 52 additions and 67 deletions

View File

@ -285,7 +285,7 @@ ESL_DECLARE(char *)esl_event_get_body(esl_event_t *event)
ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const char *header_name, const char *val)
{
esl_event_header_t *hp, *lp = NULL, *tp;
esl_status_t status = ESL_FALSE;
esl_status_t status = (esl_status_t) ESL_FALSE;
int x = 0;
esl_ssize_t hlen = -1;
unsigned long hash = 0;
@ -875,12 +875,12 @@ ESL_DECLARE(esl_status_t) esl_event_create_json(esl_event_t **event, const char
if (!(cj = cJSON_Parse(json))) {
return ESL_FALSE;
return (esl_status_t) ESL_FALSE;
}
if (esl_event_create(&new_event, ESL_EVENT_CLONE) != ESL_SUCCESS) {
cJSON_Delete(cj);
return ESL_FALSE;
return (esl_status_t) ESL_FALSE;
}
for (cjp = cj->child; cjp; cjp = cjp->next) {

View File

@ -834,6 +834,9 @@ SWITCH_DECLARE(const char *) switch_inet_ntop(int af, void const *src, char *dst
SWITCH_DECLARE(char *) switch_uuid_str(char *buf, switch_size_t len);
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);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:

View File

@ -6375,7 +6375,7 @@ SWITCH_STANDARD_APP(conference_function)
uint32_t max_members_val;
errno = 0; /* sanity first */
max_members_val = strtol(max_members_str, NULL, 0); /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */
if (errno == ERANGE || errno == EINVAL || max_members_val < 0 || max_members_val == 1) {
if (errno == ERANGE || errno == EINVAL || (int32_t) max_members_val < 0 || max_members_val == 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"conference_max_members variable %s is invalid, not setting a limit\n", max_members_str);
} else {
@ -7106,7 +7106,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
} else if (!strcasecmp(var, "max-members") && !zstr(val)) {
errno = 0; /* sanity first */
max_members = strtol(val, NULL, 0); /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */
if (errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) {
if (errno == ERANGE || errno == EINVAL || (int32_t) max_members < 0 || max_members == 1) {
/* a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound
* stuff is added, see comments above
*/

View File

@ -597,7 +597,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_db_load)
switch_api_interface_t *commands_api_interface;
switch_limit_interface_t *limit_interface;
memset(&globals, 0, sizeof(&globals));
memset(&globals, 0, sizeof(globals));
strncpy(globals.hostname, switch_core_get_switchname(), sizeof(globals.hostname));
globals.pool = pool;

View File

@ -340,18 +340,13 @@ static void bind_to_session(switch_core_session_t *session,
uint32_t digit_timeout = 1500;
uint32_t input_timeout = 0;
const char *var;
uint32_t tmp;
if ((var = switch_channel_get_variable(channel, "bind_digit_digit_timeout"))) {
tmp = (uint32_t) atol(var);
if (tmp < 0) tmp = 0;
digit_timeout = tmp;
digit_timeout = switch_atoul(var);
}
if ((var = switch_channel_get_variable(channel, "bind_digit_input_timeout"))) {
tmp = (uint32_t) atol(var);
if (tmp < 0) tmp = 0;
input_timeout = tmp;
input_timeout = switch_atoul(var);
}
switch_ivr_dmachine_create(&dmachine, "DPTOOLS", NULL, digit_timeout, input_timeout, NULL, digit_nomatch_action_callback, session);
@ -2217,10 +2212,7 @@ SWITCH_STANDARD_APP(read_function)
}
if (argc > 6) {
digit_timeout = atoi(argv[6]);
if (digit_timeout < 0) {
digit_timeout = 0;
}
digit_timeout = switch_atoui(argv[6]);
}
if (min_digits <= 1) {
@ -2303,10 +2295,7 @@ SWITCH_STANDARD_APP(play_and_get_digits_function)
}
if (argc > 9) {
digit_timeout = atoi(argv[9]);
if (digit_timeout < 0) {
digit_timeout = 0;
}
digit_timeout = switch_atoui(argv[9]);
}
if (argc > 10) {
@ -2589,25 +2578,16 @@ SWITCH_STANDARD_APP(record_function)
l++;
}
if (l) {
limit = atoi(l);
if (limit < 0) {
limit = 0;
}
limit = switch_atoui(l);
}
}
if (argv[2]) {
fh.thresh = atoi(argv[2]);
if (fh.thresh < 0) {
fh.thresh = 0;
}
fh.thresh = switch_atoui(argv[2]);
}
if (argv[3]) {
fh.silence_hits = atoi(argv[3]);
if (fh.silence_hits < 0) {
fh.silence_hits = 0;
}
fh.silence_hits = switch_atoui(argv[3]);
}
if ((tmp = switch_channel_get_variable(channel, "record_rate"))) {
@ -3481,9 +3461,7 @@ SWITCH_STANDARD_APP(wait_for_silence_function)
listen_hits = atoi(argv[2]);
if (argv[3]) {
if ((timeout_ms = atoi(argv[3])) < 0) {
timeout_ms = 0;
}
timeout_ms = switch_atoui(argv[3]);
}
if (thresh > 0 && silence_hits > 0 && listen_hits > 0) {

View File

@ -974,7 +974,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_hash_load)
switch_limit_interface_t *limit_interface;
switch_status_t status;
memset(&globals, 0, sizeof(&globals));
memset(&globals, 0, sizeof(globals));
globals.pool = pool;
status = switch_event_reserve_subclass(LIMIT_EVENT_USAGE);

View File

@ -332,13 +332,10 @@ static switch_status_t load_profile(switch_xml_t xml)
if (!strcmp(var, "logfile")) {
new_profile->logfile = strdup(val);
} else if (!strcmp(var, "rollover")) {
new_profile->roll_size = atoi(val);
if (new_profile->roll_size < 0) {
new_profile->roll_size = 0;
}
new_profile->roll_size = switch_atoui(val);
} else if (!strcmp(var, "maximum-rotate")) {
new_profile->max_rot = atoi(val);
if (new_profile->max_rot < 0) {
new_profile->max_rot = switch_atoui(val);
if (new_profile->max_rot == 0) {
new_profile->max_rot = MAX_ROT;
}
} else if (!strcmp(var, "uuid") && switch_true(val)) {

View File

@ -514,7 +514,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set a negative timeout!\n");
}
} else if (!strcasecmp(var, "delay") && !zstr(val)) {
globals.delay = (uint32_t) atoi(val);
globals.delay = switch_atoui(val);
} else if (!strcasecmp(var, "log-b-leg")) {
globals.log_b = switch_true(val);
} else if (!strcasecmp(var, "prefix-a-leg")) {
@ -530,7 +530,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
globals.encode = switch_true(val) ? ENCODING_DEFAULT : ENCODING_NONE;
}
} else if (!strcasecmp(var, "retries") && !zstr(val)) {
globals.retries = (uint32_t) atoi(val);
globals.retries = switch_atoui(val);
} else if (!strcasecmp(var, "rotate") && !zstr(val)) {
globals.rotate = switch_true(val);
} else if (!strcasecmp(var, "log-dir")) {
@ -596,12 +596,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
}
}
if (globals.retries < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Retries is negative, setting to 0\n");
globals.retries = 0;
}
if (globals.retries && globals.delay <= 0) {
if (globals.retries && globals.delay == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Retries set but delay 0 setting to 5 seconds\n");
globals.delay = 5;
}

View File

@ -85,7 +85,7 @@ static void handle_SIGILL(int sig)
#ifndef WIN32
static void handle_SIGUSR2(int sig)
{
if (sig);
if (sig) {};
system_ready = 1;
@ -97,7 +97,7 @@ static void handle_SIGCHLD(int sig)
int status = 0;
int pid = 0;
if (sig);
if (sig) {};
pid = wait(&status);

View File

@ -667,7 +667,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thre
SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock)
{
return apr_socket_addr_get(sa, remote, sock);
return apr_socket_addr_get(sa, (apr_interface_e) remote, sock);
}
SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t ** new_sock, int family, int type, int protocol, switch_memory_pool_t *pool)
@ -769,7 +769,7 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_create(switch_sockaddr_t **sa, s
new_sa = apr_pcalloc(pool, sizeof(apr_sockaddr_t));
switch_assert(new_sa);
new_sa->pool = pool;
memset(new_sa, 0, sizeof(new_sa));
memset(new_sa, 0, sizeof(*new_sa));
new_sa->family = family;
new_sa->sa.sin.sin_family = family;
@ -909,7 +909,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **po
memset(*pollfd, 0, sizeof(switch_pollfd_t));
(*pollfd)->desc_type = APR_POLL_SOCKET;
(*pollfd)->desc_type = (switch_pollset_type_t) APR_POLL_SOCKET;
(*pollfd)->reqevents = flags;
(*pollfd)->desc.s = sock;
(*pollfd)->client_data = client_data;

View File

@ -262,7 +262,7 @@ SWITCH_DECLARE(const char *) switch_channel_callstate2str(switch_channel_callsta
SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2callstate(const char *str)
{
uint8_t x;
switch_channel_callstate_t callstate = SWITCH_CAUSE_NONE;
switch_channel_callstate_t callstate = (switch_channel_callstate_t) SWITCH_CAUSE_NONE;
if (*str > 47 && *str < 58) {
callstate = atoi(str);
@ -274,7 +274,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2callstate(const char *str
}
}
}
return callstate;
return (switch_call_cause_t) callstate;
}
@ -1923,7 +1923,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
switch_mutex_unlock(channel->state_mutex);
return SWITCH_STATUS_SUCCESS;
return (switch_channel_state_t) SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,

View File

@ -1566,14 +1566,14 @@ static void switch_load_core_config(const char *file)
if (!zstr(var) && !zstr(val)) {
uint32_t *p;
uint32_t v = (unsigned long) atol(val);
uint32_t v = switch_atoul(val);
if (!strcasecmp(var, "G723") || !strcasecmp(var, "iLBC")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding %s, defaults cannot be changed\n", var);
continue;
}
if (v < 0) {
if (v == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding %s, invalid ptime\n", var);
continue;
}

View File

@ -2965,10 +2965,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *ses
switch_core_file_seek(fhp, &pos, target, SEEK_SET);
} else {
samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
if (samps < 0) {
samps = 0;
}
samps = switch_atoui(p) * (codec->implementation->samples_per_second / 1000);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", samps);
switch_core_file_seek(fhp, &pos, samps, SEEK_SET);
}

View File

@ -710,7 +710,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_SQLSetAutoCommitAttr(switch_odb
return SQLSetConnectAttr(handle->con, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER *) SQL_AUTOCOMMIT_OFF, 0 );
}
#else
return SWITCH_FALSE;
return (switch_odbc_status_t) SWITCH_FALSE;
#endif
}
@ -723,7 +723,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_SQLEndTran(switch_odbc_handle_t
return SQLEndTran(SQL_HANDLE_DBC, handle->con, SQL_ROLLBACK);
}
#else
return SWITCH_FALSE;
return (switch_odbc_status_t) SWITCH_FALSE;
#endif
}

View File

@ -951,7 +951,7 @@ static void tm2switchtime(struct tm *tm, switch_time_exp_t *xt)
if (!xt || !tm) {
return;
}
memset(xt, 0, sizeof(xt));
memset(xt, 0, sizeof(*xt));
xt->tm_sec = tm->tm_sec;
xt->tm_min = tm->tm_min;

View File

@ -2921,6 +2921,20 @@ SWITCH_DECLARE(char *) switch_format_number(const char *num)
}
SWITCH_DECLARE(unsigned int) switch_atoui(const char *nptr)
{
int tmp = atoi(nptr);
if (tmp < 0) return 0;
else return (unsigned int) tmp;
}
SWITCH_DECLARE(unsigned long) switch_atoul(const char *nptr)
{
long tmp = atol(nptr);
if (tmp < 0) return 0;
else return (unsigned long) tmp;
}
/* For Emacs:
* Local Variables:
* mode:c