From 8fd67f8779b33f3c074741d2b14e6d6fe9967412 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 12 Dec 2007 03:21:14 +0000 Subject: [PATCH] cleanup, null checks. etc. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6695 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../applications/mod_dptools/mod_dptools.c | 2 +- src/mod/applications/mod_expr/mod_expr.c | 2 +- src/mod/applications/mod_fifo/mod_fifo.c | 24 +++++++++---------- src/mod/applications/mod_limit/mod_limit.c | 8 +++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index ff444c44bd..c745b0a453 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -456,7 +456,7 @@ SWITCH_STANDARD_APP(set_global_function) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { var = strdup(data); - assert(var); + switch_assert(var); val = strchr(var, '='); if (val) { diff --git a/src/mod/applications/mod_expr/mod_expr.c b/src/mod/applications/mod_expr/mod_expr.c index addb2fd7da..b04dc85057 100644 --- a/src/mod/applications/mod_expr/mod_expr.c +++ b/src/mod/applications/mod_expr/mod_expr.c @@ -61,7 +61,7 @@ SWITCH_STANDARD_API(expr_function) m_cmd = malloc(len); - assert(m_cmd); + switch_assert(m_cmd); switch_copy_string(m_cmd, cmd, len); for (p = m_cmd; p && *p; p++) { diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 2d3e5567c3..671aa0c127 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -124,7 +124,7 @@ SWITCH_STANDARD_APP(fifo_function) } mydata = switch_core_session_strdup(session, data); - assert(mydata); + switch_assert(mydata); if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE); return; @@ -137,7 +137,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_queue_create(&node->fifo, SWITCH_CORE_QUEUE_LEN, globals.pool); switch_core_hash_init(&node->caller_hash, globals.pool); switch_core_hash_init(&node->consumer_hash, globals.pool); - assert(node->fifo); + switch_assert(node->fifo); switch_mutex_init(&node->mutex, SWITCH_MUTEX_NESTED, globals.pool); switch_core_hash_insert(globals.fifo_hash, argv[0], node); } @@ -337,12 +337,12 @@ SWITCH_STANDARD_APP(fifo_function) switch_channel_answer(channel); cloned_profile = switch_caller_profile_clone(other_session, switch_channel_get_caller_profile(channel)); - assert(cloned_profile); + switch_assert(cloned_profile); switch_channel_set_originator_caller_profile(other_channel, cloned_profile); cloned_profile = switch_caller_profile_clone(session, switch_channel_get_caller_profile(other_channel)); - assert(cloned_profile); - assert(cloned_profile->next == NULL); + switch_assert(cloned_profile); + switch_assert(cloned_profile->next == NULL); switch_channel_set_originatee_caller_profile(channel, cloned_profile); ts = switch_timestamp_now(); @@ -414,7 +414,7 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char const void *var; x_tmp = switch_xml_add_child_d(xml, container, cc_off++); - assert(x_tmp); + switch_assert(x_tmp); for (hi = switch_hash_first(NULL, hash); hi; hi = switch_hash_next(hi)) { int c_off = 0, d_off = 0; @@ -425,7 +425,7 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char session = (switch_core_session_t *) val; channel = switch_core_session_get_channel(session); x_caller = switch_xml_add_child_d(x_tmp, tag, c_off++); - assert(x_caller); + switch_assert(x_caller); switch_xml_set_attr_d(x_caller, "uuid", switch_core_session_get_uuid(session)); @@ -468,7 +468,7 @@ static void list_node(fifo_node_t *node, switch_xml_t x_report, int *off, int ve char *tmp = buffer; x_fifo = switch_xml_add_child_d(x_report, "fifo", (*off)++);; - assert(x_fifo); + switch_assert(x_fifo); switch_xml_set_attr_d(x_fifo, "name", node->name); snprintf(tmp, sizeof(buffer), "%d", node->consumer_count); @@ -496,10 +496,10 @@ SWITCH_STANDARD_API(fifo_api_function) if (!switch_strlen_zero(cmd)) { data = strdup(cmd); - assert(data); + switch_assert(data); } - if (switch_strlen_zero(cmd) || (argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 1) { + if (switch_strlen_zero(cmd) || (argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 1 || !argv[0]) { stream->write_function(stream, "%s\n", FIFO_API_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -510,7 +510,7 @@ SWITCH_STANDARD_API(fifo_api_function) if (!strcasecmp(argv[0], "list") || verbose) { char *xml_text = NULL; switch_xml_t x_report = switch_xml_new("fifo_report"); - assert(x_report); + switch_assert(x_report); if (argc < 2) { for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) { @@ -528,7 +528,7 @@ SWITCH_STANDARD_API(fifo_api_function) } } xml_text = switch_xml_toxml(x_report, SWITCH_FALSE); - assert(xml_text); + switch_assert(xml_text); stream->write_function(stream, "%s\n", xml_text); switch_xml_free(x_report); switch_safe_free(xml_text); diff --git a/src/mod/applications/mod_limit/mod_limit.c b/src/mod/applications/mod_limit/mod_limit.c index 3af7d0f49b..faddd53e0d 100644 --- a/src/mod/applications/mod_limit/mod_limit.c +++ b/src/mod/applications/mod_limit/mod_limit.c @@ -345,7 +345,7 @@ SWITCH_STANDARD_API(db_api_function) argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (argc < 1) { + if (argc < 1 || !argv[0]) { goto error; } @@ -419,7 +419,7 @@ SWITCH_STANDARD_APP(db_function) argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (argc < 4) { + if (argc < 4 || !argv[0]) { goto error; } @@ -460,7 +460,7 @@ SWITCH_STANDARD_API(group_api_function) argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (argc < 2) { + if (argc < 2 || !argv[0]) { goto error; } @@ -544,7 +544,7 @@ SWITCH_STANDARD_APP(group_function) argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (argc < 3) { + if (argc < 3 || !argv[0]) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: group %s\n", DB_USAGE); return; }