From 18d1d6fe4e040157b0ab57ab44f01c430aecf567 Mon Sep 17 00:00:00 2001 From: jpeeler Date: Mon, 19 Jul 2010 14:39:07 +0000 Subject: Fix regression with distinctive ring detection. The issue here is that passing an array to a function prohibits the ARRAY_LEN macro from returning the real size. To avoid this the size is now defined and use of ARRAY_LEN is avoided. (closes issue #15718) Reported by: alecdavis Patches: bug15718.patch uploaded by jpeeler (license 325) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@277837 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_dahdi.c | 6 +++--- channels/sig_analog.c | 4 ++-- channels/sig_analog.h | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'channels') diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index f94f93da6..333da603c 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -1728,7 +1728,7 @@ static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int { unsigned char buf[256]; int distMatches; - int curRingData[3]; + int curRingData[RING_PATTERNS]; int receivedRingT; int counter1; int counter; @@ -1749,7 +1749,7 @@ static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int * distinctive ringing */ if ((checkaftercid && distinctiveringaftercid) || !checkaftercid) { /* Clear the current ring data array so we don't have old data in it. */ - for (receivedRingT = 0; receivedRingT < ARRAY_LEN(ringdata); receivedRingT++) + for (receivedRingT = 0; receivedRingT < RING_PATTERNS; receivedRingT++) ringdata[receivedRingT] = 0; receivedRingT = 0; if (checkaftercid && distinctiveringaftercid) @@ -1783,7 +1783,7 @@ static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int break; /* Increment the ringT counter so we can match it against values in chan_dahdi.conf for distinctive ring */ - if (++receivedRingT == ARRAY_LEN(ringdata)) + if (++receivedRingT == RING_PATTERNS) break; } else if (i & DAHDI_IOMUX_READ) { res = read(p->subs[idx].dfd, buf, sizeof(buf)); diff --git a/channels/sig_analog.c b/channels/sig_analog.c index 6054458cf..1e84e27b5 100644 --- a/channels/sig_analog.c +++ b/channels/sig_analog.c @@ -2281,7 +2281,7 @@ static void *__analog_ss_thread(void *data) int timeout = 10000; /* Ten seconds */ struct timeval start = ast_tvnow(); enum analog_event ev; - int curRingData[3] = { 0 }; + int curRingData[RING_PATTERNS] = { 0 }; int receivedRingT = 0; namebuf[0] = 0; @@ -2315,7 +2315,7 @@ static void *__analog_ss_thread(void *data) } /* Increment the ringT counter so we can match it against values in chan_dahdi.conf for distinctive ring */ - if (++receivedRingT == ARRAY_LEN(curRingData)) { + if (++receivedRingT == RING_PATTERNS) { break; } } diff --git a/channels/sig_analog.h b/channels/sig_analog.h index 3f75e5827..e7f1ae2be 100644 --- a/channels/sig_analog.h +++ b/channels/sig_analog.h @@ -28,6 +28,10 @@ #include "asterisk/channel.h" #include "asterisk/frame.h" +#define ANALOG_MAX_CID 300 +#define READ_SIZE 160 +#define RING_PATTERNS 3 + /* Signalling types supported */ enum analog_sigtype { ANALOG_SIG_NONE = -1, @@ -110,8 +114,6 @@ enum analog_cid_start { ANALOG_CID_START_DTMF_NOALERT, }; -#define ANALOG_MAX_CID 300 - enum dialop { ANALOG_DIAL_OP_REPLACE = 2, }; @@ -221,8 +223,6 @@ struct analog_callback { -#define READ_SIZE 160 - struct analog_subchannel { struct ast_channel *owner; struct ast_frame f; /*!< One frame for each channel. How did this ever work before? */ -- cgit v1.2.3