From 4f8d56a824f7cca238476130b9669c71fcb6ade0 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Thu, 14 Apr 2011 21:02:38 +0000
Subject: [PATCH] Merged revisions 313780 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r313780 | rmudgett | 2011-04-14 15:59:56 -0500 (Thu, 14 Apr 2011) | 20 lines

  Leftover debug messages unconditionally sent to the console.

  Executing Dial(DAHDI/1/18475551212,300,) with the echotraining config
  option enabled outputs the following debug messages unconditionally:

  Dialing T1847555121 on 1
  Dialing www2w on 1

  * Made debug messages in my_dial_digits() normal debug messages that do
  not get output unless enabled.

  * Reworded some debug messages in my_dial_digits() to be clearer.

  * Replace strncpy() with ast_copy_string() in my_dial_digits() which does
  the same job better.

  (closes issue #18847)
  Reported by: vmikhelson
  Tested by: rmudgett
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@313781 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_dahdi.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index bbb5c1ac58..b11d114af6 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -2943,18 +2943,21 @@ static int my_dial_digits(void *pvt, enum analog_sub sub, struct analog_dialoper
 		return -1;
 	}
 
-	if (sub != ANALOG_SUB_REAL)
-		printf("Trying to dial digits on sub %d\n", sub);
+	if (sub != ANALOG_SUB_REAL) {
+		ast_log(LOG_ERROR, "Trying to dial_digits '%s' on channel %d subchannel %d\n",
+			dop->dialstr, p->channel, sub);
+		return -1;
+	}
 
 	ddop.op = DAHDI_DIAL_OP_REPLACE;
-	strncpy(ddop.dialstr, dop->dialstr, sizeof(ddop.dialstr));
+	ast_copy_string(ddop.dialstr, dop->dialstr, sizeof(ddop.dialstr));
 
-	printf("Dialing %s on %d\n", ddop.dialstr, p->channel);
+	ast_debug(1, "Channel %d: Sending '%s' to DAHDI_DIAL.\n", p->channel, ddop.dialstr);
 
 	res = ioctl(p->subs[index].dfd, DAHDI_DIAL, &ddop);
-
-	if (res == -1)
+	if (res == -1) {
 		ast_debug(1, "DAHDI_DIAL ioctl failed on %s: %s\n", p->owner->name, strerror(errno));
+	}
 
 	return res;
 }
-- 
GitLab