[Asterisk-code-review] Replace direct checks of option debug with DEBUG ATLEAST macro. (asterisk[13])

Corey Farrell asteriskteam at digium.com
Wed Mar 7 00:58:49 CST 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8451


Change subject: Replace direct checks of option_debug with DEBUG_ATLEAST macro.
......................................................................

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 module.

Change-Id: Ic342d4799a945dbc40ac085ac142681094a4ebf0
---
M addons/chan_ooh323.c
M apps/app_directory.c
M apps/app_minivm.c
M apps/app_voicemail.c
M cdr/cdr_pgsql.c
M cel/cel_pgsql.c
M channels/chan_dahdi.c
M channels/chan_sip.c
M main/callerid.c
M main/config.c
M main/netsock2.c
M main/pbx.c
M main/sched.c
M res/res_config_ldap.c
M res/res_config_pgsql.c
M res/res_rtp_asterisk.c
16 files changed, 25 insertions(+), 26 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/51/8451/1

diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c
index 5d5f5fe..91f6e8f 100644
--- a/addons/chan_ooh323.c
+++ b/addons/chan_ooh323.c
@@ -1174,8 +1174,7 @@
 				p->alertsent = 1;
 			}
 			ast_setstate(ast, AST_STATE_UP);
-      			if (option_debug)
-				ast_debug(1, "ooh323_answer(%s)\n", ast_channel_name(ast));
+			ast_debug(1, "ooh323_answer(%s)\n", ast_channel_name(ast));
 			ast_channel_unlock(ast);
 			ooAnswerCall(p->callToken);
 		}
diff --git a/apps/app_directory.c b/apps/app_directory.c
index f644d9c..b49eb55 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -817,7 +817,7 @@
 	/* Sort items */
 	sort_items(sorted, count);
 
