[Asterisk-code-review] main/taskprocessor: Use ast cli completion add. (asterisk[master])

Joshua Colp asteriskteam at digium.com
Tue Mar 20 07:38:04 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/8596 )

Change subject: main/taskprocessor: Use ast_cli_completion_add.
......................................................................

main/taskprocessor: Use ast_cli_completion_add.

Change-Id: Ie5f812a988ed811fd11967151932de62bc131b48
---
M main/taskprocessor.c
1 file changed, 9 insertions(+), 8 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/main/taskprocessor.c b/main/taskprocessor.c
index cf82eff..91eb7d9 100644
--- a/main/taskprocessor.c
+++ b/main/taskprocessor.c
@@ -341,26 +341,27 @@
 static char *tps_taskprocessor_tab_complete(struct ast_cli_args *a)
 {
 	int tklen;
-	int wordnum = 0;
 	struct ast_taskprocessor *p;
-	char *name = NULL;
 	struct ao2_iterator i;
 
-	if (a->pos != 3)
+	if (a->pos != 3) {
 		return NULL;
+	}
 
 	tklen = strlen(a->word);
 	i = ao2_iterator_init(tps_singletons, 0);
 	while ((p = ao2_iterator_next(&i))) {
-		if (!strncasecmp(a->word, p->name, tklen) && ++wordnum > a->n) {
-			name = ast_strdup(p->name);
-			ast_taskprocessor_unreference(p);
-			break;
+		if (!strncasecmp(a->word, p->name, tklen)) {
+			if (ast_cli_completion_add(ast_strdup(p->name))) {
+				ast_taskprocessor_unreference(p);
+				break;
+			}
 		}
 		ast_taskprocessor_unreference(p);
 	}
 	ao2_iterator_destroy(&i);
-	return name;
+
+	return NULL;
 }
 
 /* ping task handling function */

-- 
To view, visit https://gerrit.asterisk.org/8596
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie5f812a988ed811fd11967151932de62bc131b48
Gerrit-Change-Number: 8596
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180320/e03944b4/attachment-0001.html>


More information about the asterisk-code-review mailing list