aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c9
-rw-r--r--channels/iax2-provision.c19
2 files changed, 14 insertions, 14 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 1251c3c73..92c7e8c8e 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1975,13 +1975,14 @@ static char *complete_iax2_show_peer(char *line, char *word, int pos, int state)
int which = 0;
struct iax2_peer *p;
char *res = NULL;
+ int wordlen = strlen(word);
/* 0 - iax2; 1 - show; 2 - peer; 3 - <peername> */
- if(pos == 3) {
+ if (pos == 3) {
ast_mutex_lock(&peerl.lock);
- for(p = peerl.peers ; p ; p = p->next) {
- if(!strncasecmp(p->name, word, strlen(word))) {
- if(++which > state) {
+ for (p = peerl.peers ; p ; p = p->next) {
+ if (!strncasecmp(p->name, word, wordlen)) {
+ if (++which > state) {
res = strdup(p->name);
break;
}
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c
index c1b6f4b3d..420e79213 100644
--- a/channels/iax2-provision.c
+++ b/channels/iax2-provision.c
@@ -156,21 +156,20 @@ char *iax_prov_complete_template(char *line, char *word, int pos, int state)
{
struct iax_template *c;
int which=0;
- char *ret;
+ char *ret = NULL;
+ int wordlen = strlen(word);
+
ast_mutex_lock(&provlock);
- c = templates;
- while(c) {
- if (!strncasecmp(word, c->name, strlen(word))) {
- if (++which > state)
+ for (c = templates; c; c = c->next) {
+ if (!strncasecmp(word, c->name, wordlen)) {
+ if (++which > state) {
+ ret = strdup(c->name);
break;
+ }
}
- c = c->next;
}
- if (c) {
- ret = strdup(c->name);
- } else
- ret = NULL;
ast_mutex_unlock(&provlock);
+
return ret;
}