-	if (option_debug) {
+	if (DEBUG_ATLEAST(2)) {
 		ast_debug(2, "Listing matching entries:\n");
 		for (ptr = sorted, i = 0; i < count; i++, ptr++) {
 			ast_debug(2, "%s: %s\n", ptr[0]->exten, ptr[0]->name);
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index 2c57e04..a3dcef8 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -1440,7 +1440,7 @@
 		ast_debug(1, "Using default subject for this email \n");
 	}
 
-	if (option_debug > 2)
+	if (DEBUG_ATLEAST(3))
 		fprintf(p, "X-Asterisk-debug: template %s user account %s@%s\n", template->name, vmu->username, vmu->domain);
 	fprintf(p, "MIME-Version: 1.0\n");
 
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index db6b757..089e7d2 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -3640,7 +3640,7 @@
 	char buf[1024] = "";
 
 	if (!(user = get_user_by_mailbox(mailbox, buf, sizeof(buf))) || !(vms = get_vm_state_by_imapuser(user, 0))) {
-		if (user && option_debug > 2)
+		if (user && DEBUG_ATLEAST(3))
 			ast_log(AST_LOG_WARNING, "User %s mailbox not found for update.\n", user);
 		return;
 	}
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 4430e51..b869715 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -649,7 +649,7 @@
 		return -1;
 	}
 
-	if (option_debug) {
+	if (DEBUG_ATLEAST(1)) {
 		if (ast_strlen_zero(pghostname)) {
 			ast_debug(1, "using default unix socket\n");
 		} else {
diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c
index a79bfab..1086d92 100644
--- a/cel/cel_pgsql.c
+++ b/cel/cel_pgsql.c
@@ -534,7 +534,7 @@
 	if ((tmp = ast_variable_retrieve(cfg, "global", "show_user_defined"))) {
 		cel_show_user_def = ast_true(tmp) ? 1 : 0;
 	}
-	if (option_debug) {
+	if (DEBUG_ATLEAST(3)) {
 		if (ast_strlen_zero(pghostname)) {
 			ast_debug(3, "cel_pgsql: using default unix socket\n");
 		} else {
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index d5e79ff..8669267 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -15167,14 +15167,14 @@
 		ast_mutex_lock(&p->lock);
 		if (p->owner && !p->restartpending) {
 			if (ast_channel_trylock(p->owner)) {
-				if (option_debug > 2)
+				if (DEBUG_ATLEAST(3))
 					ast_verbose("Avoiding deadlock\n");
 				/* Avoid deadlock since you're not supposed to lock iflock or pvt before a channel */
 				ast_mutex_unlock(&p->lock);
 				ast_mutex_unlock(&iflock);
 				goto retry;
 			}
-			if (option_debug > 2)
+			if (DEBUG_ATLEAST(3))
 				ast_verbose("Softhanging up on %s\n", ast_channel_name(p->owner));
 			ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_EXPLICIT);
 			p->restartpending = 1;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 0a5caec..c5d104c 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -22332,7 +22332,7 @@
 		return;
 	}
 
-	if (!option_debug && !sipdebug) {
+	if (!DEBUG_ATLEAST(1) && !sipdebug) {
 		if (!errmsg) {
 			ast_log(LOG_NOTICE, "You must have debugging enabled (SIP or Asterisk) in order to dump SIP history.\n");
 			errmsg = 1;
diff --git a/main/callerid.c b/main/callerid.c
index a9864da..a411bd3 100644
--- a/main/callerid.c
+++ b/main/callerid.c
@@ -503,7 +503,7 @@
 						case 0x06: /* short dial number */
 						case 0x07: /* reserved */
 						default:   /* reserved */
-							if (option_debug > 1)
+							if (DEBUG_ATLEAST(2))
 								ast_log(LOG_NOTICE, "did info:#1=%X\n", (unsigned)cid->rawdata[x]);
 							break ;
 						}
diff --git a/main/config.c b/main/config.c
index eec6c02..e0f7b44 100644
--- a/main/config.c
+++ b/main/config.c
@@ -2787,7 +2787,7 @@
 			}
 			cat = cat->next;
 		}
-		if (!option_debug) {
+		if (!DEBUG_ATLEAST(1)) {
 			ast_verb(2, "Saving '%s': saved\n", fn);
 		}
 	} else {
diff --git a/main/netsock2.c b/main/netsock2.c
index 5f94a75..90835c3 100644
--- a/main/netsock2.c
+++ b/main/netsock2.c
@@ -445,7 +445,7 @@
 		&& addr->ss.ss_family == AF_INET6) {
 		return ntohs(((struct sockaddr_in6 *)&addr->ss)->sin6_port);
 	}
-	if (option_debug >= 1) {
+	if (DEBUG_ATLEAST(1)) {
 		ast_log(__LOG_DEBUG, file, line, func, "Not an IPv4 nor IPv6 address, cannot get port.\n");
 	}
 	return 0;
@@ -463,7 +463,7 @@
 	} else if (addr->len == sizeof(struct sockaddr_in6)
 		&& addr->ss.ss_family == AF_INET6) {
 		((struct sockaddr_in6 *)&addr->ss)->sin6_port = htons(port);
-	} else if (option_debug >= 1) {
+	} else if (DEBUG_ATLEAST(1)) {
 		ast_log(__LOG_DEBUG, file, line, func,
 			"Not an IPv4 nor IPv6 address, cannot set port.\n");
 	}
@@ -659,7 +659,7 @@
 		return 0;
 	}
 
-	if (addr->ss.ss_family != AF_INET && option_debug >= 1) {
+	if (addr->ss.ss_family != AF_INET && DEBUG_ATLEAST(1)) {
 		ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n");
 	}
 
@@ -672,7 +672,7 @@
 {
 	memcpy(&addr->ss, sin, sizeof(*sin));
 
-	if (addr->ss.ss_family != AF_INET && option_debug >= 1) {
+	if (addr->ss.ss_family != AF_INET && DEBUG_ATLEAST(1)) {
 		ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n");
 	}
 
diff --git a/main/pbx.c b/main/pbx.c
index 8e58819..778310a 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -7424,7 +7424,7 @@
 			ast_add_hint(tmp);
 		}
 	}
-	if (option_debug) {
+	if (DEBUG_ATLEAST(1)) {
 		if (tmp->matchcid == AST_EXT_MATCHCID_ON) {
 			ast_debug(1, "Added extension '%s' priority %d (CID match '%s') to %s (%p)\n",
 					  tmp->name, tmp->priority, tmp->cidmatch_display, con->name, con);
diff --git a/main/sched.c b/main/sched.c
index 222c691..d87f473 100644
--- a/main/sched.c
+++ b/main/sched.c
@@ -34,7 +34,7 @@
 
 #ifdef DEBUG_SCHEDULER
 #define DEBUG(a) do { \
-	if (option_debug) \
+	if (DEBUG_ATLEAST(1)) \
 		DEBUG_M(a) \
 	} while (0)
 #else
@@ -550,7 +550,7 @@
 	}
 #ifdef DUMP_SCHEDULER
 	/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
-	if (option_debug)
+	if (DEBUG_ATLEAST(1))
 		ast_sched_dump(con);
 #endif
 	if (con->sched_thread) {
@@ -651,7 +651,7 @@
 
 #ifdef DUMP_SCHEDULER
 	/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
-	if (option_debug)
+	if (DEBUG_ATLEAST(1))
 		ast_sched_dump(con);
 #endif
 	if (con->sched_thread) {
diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 78f1fa8..75b01c0 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -550,7 +550,7 @@
 			} /*!< 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) {
@@ -1620,7 +1620,7 @@
 
 	/* 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) {
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index b4f5aa2..a1ddaa7 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -1560,7 +1560,7 @@
 
 	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);
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 1dcae3b..d397ef2 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -4164,7 +4164,7 @@
 	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) {
+		if (DEBUG_ATLEAST(1)) {
 			ast_debug(1, "Ooh, format changed from %s to %s\n",
 				ast_format_get_name(rtp->lasttxformat),
 				ast_format_get_name(frame->subclass.format));
@@ -5251,7 +5251,7 @@
 				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 (DEBUG_ATLEAST(1) || rtpdebug) {
 				ast_log(LOG_WARNING,
 					"RTP NAT: Can't write RTP to private "
 					"address %s, waiting for other end to "
@@ -5585,7 +5585,7 @@
 	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)

-- 
To view, visit https://gerrit.asterisk.org/8451
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic342d4799a945dbc40ac085ac142681094a4ebf0
Gerrit-Change-Number: 8451
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180307/f82385eb/attachment.html>


More information about the asterisk-code-review mailing list