<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8451">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/51/8451/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 5d5f5fe..91f6e8f 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 f644d9c..b49eb55 100644<br>--- a/apps/app_directory.c<br>+++ b/apps/app_directory.c<br>@@ -817,7 +817,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 2c57e04..a3dcef8 100644<br>--- a/apps/app_minivm.c<br>+++ b/apps/app_minivm.c<br>@@ -1440,7 +1440,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 db6b757..089e7d2 100644<br>--- a/apps/app_voicemail.c<br>+++ b/apps/app_voicemail.c<br>@@ -3640,7 +3640,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 4430e51..b869715 100644<br>--- a/cdr/cdr_pgsql.c<br>+++ b/cdr/cdr_pgsql.c<br>@@ -649,7 +649,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 a79bfab..1086d92 100644<br>--- a/cel/cel_pgsql.c<br>+++ b/cel/cel_pgsql.c<br>@@ -534,7 +534,7 @@<br>    if ((tmp = ast_variable_retrieve(cfg, "global", "show_user_defined"))) {<br>          cel_show_user_def = ast_true(tmp) ? 1 : 0;<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 d5e79ff..8669267 100644<br>--- a/channels/chan_dahdi.c<br>+++ b/channels/chan_dahdi.c<br>@@ -15167,14 +15167,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 0a5caec..c5d104c 100644<br>--- a/channels/chan_sip.c<br>+++ b/channels/chan_sip.c<br>@@ -22332,7 +22332,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 a9864da..a411bd3 100644<br>--- a/main/callerid.c<br>+++ b/main/callerid.c<br>@@ -503,7 +503,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 eec6c02..e0f7b44 100644<br>--- a/main/config.c<br>+++ b/main/config.c<br>@@ -2787,7 +2787,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 5f94a75..90835c3 100644<br>--- a/main/netsock2.c<br>+++ b/main/netsock2.c<br>@@ -445,7 +445,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>@@ -463,7 +463,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>@@ -659,7 +659,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>@@ -672,7 +672,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 8e58819..778310a 100644<br>--- a/main/pbx.c<br>+++ b/main/pbx.c<br>@@ -7424,7 +7424,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 222c691..d87f473 100644<br>--- a/main/sched.c<br>+++ b/main/sched.c<br>@@ -34,7 +34,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>@@ -550,7 +550,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>@@ -651,7 +651,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 78f1fa8..75b01c0 100644<br>--- a/res/res_config_ldap.c<br>+++ b/res/res_config_ldap.c<br>@@ -550,7 +550,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>@@ -1620,7 +1620,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 b4f5aa2..a1ddaa7 100644<br>--- a/res/res_config_pgsql.c<br>+++ b/res/res_config_pgsql.c<br>@@ -1560,7 +1560,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 1dcae3b..d397ef2 100644<br>--- a/res/res_rtp_asterisk.c<br>+++ b/res/res_rtp_asterisk.c<br>@@ -4164,7 +4164,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>@@ -5251,7 +5251,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>@@ -5585,7 +5585,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/8451">change 8451</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/8451"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </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: 8451 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>