[asterisk-commits] main/cli: Use proper string methods to check existence of co... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Nov 21 11:36:43 CST 2015


Joshua Colp has submitted this change and it was merged.

Change subject: main/cli: Use proper string methods to check existence of context/exten/app
......................................................................


main/cli: Use proper string methods to check existence of context/exten/app

Because the context, extension, and application are stored in stringfields,
checking for them being NULL doesn't work so well. This patch uses the
appropriate string library call, ast_strlen_zero, to see if there is a value
in the context/exten/app values.

Change-Id: Ie09623bfdf35f5a8d3b23dd596647fe3c97b9a23
---
M main/cli.c
1 file changed, 4 insertions(+), 2 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/main/cli.c b/main/cli.c
index b3d4cac..9173055 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1076,10 +1076,12 @@
 				char locbuf[40] = "(None)";
 				char appdata[40] = "(None)";
 
-				if (!cs->context && !cs->exten)
+				if (!ast_strlen_zero(cs->context) && !ast_strlen_zero(cs->exten)) {
 					snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", cs->exten, cs->context, cs->priority);
-				if (cs->appl)
+				}
+				if (!ast_strlen_zero(cs->appl)) {
 					snprintf(appdata, sizeof(appdata), "%s(%s)", cs->appl, S_OR(cs->data, ""));
+				}
 				ast_cli(a->fd, FORMAT_STRING, cs->name, locbuf, ast_state2str(cs->state), appdata);
 			}
 		}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie09623bfdf35f5a8d3b23dd596647fe3c97b9a23
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list