From 9ddf0e4dcecf6ec6e2147ca6bfe58b7eeef8bced Mon Sep 17 00:00:00 2001
From: Russell Bryant <russell@russellbryant.com>
Date: Thu, 27 Oct 2005 02:19:37 +0000
Subject: [PATCH] Remove unnecessary checks before calls to ast_strlen_zero. 
 Also, change some places where strlen is used instead of ast_strlen_zero

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6866 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_agent.c     | 18 +++++++--------
 channels/chan_alsa.c      | 20 ++++++++--------
 channels/chan_h323.c      |  6 ++---
 channels/chan_iax2.c      | 22 +++++++++---------
 channels/chan_mgcp.c      | 14 ++++++------
 channels/chan_modem.c     |  4 ++--
 channels/chan_modem_i4l.c |  7 +++---
 channels/chan_nbs.c       |  3 ++-
 channels/chan_oss.c       |  6 ++---
 channels/chan_oss_old.c   | 18 +++++++--------
 channels/chan_phone.c     |  6 ++---
 channels/chan_sip.c       | 48 +++++++++++++++++++--------------------
 channels/chan_vpb.c       |  4 ++--
 channels/chan_zap.c       |  6 ++---
 14 files changed, 92 insertions(+), 90 deletions(-)

diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 4f406662bb..f5ce13d55b 100755
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -724,7 +724,7 @@ static void set_agentbycallerid(const char *callerid, const char *agent)
 	char buf[AST_MAX_BUF];
 
 	/* if there is no Caller ID, nothing to do */
-	if (!callerid || ast_strlen_zero(callerid))
+	if (ast_strlen_zero(callerid))
 		return;
 
 	snprintf(buf, sizeof(buf), "%s_%s",GETAGENTBYCALLERID, callerid);
@@ -1388,7 +1388,7 @@ static int action_agents(struct mansession *s, struct message *m)
 	char *talkingtoChan = NULL;
 	char *status = NULL;
 
-	if (id && !ast_strlen_zero(id))
+	if (!ast_strlen_zero(id))
 		snprintf(idText, sizeof(idText) ,"ActionID: %s\r\n", id);
 	astman_send_ack(s, m, "Agents will follow");
 	ast_mutex_lock(&agentlock);
@@ -1526,7 +1526,7 @@ static int action_agent_logoff(struct mansession *s, struct message *m)
 	int soft;
 	int ret; /* return value of agent_logoff */
 
-	if (!agent || ast_strlen_zero(agent)) {
+	if (ast_strlen_zero(agent)) {
 		astman_send_error(s, m, "No agent specified");
 		return 0;
 	}
@@ -1737,7 +1737,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
 		strsep(&options, "|");
 	}
 
