From c8a521b6c804d66abb367783dba75eecb16889a2 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Wed, 7 Mar 2018 15:36:17 -0500 Subject: Replace direct checks of option_debug with DEBUG_ATLEAST macro. Checking option_debug directly is incorrect as it ignores file/module specific debug settings. This system-wide change replaces nearly all direct checks for option_debug with the DEBUG_ATLEAST macro. Change-Id: Ic342d4799a945dbc40ac085ac142681094a4ebf0 --- res/res_config_ldap.c | 12 ++++++------ res/res_config_pgsql.c | 14 +++++++------- res/res_rtp_asterisk.c | 21 ++++++++++----------- 3 files changed, 23 insertions(+), 24 deletions(-) (limited to 'res') diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c index 10265c93d..15d9ec018 100644 --- a/res/res_config_ldap.c +++ b/res/res_config_ldap.c @@ -548,11 +548,11 @@ static struct ast_variable **realtime_ldap_result_to_vars(struct ldap_table_conf } /*!< while (ldap_attribute_name) */ ber_free(ber, 0); if (static_table_config == table_config) { - if (option_debug > 2) { + if (DEBUG_ATLEAST(3)) { const struct ast_variable *tmpdebug = variable_named(var, "variable_name"); const struct ast_variable *tmpdebug2 = variable_named(var, "variable_value"); if (tmpdebug && tmpdebug2) { - ast_debug(3, "Added to vars - %s = %s\n", tmpdebug->value, tmpdebug2->value); + ast_log(LOG_DEBUG, "Added to vars - %s = %s\n", tmpdebug->value, tmpdebug2->value); } } vars[entry_index++] = var; @@ -1618,14 +1618,14 @@ static int update2_ldap(const char *basedn, const char *table_name, const struct /* Ready to update */ ast_debug(3, "Modifying %zu matched entries\n", entry_count); - if (option_debug > 2) { + if (DEBUG_ATLEAST(3)) { size_t i; for (i = 0; modifications[i]; i++) { if (modifications[i]->mod_op != LDAP_MOD_DELETE) { - ast_debug(3, "%s => %s\n", modifications[i]->mod_type, - modifications[i]->mod_values[0]); + ast_log(LOG_DEBUG, "%s => %s\n", modifications[i]->mod_type, + modifications[i]->mod_values[0]); } else { - ast_debug(3, "deleting %s\n", modifications[i]->mod_type); + ast_log(LOG_DEBUG, "deleting %s\n", modifications[i]->mod_type); } } } diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index cee4e488d..c259b30c1 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -1528,16 +1528,16 @@ static int parse_config(int is_reload) ast_config_destroy(config); - if (option_debug) { + if (DEBUG_ATLEAST(1)) { if (!ast_strlen_zero(dbhost)) { - ast_debug(1, "PostgreSQL RealTime Host: %s\n", dbhost); - ast_debug(1, "PostgreSQL RealTime Port: %i\n", dbport); + ast_log(LOG_DEBUG, "PostgreSQL RealTime Host: %s\n", dbhost); + ast_log(LOG_DEBUG, "PostgreSQL RealTime Port: %i\n", dbport); } else { - ast_debug(1, "PostgreSQL RealTime Socket: %s\n", dbsock); + ast_log(LOG_DEBUG, "PostgreSQL RealTime Socket: %s\n", dbsock); } - ast_debug(1, "PostgreSQL RealTime User: %s\n", dbuser); - ast_debug(1, "PostgreSQL RealTime Password: %s\n", dbpass); - ast_debug(1, "PostgreSQL RealTime DBName: %s\n", dbname); + ast_log(LOG_DEBUG, "PostgreSQL RealTime User: %s\n", dbuser); + ast_log(LOG_DEBUG, "PostgreSQL RealTime Password: %s\n", dbpass); + ast_log(LOG_DEBUG, "PostgreSQL RealTime DBName: %s\n", dbname); } if (!pgsql_reconnect(NULL)) { diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index b53b38ad7..d0e482405 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -4565,11 +4565,9 @@ static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *fr format = frame->subclass.format; if (ast_format_cmp(rtp->lasttxformat, format) == AST_FORMAT_CMP_NOT_EQUAL) { /* Oh dear, if the format changed we will have to set up a new smoother */ - if (option_debug > 0) { - ast_debug(1, "Ooh, format changed from %s to %s\n", - ast_format_get_name(rtp->lasttxformat), - ast_format_get_name(frame->subclass.format)); - } + ast_debug(1, "Ooh, format changed from %s to %s\n", + ast_format_get_name(rtp->lasttxformat), + ast_format_get_name(frame->subclass.format)); ao2_replace(rtp->lasttxformat, format); if (rtp->smoother) { ast_smoother_free(rtp->smoother); @@ -5744,7 +5742,7 @@ static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance, ast_sockaddr_stringify(&remote_address), strerror(errno)); } else if (((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(bridged, FLAG_NAT_INACTIVE_NOWARN)) { - if (option_debug || rtpdebug) { + if (rtpdebug || DEBUG_ATLEAST(1)) { ast_log(LOG_WARNING, "RTP NAT: Can't write RTP to private " "address %s, waiting for other end to " @@ -6117,13 +6115,14 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc if (ext) { hdrlen += (ntohl(rtpheader[hdrlen/4]) & 0xffff) << 2; hdrlen += 4; - if (option_debug) { + if (DEBUG_ATLEAST(1)) { unsigned int profile; profile = (ntohl(rtpheader[3]) & 0xffff0000) >> 16; - if (profile == 0x505a) - ast_debug(1, "Found Zfone extension in RTP stream - zrtp - not supported.\n"); - else - ast_debug(1, "Found unknown RTP Extensions %x\n", profile); + if (profile == 0x505a) { + ast_log(LOG_DEBUG, "Found Zfone extension in RTP stream - zrtp - not supported.\n"); + } else { + ast_log(LOG_DEBUG, "Found unknown RTP Extensions %x\n", profile); + } } } -- cgit v1.2.3