<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8450">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Replace direct checks of option_debug with DEBUG_ATLEAST macro.<br><br>Checking option_debug directly is incorrect as it ignores file/module<br>specific debug settings.  This system-wide change replaces nearly all<br>direct checks for option_debug with the DEBUG_ATLEAST module.<br><br>Change-Id: Ic342d4799a945dbc40ac085ac142681094a4ebf0<br>---<br>M addons/chan_ooh323.c<br>M apps/app_directory.c<br>M apps/app_minivm.c<br>M apps/app_voicemail.c<br>M cdr/cdr_pgsql.c<br>M cel/cel_pgsql.c<br>M channels/chan_dahdi.c<br>M channels/chan_sip.c<br>M main/callerid.c<br>M main/config.c<br>M main/netsock2.c<br>M main/pbx.c<br>M main/sched.c<br>M res/res_config_ldap.c<br>M res/res_config_pgsql.c<br>M res/res_rtp_asterisk.c<br>16 files changed, 25 insertions(+), 26 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/50/8450/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c<br>index 8c4ff2c..278c587 100644<br>--- a/addons/chan_ooh323.c<br>+++ b/addons/chan_ooh323.c<br>@@ -1174,8 +1174,7 @@<br>                                p->alertsent = 1;<br>                  }<br>                     ast_setstate(ast, AST_STATE_UP);<br>-                             if (option_debug)<br>-                            ast_debug(1, "ooh323_answer(%s)\n", ast_channel_name(ast));<br>+                        ast_debug(1, "ooh323_answer(%s)\n", ast_channel_name(ast));<br>                         ast_channel_unlock(ast);<br>                      ooAnswerCall(p->callToken);<br>                }<br>diff --git a/apps/app_directory.c b/apps/app_directory.c<br>index 48533f5..c268969 100644<br>--- a/apps/app_directory.c<br>+++ b/apps/app_directory.c<br>@@ -815,7 +815,7 @@<br>       /* Sort items */<br>      sort_items(sorted, count);<br> <br>-        if (option_debug) {<br>+  if (DEBUG_ATLEAST(2)) {<br>               ast_debug(2, "Listing matching entries:\n");<br>                for (ptr = sorted, i = 0; i < count; i++, ptr++) {<br>                         ast_debug(2, "%s: %s\n", ptr[0]->exten, ptr[0]->name);<br>diff --git a/apps/app_minivm.c b/apps/app_minivm.c<br>index e9fa211..c09fba1 100644<br>--- a/apps/app_minivm.c<br>+++ b/apps/app_minivm.c<br>@@ -1438,7 +1438,7 @@<br>            ast_debug(1, "Using default subject for this email \n");<br>    }<br> <br>- if (option_debug > 2)<br>+     if (DEBUG_ATLEAST(3))<br>                 fprintf(p, "X-Asterisk-debug: template %s user account %s@%s\n", template->name, vmu->username, vmu->domain);<br>      fprintf(p, "MIME-Version: 1.0\n");<br> <br>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c<br>index d22a839..a5b085e 100644<br>--- a/apps/app_voicemail.c<br>+++ b/apps/app_voicemail.c<br>@@ -3638,7 +3638,7 @@<br>       char buf[1024] = "";<br> <br>     if (!(user = get_user_by_mailbox(mailbox, buf, sizeof(buf))) || !(vms = get_vm_state_by_imapuser(user, 0))) {<br>-                if (user && option_debug > 2)<br>+             if (user && DEBUG_ATLEAST(3))<br>                         ast_log(AST_LOG_WARNING, "User %s mailbox not found for update.\n", user);<br>          return;<br>       }<br>diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c<br>index 33cc1b8..76c76f6 100644<br>--- a/cdr/cdr_pgsql.c<br>+++ b/cdr/cdr_pgsql.c<br>@@ -642,7 +642,7 @@<br>           return -1;<br>    }<br> <br>- if (option_debug) {<br>+  if (DEBUG_ATLEAST(1)) {<br>               if (ast_strlen_zero(pghostname)) {<br>                    ast_debug(1, "using default unix socket\n");<br>                } else {<br>diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c<br>index 5fe6678..6a2bac5 100644<br>--- a/cel/cel_pgsql.c<br>+++ b/cel/cel_pgsql.c<br>@@ -556,7 +556,7 @@<br>            ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying schema info\n");<br>          return AST_MODULE_LOAD_DECLINE;<br>       }<br>-    if (option_debug) {<br>+  if (DEBUG_ATLEAST(3)) {<br>               if (ast_strlen_zero(pghostname)) {<br>                    ast_debug(3, "cel_pgsql: using default unix socket\n");<br>             } else {<br>diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c<br>index 4859d1a..c149763 100644<br>--- a/channels/chan_dahdi.c<br>+++ b/channels/chan_dahdi.c<br>@@ -15058,14 +15058,14 @@<br>              ast_mutex_lock(&p->lock);<br>              if (p->owner && !p->restartpending) {<br>                   if (ast_channel_trylock(p->owner)) {<br>-                              if (option_debug > 2)<br>+                             if (DEBUG_ATLEAST(3))<br>                                         ast_verbose("Avoiding deadlock\n");<br>                                 /* Avoid deadlock since you're not supposed to lock iflock or pvt before a channel */<br>                             ast_mutex_unlock(&p->lock);<br>                            ast_mutex_unlock(&iflock);<br>                                goto retry;<br>                   }<br>-                    if (option_debug > 2)<br>+                     if (DEBUG_ATLEAST(3))<br>                                 ast_verbose("Softhanging up on %s\n", ast_channel_name(p->owner));<br>                       ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_EXPLICIT);<br>                  p->restartpending = 1;<br>diff --git a/channels/chan_sip.c b/channels/chan_sip.c<br>index 9cdf71c..040a221 100644<br>--- a/channels/chan_sip.c<br>+++ b/channels/chan_sip.c<br>@@ -22400,7 +22400,7 @@<br>               return;<br>       }<br> <br>- if (!option_debug && !sipdebug) {<br>+    if (!DEBUG_ATLEAST(1) && !sipdebug) {<br>                 if (!errmsg) {<br>                        ast_log(LOG_NOTICE, "You must have debugging enabled (SIP or Asterisk) in order to dump SIP history.\n");<br>                   errmsg = 1;<br>diff --git a/main/callerid.c b/main/callerid.c<br>index d6f8575..6c4e5cf 100644<br>--- a/main/callerid.c<br>+++ b/main/callerid.c<br>@@ -501,7 +501,7 @@<br>                                                 case 0x06: /* short dial number */<br>                                            case 0x07: /* reserved */<br>                                             default:   /* reserved */<br>-                                                    if (option_debug > 1)<br>+                                                     if (DEBUG_ATLEAST(2))<br>                                                                 ast_log(LOG_NOTICE, "did info:#1=%X\n", (unsigned)cid->rawdata[x]);<br>                                                      break ;<br>                                               }<br>diff --git a/main/config.c b/main/config.c<br>index 8107fce..2988ecd 100644<br>--- a/main/config.c<br>+++ b/main/config.c<br>@@ -2785,7 +2785,7 @@<br>                         }<br>                     cat = cat->next;<br>           }<br>-            if (!option_debug) {<br>+         if (!DEBUG_ATLEAST(1)) {<br>                      ast_verb(2, "Saving '%s': saved\n", fn);<br>            }<br>     } else {<br>diff --git a/main/netsock2.c b/main/netsock2.c<br>index ef74ab9..fedbd94 100644<br>--- a/main/netsock2.c<br>+++ b/main/netsock2.c<br>@@ -443,7 +443,7 @@<br>            && addr->ss.ss_family == AF_INET6) {<br>               return ntohs(((struct sockaddr_in6 *)&addr->ss)->sin6_port);<br>        }<br>-    if (option_debug >= 1) {<br>+  if (DEBUG_ATLEAST(1)) {<br>               ast_log(__LOG_DEBUG, file, line, func, "Not an IPv4 nor IPv6 address, cannot get port.\n");<br>         }<br>     return 0;<br>@@ -461,7 +461,7 @@<br>        } else if (addr->len == sizeof(struct sockaddr_in6)<br>                && addr->ss.ss_family == AF_INET6) {<br>               ((struct sockaddr_in6 *)&addr->ss)->sin6_port = htons(port);<br>-       } else if (option_debug >= 1) {<br>+   } else if (DEBUG_ATLEAST(1)) {<br>                ast_log(__LOG_DEBUG, file, line, func,<br>                        "Not an IPv4 nor IPv6 address, cannot set port.\n");<br>        }<br>@@ -657,7 +657,7 @@<br>                return 0;<br>     }<br> <br>- if (addr->ss.ss_family != AF_INET && option_debug >= 1) {<br>+      if (addr->ss.ss_family != AF_INET && DEBUG_ATLEAST(1)) {<br>           ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n");<br>  }<br> <br>@@ -670,7 +670,7 @@<br> {<br>         memcpy(&addr->ss, sin, sizeof(*sin));<br> <br>-      if (addr->ss.ss_family != AF_INET && option_debug >= 1) {<br>+      if (addr->ss.ss_family != AF_INET && DEBUG_ATLEAST(1)) {<br>           ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n");<br>  }<br> <br>diff --git a/main/pbx.c b/main/pbx.c<br>index 942c15c..f515339 100644<br>--- a/main/pbx.c<br>+++ b/main/pbx.c<br>@@ -7508,7 +7508,7 @@<br>                  ast_add_hint(tmp);<br>            }<br>     }<br>-    if (option_debug) {<br>+  if (DEBUG_ATLEAST(1)) {<br>               if (tmp->matchcid == AST_EXT_MATCHCID_ON) {<br>                        ast_debug(1, "Added extension '%s' priority %d (CID match '%s') to %s (%p)\n",<br>                                        tmp->name, tmp->priority, tmp->cidmatch_display, con->name, con);<br>diff --git a/main/sched.c b/main/sched.c<br>index a4ca260..a11b013 100644<br>--- a/main/sched.c<br>+++ b/main/sched.c<br>@@ -32,7 +32,7 @@<br> <br> #ifdef DEBUG_SCHEDULER<br> #define DEBUG(a) do { \<br>-    if (option_debug) \<br>+  if (DEBUG_ATLEAST(1)) \<br>               DEBUG_M(a) \<br>  } while (0)<br> #else<br>@@ -548,7 +548,7 @@<br>      }<br> #ifdef DUMP_SCHEDULER<br>     /* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */<br>-    if (option_debug)<br>+    if (DEBUG_ATLEAST(1))<br>                 ast_sched_dump(con);<br> #endif<br>         if (con->sched_thread) {<br>@@ -649,7 +649,7 @@<br> <br> #ifdef DUMP_SCHEDULER<br>   /* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */<br>-    if (option_debug)<br>+    if (DEBUG_ATLEAST(1))<br>                 ast_sched_dump(con);<br> #endif<br>         if (con->sched_thread) {<br>diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c<br>index 10265c9..c767cba 100644<br>--- a/res/res_config_ldap.c<br>+++ b/res/res_config_ldap.c<br>@@ -548,7 +548,7 @@<br>                         } /*!< while (ldap_attribute_name) */<br>                      ber_free(ber, 0);<br>                     if (static_table_config == table_config) {<br>-                           if (option_debug > 2) {<br>+                           if (DEBUG_ATLEAST(3)) {<br>                                       const struct ast_variable *tmpdebug = variable_named(var, "variable_name");<br>                                         const struct ast_variable *tmpdebug2 = variable_named(var, "variable_value");<br>                                       if (tmpdebug && tmpdebug2) {<br>@@ -1618,7 +1618,7 @@<br> <br>        /* Ready to update */<br>         ast_debug(3, "Modifying %zu matched entries\n", entry_count);<br>-      if (option_debug > 2) {<br>+   if (DEBUG_ATLEAST(3)) {<br>               size_t i;<br>             for (i = 0; modifications[i]; i++) {<br>                  if (modifications[i]->mod_op != LDAP_MOD_DELETE) {<br>diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c<br>index 6ae6ebd..5b9f160 100644<br>--- a/res/res_config_pgsql.c<br>+++ b/res/res_config_pgsql.c<br>@@ -1528,7 +1528,7 @@<br> <br>      ast_config_destroy(config);<br> <br>-       if (option_debug) {<br>+  if (DEBUG_ATLEAST(1)) {<br>               if (!ast_strlen_zero(dbhost)) {<br>                       ast_debug(1, "PostgreSQL RealTime Host: %s\n", dbhost);<br>                     ast_debug(1, "PostgreSQL RealTime Port: %i\n", dbport);<br>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c<br>index b53b38a..7cbfdf0 100644<br>--- a/res/res_rtp_asterisk.c<br>+++ b/res/res_rtp_asterisk.c<br>@@ -4565,7 +4565,7 @@<br>     format = frame->subclass.format;<br>   if (ast_format_cmp(rtp->lasttxformat, format) == AST_FORMAT_CMP_NOT_EQUAL) {<br>               /* Oh dear, if the format changed we will have to set up a new smoother */<br>-           if (option_debug > 0) {<br>+           if (DEBUG_ATLEAST(1)) {<br>                       ast_debug(1, "Ooh, format changed from %s to %s\n",<br>                                 ast_format_get_name(rtp->lasttxformat),<br>                            ast_format_get_name(frame->subclass.format));<br>@@ -5744,7 +5744,7 @@<br>                               ast_sockaddr_stringify(&remote_address),<br>                          strerror(errno));<br>             } else if (((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(bridged, FLAG_NAT_INACTIVE_NOWARN)) {<br>-                      if (option_debug || rtpdebug) {<br>+                      if (DEBUG_ATLEAST(1) || rtpdebug) {<br>                           ast_log(LOG_WARNING,<br>                                  "RTP NAT: Can't write RTP to private "<br>                                  "address %s, waiting for other end to "<br>@@ -6117,7 +6117,7 @@<br>      if (ext) {<br>            hdrlen += (ntohl(rtpheader[hdrlen/4]) & 0xffff) << 2;<br>               hdrlen += 4;<br>-         if (option_debug) {<br>+          if (DEBUG_ATLEAST(1)) {<br>                       unsigned int profile;<br>                         profile = (ntohl(rtpheader[3]) & 0xffff0000) >> 16;<br>                         if (profile == 0x505a)<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8450">change 8450</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8450"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ic342d4799a945dbc40ac085ac142681094a4ebf0 </div>
<div style="display:none"> Gerrit-Change-Number: 8450 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>