-	while (options && !ast_strlen_zero(options)) {
+	while (!ast_strlen_zero(options)) {
 		if (*options == 's') {
 			play_announcement = 0;
 			break;
@@ -1748,7 +1748,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
 	if (chan->_state != AST_STATE_UP)
 		res = ast_answer(chan);
 	if (!res) {
-		if (opt_user && !ast_strlen_zero(opt_user))
+		if (!ast_strlen_zero(opt_user))
 			ast_copy_string(user, opt_user, AST_MAX_AGENT);
 		else
 			res = ast_app_getdata(chan, "agent-user", user, sizeof(user) - 1, 0);
@@ -1833,7 +1833,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
 								res = 0;
 							} else
 								res = ast_app_getdata(chan, "agent-newlocation", tmpchan+pos, sizeof(tmpchan) - 2, 0);
-							if (ast_strlen_zero(tmpchan) || ast_exists_extension(chan, context && !ast_strlen_zero(context) ? context : "default", tmpchan,
+							if (ast_strlen_zero(tmpchan) || ast_exists_extension(chan, !ast_strlen_zero(context) ? context : "default", tmpchan,
 													     1, NULL))
 								break;
 							if (exten) {
@@ -1841,7 +1841,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
 								exten = NULL;
 								pos = 0;
 							} else {
-								ast_log(LOG_WARNING, "Extension '%s@%s' is not valid for automatic login of agent '%s'\n", tmpchan, context && !ast_strlen_zero(context) ? context : "default", p->agent);
+								ast_log(LOG_WARNING, "Extension '%s@%s' is not valid for automatic login of agent '%s'\n", tmpchan, !ast_strlen_zero(context) ? context : "default", p->agent);
 								res = ast_streamfile(chan, "invalid", chan->language);
 								if (!res)
 									res = ast_waitstream(chan, AST_DIGIT_ANY);
@@ -1858,7 +1858,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
 						exten = tmpchan;
 						if (!res) {
 							set_agentbycallerid(p->logincallerid, NULL);
-							if (context && !ast_strlen_zero(context) && !ast_strlen_zero(tmpchan))
+							if (!ast_strlen_zero(context) && !ast_strlen_zero(tmpchan))
 								snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", tmpchan, context);
 							else {
 								ast_copy_string(last_loginchan, p->loginchan, sizeof(last_loginchan));
@@ -2183,7 +2183,7 @@ static int action_agent_callback_login(struct mansession *s, struct message *m)
 		else
 			snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", exten, context);
 
-		if (wrapuptime_s && !ast_strlen_zero(wrapuptime_s)) {
+		if (!ast_strlen_zero(wrapuptime_s)) {
 			p->wrapuptime = atoi(wrapuptime_s);
 			if (p->wrapuptime < 0)
 				p->wrapuptime = 0;
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 25b251fd43..adbce62eba 100755
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -778,12 +778,12 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
 		tmp->readformat = AST_FORMAT_SLINEAR;
 		tmp->writeformat = AST_FORMAT_SLINEAR;
 		tmp->tech_pvt = p;
-		if (strlen(p->context))
-			strncpy(tmp->context, p->context, sizeof(tmp->context)-1);
-		if (strlen(p->exten))
-			strncpy(tmp->exten, p->exten, sizeof(tmp->exten)-1);
-		if (strlen(language))
-			strncpy(tmp->language, language, sizeof(tmp->language)-1);
+		if (!ast_strlen_zero(p->context))
+			ast_copy_string(tmp->context, p->context, sizeof(tmp->context));
+		if (!ast_strlen_zero(p->exten))
+			ast_copy_string(tmp->exten, p->exten, sizeof(tmp->exten));
+		if (!ast_strlen_zero(language))
+			ast_copy_string(tmp->language, language, sizeof(tmp->language));
 		p->owner = tmp;
 		ast_setstate(tmp, state);
 		ast_mutex_lock(&usecnt_lock);
@@ -851,10 +851,10 @@ static char *autoanswer_complete(char *line, char *word, int pos, int state)
 #endif
 	switch(state) {
 	case 0:
-		if (strlen(word) && !strncasecmp(word, "on", MIN(strlen(word), 2)))
+		if (!ast_strlen_zero(word) && !strncasecmp(word, "on", MIN(strlen(word), 2)))
 			return strdup("on");
 	case 1:
-		if (strlen(word) && !strncasecmp(word, "off", MIN(strlen(word), 3)))
+		if (!ast_strlen_zero(word) && !strncasecmp(word, "off", MIN(strlen(word), 3)))
 			return strdup("off");
 	default:
 		return NULL;
@@ -1000,9 +1000,9 @@ static int console_dial(int fd, int argc, char *argv[])
 			stringp=tmp;
 			strsep(&stringp, "@");
 			tmp2 = strsep(&stringp, "@");
-			if (strlen(tmp))
+			if (!ast_strlen_zero(tmp))
 				mye = tmp;
-			if (tmp2 && strlen(tmp2))
+			if (!ast_strlen_zero(tmp2))
 				myc = tmp2;
 		}
 		if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index e98638bb50..208e817bef 100755
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -767,12 +767,12 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
 		}
 		if (!ast_strlen_zero(pvt->cid_num)) {
 			ch->cid.cid_num = strdup(pvt->cid_num);
-		} else if (pvt->cd.call_source_e164 && !ast_strlen_zero(pvt->cd.call_source_e164)) {
+		} else if (!ast_strlen_zero(pvt->cd.call_source_e164)) {
 			ch->cid.cid_num = strdup(pvt->cd.call_source_e164);
 		}
 		if (!ast_strlen_zero(pvt->cid_name)) {
 			ch->cid.cid_name = strdup(pvt->cid_name);
-		} else if (pvt->cd.call_source_e164 && !ast_strlen_zero(pvt->cd.call_source_name)) {
+		} else if (!ast_strlen_zero(pvt->cd.call_source_name)) {
 			ch->cid.cid_name = strdup(pvt->cd.call_source_name);
 		}
 		if (!ast_strlen_zero(pvt->rdnis)) {
@@ -1037,7 +1037,7 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
 		ext = NULL;
 	}
 	strtok_r(host, "/", &(h323id));		
-	if (h323id && !ast_strlen_zero(h323id)) {
+	if (!ast_strlen_zero(h323id)) {
 		h323_set_id(h323id);
 	}
 	if (ext) {
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index c901f917b3..354d107428 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1287,7 +1287,7 @@ static int iax_check_version(char *dev)
 {
 	int res = 0;
 	struct iax_firmware *cur;
-	if (dev && !ast_strlen_zero(dev)) {
+	if (!ast_strlen_zero(dev)) {
 		ast_mutex_lock(&waresl.lock);
 		cur = waresl.wares;
 		while(cur) {
@@ -1309,7 +1309,7 @@ static int iax_firmware_append(struct iax_ie_data *ied, const unsigned char *dev
 	unsigned int start = (desc >> 8) & 0xffffff;
 	unsigned int bytes;
 	struct iax_firmware *cur;
-	if (dev && !ast_strlen_zero((char *)dev) && bs) {
+	if (!ast_strlen_zero((char *)dev) && bs) {
 		start *= bs;
 		ast_mutex_lock(&waresl.lock);
 		cur = waresl.wares;
@@ -2836,7 +2836,7 @@ struct parsed_dial_string {
  */
 static void parse_dial_string(char *data, struct parsed_dial_string *pds)
 {
-	if (!data || ast_strlen_zero(data))
+	if (ast_strlen_zero(data))
 		return;
 
 	pds->peer = strsep(&data, "/");
@@ -2953,9 +2953,9 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
 	if (ast_test_flag(iaxs[callno], IAX_SENDANI) && c->cid.cid_ani)
 		iax_ie_append_str(&ied, IAX_IE_CALLING_ANI, c->cid.cid_ani);
 
-	if (c->language && !ast_strlen_zero(c->language))
+	if (!ast_strlen_zero(c->language))
 		iax_ie_append_str(&ied, IAX_IE_LANGUAGE, c->language);
-	if (c->cid.cid_dnid && !ast_strlen_zero(c->cid.cid_dnid))
+	if (!ast_strlen_zero(c->cid.cid_dnid))
 		iax_ie_append_str(&ied, IAX_IE_DNID, c->cid.cid_dnid);
 
 	if (pds.context)
@@ -4288,7 +4288,7 @@ static int manager_iax2_show_peers( struct mansession *s, struct message *m )
 	int ret;
 	char *id;
 	id = astman_get_header(m,"ActionID");
-	if (id && !ast_strlen_zero(id))
+	if (!ast_strlen_zero(id))
 		ast_cli(s->fd, "ActionID: %s\r\n",id);
 	ret = __iax2_show_peers(1, s->fd, 3, a );
 	ast_cli(s->fd, "\r\n\r\n" );
@@ -5123,9 +5123,9 @@ static int authenticate(char *challenge, char *secret, char *keyn, int authmetho
 	int res = -1;
 	int x;
 	char iabuf[INET_ADDRSTRLEN];
-	if (keyn && !ast_strlen_zero(keyn)) {
+	if (!ast_strlen_zero(keyn)) {
 		if (!(authmethods & IAX_AUTH_RSA)) {
-			if (!secret || ast_strlen_zero(secret)) 
+			if (ast_strlen_zero(secret)) 
 				ast_log(LOG_NOTICE, "Asked to authenticate to %s with an RSA key, but they don't allow RSA authentication\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
 		} else if (ast_strlen_zero(challenge)) {
 			ast_log(LOG_NOTICE, "No challenge provided for RSA authentication to %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
@@ -5147,7 +5147,7 @@ static int authenticate(char *challenge, char *secret, char *keyn, int authmetho
 		}
 	} 
 	/* Fall back */
-	if (res && secret && !ast_strlen_zero(secret)) {
+	if (res && !ast_strlen_zero(secret)) {
 		if ((authmethods & IAX_AUTH_MD5) && !ast_strlen_zero(challenge)) {
 			struct MD5Context md5;
 			unsigned char digest[16];
@@ -5194,7 +5194,7 @@ static int authenticate_reply(struct chan_iax2_pvt *p, struct sockaddr_in *sin,
 		p->encmethods = 0;
 
 	/* Check for override RSA authentication first */
-	if ((override && !ast_strlen_zero(override)) || (okey && !ast_strlen_zero(okey))) {
+	if (!ast_strlen_zero(override) || !ast_strlen_zero(okey)) {
 		/* Normal password authentication */
 		res = authenticate(p->challenge, override, okey, authmethods, &ied, sin, &p->ecx, &p->dcx);
 	} else {
@@ -7681,7 +7681,7 @@ static int iax2_prov_app(struct ast_channel *chan, void *data)
 	int force =0;
 	unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
 	char iabuf[INET_ADDRSTRLEN];
-	if (!data || ast_strlen_zero(data))
+	if (ast_strlen_zero(data))
 		data = "default";
 	sdata = ast_strdupa(data);
 	opts = strchr(sdata, '|');
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 329c72da17..a560fd3359 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -905,7 +905,7 @@ static int mgcp_call(struct ast_channel *ast, char *dest, int timeout)
 	ast_mutex_lock(&sub->lock);
 	switch (p->hookstate) {
 	case MGCP_OFFHOOK:
-		if (distinctive_ring && !ast_strlen_zero(distinctive_ring)) {
+		if (!ast_strlen_zero(distinctive_ring)) {
 			snprintf(tone, sizeof(tone), "L/wt%s", distinctive_ring);
 			if (mgcpdebug) {
 				ast_verbose(VERBOSE_PREFIX_3 "MGCP distinctive callwait %s\n", tone);
@@ -919,7 +919,7 @@ static int mgcp_call(struct ast_channel *ast, char *dest, int timeout)
 		break;
 	case MGCP_ONHOOK:
 	default:
-		if (distinctive_ring && !ast_strlen_zero(distinctive_ring)) {
+		if (!ast_strlen_zero(distinctive_ring)) {
 			snprintf(tone, sizeof(tone), "L/r%s", distinctive_ring);
 			if (mgcpdebug) {
 				ast_verbose(VERBOSE_PREFIX_3 "MGCP distinctive ring %s\n", tone);
@@ -1801,7 +1801,7 @@ static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
 	/* Scan through the RTP payload types specified in a "m=" line: */
 	ast_rtp_pt_clear(sub->rtp);
 	codecs = ast_strdupa(m + len);
-	while (codecs && !ast_strlen_zero(codecs)) {
+	while (!ast_strlen_zero(codecs)) {
 		if (sscanf(codecs, "%d%n", &codec, &len) != 1) {
 			if (codec_count)
 				break;
@@ -3314,7 +3314,7 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
 		/* Must have at least one header */
 		return 1;
 	}
-	if (!req.identifier || ast_strlen_zero(req.identifier)) {
+	if (ast_strlen_zero(req.identifier)) {
 		ast_log(LOG_NOTICE, "Message from %s missing identifier\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
 		return 1;
 	}
@@ -3356,9 +3356,9 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
 				gw->name, ident);
 		}
 	} else {
-		if (!req.endpoint || ast_strlen_zero(req.endpoint) || 
-		    !req.version || ast_strlen_zero(req.version) || 
-			!req.verb || ast_strlen_zero(req.verb)) {
+		if (ast_strlen_zero(req.endpoint) || 
+		    	ast_strlen_zero(req.version) || 
+			ast_strlen_zero(req.verb)) {
 			ast_log(LOG_NOTICE, "Message must have a verb, an idenitifier, version, and endpoint\n");
 			return 1;
 		}
diff --git a/channels/chan_modem.c b/channels/chan_modem.c
index 3eb3ce5006..d01c13ac5a 100755
--- a/channels/chan_modem.c
+++ b/channels/chan_modem.c
@@ -580,9 +580,9 @@ struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state)
 		if (!ast_strlen_zero(i->cid_name))
 			tmp->cid.cid_name = strdup(i->cid_name);
 
-		if (strlen(i->language))
+		if (!ast_strlen_zero(i->language))
 			strncpy(tmp->language,i->language, sizeof(tmp->language)-1);
-		if (strlen(i->dnid))
+		if (!ast_strlen_zero(i->dnid))
 			strncpy(tmp->exten, i->dnid, sizeof(tmp->exten) - 1);
 		i->owner = tmp;
 		ast_mutex_lock(&usecnt_lock);
diff --git a/channels/chan_modem_i4l.c b/channels/chan_modem_i4l.c
index 0a5e1d1362..fd875a592b 100755
--- a/channels/chan_modem_i4l.c
+++ b/channels/chan_modem_i4l.c
@@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/callerid.h"
 #include "asterisk/ulaw.h"
 #include "asterisk/pbx.h"
+#include "asterisk/utils.h"
 
 #define STATE_COMMAND 	0
 #define STATE_VOICE 	1
@@ -178,7 +179,7 @@ static int i4l_init(struct ast_modem_pvt *p)
 		ast_log(LOG_WARNING, "Unable to set to voice mode\n");
 		return -1;
 	}
-	if (strlen(p->msn)) {
+	if (!ast_strlen_zero(p->msn)) {
 		snprintf(cmd, sizeof(cmd), "AT&E%s", p->msn);
 		if (ast_modem_send(p, cmd, 0) ||
 		    ast_modem_expect(p, "OK", 5)) {
@@ -186,7 +187,7 @@ static int i4l_init(struct ast_modem_pvt *p)
 			return -1;
 		}
 	}
-	if (strlen(p->incomingmsn)) {
+	if (!ast_strlen_zero(p->incomingmsn)) {
 		char *q;
 		snprintf(cmd, sizeof(cmd), "AT&L%s", p->incomingmsn);
 		/* translate , into ; since that is the seperator I4L uses, but can't be directly */
@@ -632,7 +633,7 @@ static int i4l_dial(struct ast_modem_pvt *p, char *stuff)
 	/* Find callerid number first, to set the correct A number */
 	if (c && c->cid.cid_num && !(c->cid.cid_pres & 0x20)) {
 	    snprintf(tmpmsn, sizeof(tmpmsn), ",%s,", c->cid.cid_num);
-	    if(strlen(p->outgoingmsn) && strstr(p->outgoingmsn,tmpmsn) != NULL) {
+	    if(!ast_strlen_zero(p->outgoingmsn) && strstr(p->outgoingmsn,tmpmsn) != NULL) {
 	      /* Tell ISDN4Linux to use this as A number */
 	      snprintf(cmd, sizeof(cmd), "AT&E%s\n", c->cid.cid_num);
 	      if (ast_modem_send(p, cmd, strlen(cmd))) {
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index 3c6583f8f6..edb989c104 100755
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -45,6 +45,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/module.h"
 #include "asterisk/pbx.h"
 #include "asterisk/options.h"
+#include "asterisk/utils.h"
 
 static const char desc[] = "Network Broadcast Sound Support";
 static const char type[] = "NBS";
@@ -135,7 +136,7 @@ static struct nbs_pvt *nbs_alloc(void *data)
 	p = malloc(sizeof(struct nbs_pvt));
 	if (p) {
 		memset(p, 0, sizeof(struct nbs_pvt));
-		if (strlen(opts)) {
+		if (!ast_strlen_zero(opts)) {
 			if (strchr(opts, 'm'))
 				flags |= NBS_FLAG_MUTE;
 			if (strchr(opts, 'o'))
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index eb5065382b..ef163f43ad 100755
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -881,11 +881,11 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o,
 	c->writeformat = AST_FORMAT_SLINEAR;
 	c->tech_pvt = o;
 
-	if (ctx && !ast_strlen_zero(ctx))
+	if (!ast_strlen_zero(ctx))
 		ast_copy_string(c->context, ctx, sizeof(c->context));
-	if (ext && !ast_strlen_zero(ext))
+	if (!ast_strlen_zero(ext))
 		ast_copy_string(c->exten, ext, sizeof(c->exten));
-	if (o->language && !ast_strlen_zero(o->language))
+	if (!ast_strlen_zero(o->language))
 		ast_copy_string(c->language, o->language, sizeof(c->language));
 
 	o->owner = c;
diff --git a/channels/chan_oss_old.c b/channels/chan_oss_old.c
index 27f8d46feb..dc5db42191 100755
--- a/channels/chan_oss_old.c
+++ b/channels/chan_oss_old.c
@@ -770,11 +770,11 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state)
 		tmp->readformat = AST_FORMAT_SLINEAR;
 		tmp->writeformat = AST_FORMAT_SLINEAR;
 		tmp->tech_pvt = p;
-		if (strlen(p->context))
+		if (!ast_strlen_zero(p->context))
 			strncpy(tmp->context, p->context, sizeof(tmp->context)-1);
-		if (strlen(p->exten))
+		if (!ast_strlen_zero(p->exten))
 			strncpy(tmp->exten, p->exten, sizeof(tmp->exten)-1);
-		if (strlen(language))
+		if (!ast_strlen_zero(language))
 			strncpy(tmp->language, language, sizeof(tmp->language)-1);
 		p->owner = tmp;
 		ast_setstate(tmp, state);
@@ -839,10 +839,10 @@ static char *autoanswer_complete(char *line, char *word, int pos, int state)
 #endif
 	switch(state) {
 	case 0:
-		if (strlen(word) && !strncasecmp(word, "on", MIN(strlen(word), 2)))
+		if (!ast_strlen_zero(word) && !strncasecmp(word, "on", MIN(strlen(word), 2)))
 			return strdup("on");
 	case 1:
-		if (strlen(word) && !strncasecmp(word, "off", MIN(strlen(word), 3)))
+		if (!ast_strlen_zero(word) && !strncasecmp(word, "off", MIN(strlen(word), 3)))
 			return strdup("off");
 	default:
 		return NULL;
@@ -887,14 +887,14 @@ static int console_sendtext(int fd, int argc, char *argv[])
 		ast_cli(fd, "No one is calling us\n");
 		return RESULT_FAILURE;
 	}
-	if (strlen(text2send))
+	if (!ast_strlen_zero(text2send))
 		ast_cli(fd, "Warning: message already waiting to be sent, overwriting\n");
 	text2send[0] = '\0';
 	while(tmparg < argc) {
 		strncat(text2send, argv[tmparg++], sizeof(text2send) - strlen(text2send) - 1);
 		strncat(text2send, " ", sizeof(text2send) - strlen(text2send) - 1);
 	}
-	if (strlen(text2send)) {
+	if (!ast_strlen_zero(text2send)) {
 		f.frametype = AST_FRAME_TEXT;
 		f.subclass = 0;
 		f.data = text2send;
@@ -978,9 +978,9 @@ static int console_dial(int fd, int argc, char *argv[])
 		stringp=tmp;
 		strsep(&stringp, "@");
 		tmp2 = strsep(&stringp, "@");
-		if (strlen(tmp))
+		if (!ast_strlen_zero(tmp))
 			mye = tmp;
-		if (tmp2 && strlen(tmp2))
+		if (!ast_strlen_zero(tmp2))
 			myc = tmp2;
 	}
 	if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index e1a65b2da6..03fe43608a 100755
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -261,7 +261,7 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
 		snprintf(cid.min, sizeof(cid.min),     "%02d", tm.tm_min);
 	}
 	/* the standard format of ast->callerid is:  "name" <number>, but not always complete */
-	if (!ast->cid.cid_name || ast_strlen_zero(ast->cid.cid_name))
+	if (ast_strlen_zero(ast->cid.cid_name))
 		strncpy(cid.name, DEFAULT_CALLER_ID, sizeof(cid.name) - 1);
 	else
 		strncpy(cid.name, ast->cid.cid_name, sizeof(cid.name) - 1);
@@ -818,11 +818,11 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
 			tmp->rings = 1;
 		tmp->tech_pvt = i;
 		strncpy(tmp->context, context, sizeof(tmp->context)-1);
-		if (strlen(i->ext))
+		if (!ast_strlen_zero(i->ext))
 			strncpy(tmp->exten, i->ext, sizeof(tmp->exten)-1);
 		else
 			strncpy(tmp->exten, "s",  sizeof(tmp->exten) - 1);
-		if (strlen(i->language))
+		if (!ast_strlen_zero(i->language))
 			strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
 		if (!ast_strlen_zero(i->cid_num))
 			tmp->cid.cid_num = strdup(i->cid_num);
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index afefb5032d..31f9f803a9 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -949,7 +949,7 @@ int find_sip_method(char *msg)
 {
 	int i, res = 0;
 	
-	if (!msg || ast_strlen_zero(msg))
+	if (ast_strlen_zero(msg))
 		return 0;
 
 	for (i = 1; (i < (sizeof(sip_methods) / sizeof(sip_methods[0]))) && !res; i++) {
@@ -968,7 +968,7 @@ unsigned int parse_sip_options(struct sip_pvt *pvt, char *supported)
 	int i;
 	unsigned int profile = 0;
 
-	if (!supported || ast_strlen_zero(supported) )
+	if (ast_strlen_zero(supported) )
 		return 0;
 
 	if (option_debug > 2 && sipdebug)
@@ -1554,7 +1554,7 @@ static int sip_sendtext(struct ast_channel *ast, const char *text)
 		ast_verbose("Sending text %s on %s\n", text, ast->name);
 	if (!p)
 		return -1;
-	if (!text || ast_strlen_zero(text))
+	if (ast_strlen_zero(text))
 		return 0;
 	if (debug)
 		ast_verbose("Really sending text %s on %s\n", text, ast->name);
@@ -3177,7 +3177,7 @@ static int sip_register(char *value, int lineno)
 		*hostname = '\0';
 		hostname++;
 	}
-	if (!username || ast_strlen_zero(username) || !hostname || ast_strlen_zero(hostname)) {
+	if (ast_strlen_zero(username) || ast_strlen_zero(hostname)) {
 		ast_log(LOG_WARNING, "Format for registration is user[:secret[:authuser]]@host[:port][/contact] at line %d\n", lineno);
 		return -1;
 	}
@@ -3192,7 +3192,7 @@ static int sip_register(char *value, int lineno)
 	hostname = strsep(&stringp, "/");
 	if (hostname) 
 		contact = strsep(&stringp, "/");
-	if (!contact || ast_strlen_zero(contact))
+	if (ast_strlen_zero(contact))
 		contact = "s";
 	stringp=hostname;
 	hostname = strsep(&stringp, ":");
@@ -4575,7 +4575,7 @@ static void extract_uri(struct sip_pvt *p, struct sip_request *req)
 	n = strchr(c, ';');
 	if (n)
 		*n = '\0';
-	if (c && !ast_strlen_zero(c))
+	if (!ast_strlen_zero(c))
 		ast_copy_string(p->uri, c, sizeof(p->uri));
 }
 
@@ -4613,7 +4613,7 @@ static void build_rpid(struct sip_pvt *p)
 	if (p->owner && p->owner->cid.cid_name) {
 		clin = strdup(p->owner->cid.cid_name);
 	}
-	if (!clin || ast_strlen_zero(clin))
+	if (ast_strlen_zero(clin))
 		clin = clid;
 
 	switch (p->callingpres) {
@@ -4728,7 +4728,7 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
 	}
 	if (!l)
 		l = default_callerid;
-	if (!n || ast_strlen_zero(n))
+	if (ast_strlen_zero(n))
 		n = l;
 	/* Allow user to be overridden */
 	if (!ast_strlen_zero(p->fromuser))
@@ -5099,7 +5099,7 @@ static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs,
 	add_header(&req, "Content-Type", default_notifymime);
 
 	ast_build_string(&t, &maxbytes, "Messages-Waiting: %s\r\n", newmsgs ? "yes" : "no");
-	ast_build_string(&t, &maxbytes, "Message-Account: sip:%s@%s\r\n", (vmexten && !ast_strlen_zero(vmexten)) ? vmexten : global_vmexten, p->fromdomain);
+	ast_build_string(&t, &maxbytes, "Message-Account: sip:%s@%s\r\n", !ast_strlen_zero(vmexten) ? vmexten : global_vmexten, p->fromdomain);
 	ast_build_string(&t, &maxbytes, "Voice-Message: %d/%d (0/0)\r\n", newmsgs, oldmsgs);
 
 	if (t > tmp + sizeof(tmp))
@@ -5391,7 +5391,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, char *auth,
 	
 	/* Fromdomain is what we are registering to, regardless of actual
 	   host name from SRV */
-	if (p->fromdomain && !ast_strlen_zero(p->fromdomain))
+	if (!ast_strlen_zero(p->fromdomain))
 		snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
 	else
 		snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
@@ -5418,7 +5418,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, char *auth,
 	
 	if (auth) 	/* Add auth header */
 		add_header(&req, authheader, auth);
-	else if ( !ast_strlen_zero(r->nonce) ) {
+	else if (!ast_strlen_zero(r->nonce)) {
 		char digest[1024];
 
 		/* We have auth data to reuse, build a digest header! */
@@ -5778,7 +5778,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
 	   what we currently have stored as their contact address, so return
 	   it
 	*/
-	if (ast_strlen_zero(c) && (!expires || ast_strlen_zero(expires))) {
+	if (ast_strlen_zero(c) && ast_strlen_zero(expires)) {
 		if ((p->expire > -1) && !ast_strlen_zero(p->fullcontact)) {
 			/* tell them when the registration is going to expire */
 			pvt->expiry = ast_sched_when(sched, p->expire);
@@ -7364,7 +7364,7 @@ static int manager_sip_show_peers( struct mansession *s, struct message *m )
 	char idtext[256] = "";
 	int total = 0;
 
-	if (id && !ast_strlen_zero(id))
+	if (!ast_strlen_zero(id))
 		snprintf(idtext,256,"ActionID: %s\r\n",id);
 
 	astman_send_ack(s, m, "Peer status list will follow");
@@ -7404,7 +7404,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
 
 	if (s) {	/* Manager - get ActionID */
 		id = astman_get_header(m,"ActionID");
-		if (id && !ast_strlen_zero(id))
+		if (!ast_strlen_zero(id))
 			snprintf(idtext,256,"ActionID: %s\r\n",id);
 	}
 
@@ -7784,7 +7784,7 @@ static int manager_sip_show_peer( struct mansession *s, struct message *m )
 	int ret;
 
 	peer = astman_get_header(m,"Peer");
-	if (!peer || ast_strlen_zero(peer)) {
+	if (ast_strlen_zero(peer)) {
 		astman_send_error(s, m, "Peer: <name> missing.\n");
 		return 0;
 	}
@@ -7793,7 +7793,7 @@ static int manager_sip_show_peer( struct mansession *s, struct message *m )
 	a[2] = "peer";
 	a[3] = peer;
 
-	if (id && !ast_strlen_zero(id))
+	if (!ast_strlen_zero(id))
 		ast_cli(s->fd, "ActionID: %s\r\n",id);
 	ret = _sip_show_peer(1, s->fd, s, m, 4, a );
 	ast_cli( s->fd, "\r\n\r\n" );
@@ -9131,7 +9131,7 @@ static struct ast_custom_function sip_header_function = {
 /*! \brief  function_check_sipdomain: Dial plan function to check if domain is local */
 static char *func_check_sipdomain(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
-	if (!data || ast_strlen_zero(data)) {
+	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "CHECKSIPDOMAIN requires an argument - A domain name\n");
 		return buf;
 	}
@@ -10185,7 +10185,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
 			parse_sip_options(p, supported);
 	}
 	required = get_header(req, "Required");
-	if (required && !ast_strlen_zero(required)) {
+	if (!ast_strlen_zero(required)) {
 		required_profile = parse_sip_options(NULL, required);
 		if (required_profile) { 	/* They require something */
 			/* At this point we support no extensions, so fail */
@@ -10641,7 +10641,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
 			return 0;
 		}
 		/* Initialize the context if it hasn't been already */
-		if (p->subscribecontext && !ast_strlen_zero(p->subscribecontext))
+		if (!ast_strlen_zero(p->subscribecontext))
 			ast_copy_string(p->context, p->subscribecontext, sizeof(p->context));
 		else if (ast_strlen_zero(p->context))
 			strcpy(p->context, default_context);
@@ -11589,7 +11589,7 @@ static int add_sip_domain(const char *domain, const enum domain_mode mode, const
 {
 	struct domain *d;
 
-	if (!domain || ast_strlen_zero(domain)) {
+	if (ast_strlen_zero(domain)) {
 		ast_log(LOG_WARNING, "Zero length domain.\n");
 		return 1;
 	}
@@ -11602,7 +11602,7 @@ static int add_sip_domain(const char *domain, const enum domain_mode mode, const
 
 	ast_copy_string(d->domain, domain, sizeof(d->domain));
 
-	if (context && !ast_strlen_zero(context))
+	if (!ast_strlen_zero(context))
 		ast_copy_string(d->context, context, sizeof(d->context));
 
 	d->mode = mode;
@@ -11660,7 +11660,7 @@ static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char
 	struct sip_auth *auth;
 	struct sip_auth *b = NULL, *a = authlist;
 
-	if (!configuration || ast_strlen_zero(configuration))
+	if (ast_strlen_zero(configuration))
 		return authlist;
 
 	ast_log(LOG_DEBUG, "Auth config ::  %s\n", configuration);
@@ -11674,7 +11674,7 @@ static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char
 		*realm = '\0';
 		realm++;
 	}
-	if (!username || ast_strlen_zero(username) || !realm || ast_strlen_zero(realm)) {
+	if (ast_strlen_zero(username) || ast_strlen_zero(realm)) {
 		ast_log(LOG_WARNING, "Format for authentication entry is user[:secret]@realm at line %d\n", lineno);
 		return authlist;
 	}
@@ -12378,7 +12378,7 @@ static int reload_config(void)
 
 			if (ast_strlen_zero(domain))
 				ast_log(LOG_WARNING, "Empty domain specified at line %d\n", v->lineno);
-			else if (context && ast_strlen_zero(context))
+			else if (ast_strlen_zero(context))
 				ast_log(LOG_WARNING, "Empty context specified at line %d for domain '%s'\n", v->lineno, domain);
 			else
 				add_sip_domain(ast_strip(domain), SIP_DOMAIN_CONFIG, context ? ast_strip(context) : "");
diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c
index f27fb4fe2d..2920e4d3fa 100755
--- a/channels/chan_vpb.c
+++ b/channels/chan_vpb.c
@@ -778,10 +778,10 @@ static void get_callerid_ast(struct vpb_pvt *p)
 	}
 	if (number)
 		ast_shrink_phone_number(number);
-	if (number && !ast_strlen_zero(number)) {
+	if (!ast_strlen_zero(number)) {
 		owner->cid.cid_num = strdup(number);
 		owner->cid.cid_ani = strdup(number);
-		if (name && !ast_strlen_zero(name)){
+		if (!ast_strlen_zero(name)){
 			owner->cid.cid_name = strdup(name);
 			snprintf(p->callerid,(sizeof(p->callerid)-1),"%s %s",number,name);
 		}
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index de6448459d..4d9073416d 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -9103,7 +9103,7 @@ static int handle_pri_set_debug_file(int fd, int argc, char **argv)
 		if (argc < 5) 
 			return RESULT_SHOWUSAGE;
 
-		if (!argv[4] || ast_strlen_zero(argv[4]))
+		if (ast_strlen_zero(argv[4]))
 			return RESULT_SHOWUSAGE;
 
 		myfd = open(argv[4], O_CREAT|O_WRONLY);
@@ -9897,7 +9897,7 @@ static int action_zapshowchannels(struct mansession *s, struct message *m)
 	char idText[256] = "";
 
 	astman_send_ack(s, m, "Zapata channel status will follow");
-	if (id && !ast_strlen_zero(id))
+	if (!ast_strlen_zero(id))
 		snprintf(idText, sizeof(idText) - 1, "ActionID: %s\r\n", id);
 
 	ast_mutex_lock(&iflock);
@@ -10300,7 +10300,7 @@ static int setup_zap(int reload)
 			else
 				callprogress &= ~6;
 		} else if (!strcasecmp(v->name, "echocancel")) {
-			if (v->value && !ast_strlen_zero(v->value)) {
+			if (!ast_strlen_zero(v->value)) {
 				y = atoi(v->value);
 			} else
 				y = 0;
-- 
GitLab