]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-2216 partial with renaming
authorJeff Lenk <jeff@jefflenk.com>
Sun, 8 Jan 2012 20:19:16 +0000 (14:19 -0600)
committerJeff Lenk <jeff@jefflenk.com>
Sun, 8 Jan 2012 20:19:16 +0000 (14:19 -0600)
16 files changed:
libs/esl/src/esl_event.c
src/include/switch_utils.h
src/mod/applications/mod_conference/mod_conference.c
src/mod/applications/mod_db/mod_db.c
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/applications/mod_hash/mod_hash.c
src/mod/loggers/mod_logfile/mod_logfile.c
src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
src/switch.c
src/switch_apr.c
src/switch_channel.c
src/switch_core.c
src/switch_ivr.c
src/switch_odbc.c
src/switch_time.c
src/switch_utils.c

index ead853ea4636447614bfc75521be4584c081f24b..1271e46e4f55f5b2fcaf1ec1bcf06dd46d252d1f 100644 (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) {
index 343a2ce62e24631832ef4f27686a6f6436da2ac4..cce5abfa2d93601e880c76d30aedd387f81762ca 100644 (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:
index bd07c68ce6ccd205ced1aeb3ec717e20036370a1..003ad6b116a77d1457e938557f8286fdbd1e5aee 100644 (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
                                         */
index dccc6c9a2f3f1f901eb7d018e8e4bc742ff7cb8e..d94de1b90025d27b6c218f5e6c351e7976055c07 100644 (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;
 
index 9d804bdfc44b90cdd219836107dfe130d8e38cb3..20620c10a85ca186f3cf7c9e9c39043f52ab09f1 100755 (executable)
@@ -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) {
index ced478bb1c0bc86224beef729930187a28780f63..c4a899a74b380e6823d9cf884aca846d9f8cdaf2 100644 (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);
index b768d6bff0704047aca35c282147f4d74989a5f7..db78909134ac953bce91dd1596fe9f72076bddc0 100644 (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)) {
index 06d474e0bf2ec4d3079552fc163fdabdd6384d57..684a04880648fa011f83a2b00f6e28130ebc092e 100644 (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;
        }
index dc496473803ffcf3e117f74c230b37e7b3e2c319..b903fae5f0122a7873b67fe0c4c35c18f9b08f5e 100644 (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);
        
index 7d98ec69efc8f130c60807a2555887a997841574..329bbeee37742d082775d1c6e3e085705da11c11 100644 (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;
index a0b5b9c018a3b43d37508f920edfb036b9b0b650..56206810272ad4d846949761e44e44b28c3cc974 100644 (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,
index 0e3dc80679399b4fb51d9ff745e2c3f1880cfd12..d8dfa9a428c53049cc7438624d7e31d011f8ed21 100644 (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;
                                        }
index 743b043dd6ebc369335988b968513980b70f7f2e..c56a862584d6d6f721c39e3474198f799e9efa1a 100644 (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);
                                }
index a7c2153304bcbc58d129286d149d28ecf420066b..5bd31adf602f7f02f2f7094be37877f2f62e9767 100644 (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
 }
 
index 2a5a6860ea7af9e052f5b45e61eb68f9a86662d0..2f111efa26bdbe6677328c7fc60df106e81dbefe 100644 (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;
index 808afd0c571a89c9127e35401e06c7ce04592fb8..3374011f5730f09e84822531e92249f2c4416dd1 100644 (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