[Asterisk-cvs] asterisk/channels chan_agent.c, 1.161, 1.162 chan_alsa.c, 1.50, 1.51 chan_h323.c, 1.131, 1.132 chan_iax2.c, 1.363, 1.364 chan_mgcp.c, 1.131, 1.132 chan_modem.c, 1.47, 1.48 chan_modem_i4l.c, 1.32, 1.33 chan_nbs.c, 1.19, 1.20 chan_oss.c, 1.59, 1.60 chan_oss_old.c, 1.2, 1.3 chan_phone.c, 1.57, 1.58 chan_sip.c, 1.897, 1.898 chan_vpb.c, 1.97, 1.98 chan_zap.c, 1.535, 1.536

russell russell
Wed Oct 26 22:26:51 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv20403/channels

Modified Files:
	chan_agent.c chan_alsa.c chan_h323.c chan_iax2.c chan_mgcp.c 
	chan_modem.c chan_modem_i4l.c chan_nbs.c chan_oss.c 
	chan_oss_old.c chan_phone.c chan_sip.c chan_vpb.c chan_zap.c 
Log Message:
Remove unnecessary checks before calls to ast_strlen_zero.  Also, change
some places where strlen is used instead of ast_strlen_zero


Index: chan_agent.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_agent.c,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- chan_agent.c	26 Oct 2005 16:16:05 -0000	1.161
+++ chan_agent.c	27 Oct 2005 02:19:37 -0000	1.162
@@ -724,7 +724,7 @@
 	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 @@
 	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 @@
 	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 @@
 		strsep(&options, "|");
 	}
 
-	while (options && !ast_strlen_zero(options)) {
+	while (!ast_strlen_zero(options)) {
 		if (*options == 's') {
 			play_announcement = 0;
 			break;
@@ -1748,7 +1748,7 @@
 	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 @@
 								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 @@
 								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 @@
 						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 @@
 		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;

Index: chan_alsa.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_alsa.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- chan_alsa.c	24 Oct 2005 20:12:05 -0000	1.50
+++ chan_alsa.c	27 Oct 2005 02:19:37 -0000	1.51
@@ -778,12 +778,12 @@
 		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 @@
 #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 @@
 			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)) {

Index: chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- chan_h323.c	24 Oct 2005 20:12:05 -0000	1.131
+++ chan_h323.c	27 Oct 2005 02:19:37 -0000	1.132
@@ -767,12 +767,12 @@
 		}
 		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 @@
 		ext = NULL;
 	}
 	strtok_r(host, "/", &(h323id));		
-	if (h323id && !ast_strlen_zero(h323id)) {
+	if (!ast_strlen_zero(h323id)) {
 		h323_set_id(h323id);
 	}
 	if (ext) {

Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.363
retrieving revision 1.364
diff -u -d -r1.363 -r1.364
--- chan_iax2.c	26 Oct 2005 17:07:51 -0000	1.363
+++ chan_iax2.c	27 Oct 2005 02:19:37 -0000	1.364
@@ -1287,7 +1287,7 @@
 {
 	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 @@
 	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 @@
  */
 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 @@
 	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 @@
 	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 @@
 	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 @@
 		}
 	} 
 	/* 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 @@
 		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 @@
 	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, '|');

Index: chan_mgcp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- chan_mgcp.c	24 Oct 2005 20:12:05 -0000	1.131
+++ chan_mgcp.c	27 Oct 2005 02:19:37 -0000	1.132
@@ -905,7 +905,7 @@
 	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 @@
 		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 @@
 	/* 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 @@
 		/* 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 @@
 				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;
 		}

Index: chan_modem.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_modem.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- chan_modem.c	24 Oct 2005 20:12:05 -0000	1.47
+++ chan_modem.c	27 Oct 2005 02:19:37 -0000	1.48
@@ -580,9 +580,9 @@
 		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);

Index: chan_modem_i4l.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_modem_i4l.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- chan_modem_i4l.c	24 Oct 2005 20:12:05 -0000	1.32
+++ chan_modem_i4l.c	27 Oct 2005 02:19:37 -0000	1.33
@@ -44,6 +44,7 @@
 #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 @@
 		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 @@
 			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 @@
 	/* 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))) {

Index: chan_nbs.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_nbs.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- chan_nbs.c	24 Oct 2005 20:12:05 -0000	1.19
+++ chan_nbs.c	27 Oct 2005 02:19:37 -0000	1.20
@@ -45,6 +45,7 @@
 #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 @@
 	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'))

Index: chan_oss.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_oss.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- chan_oss.c	24 Oct 2005 20:12:05 -0000	1.59
+++ chan_oss.c	27 Oct 2005 02:19:37 -0000	1.60
@@ -881,11 +881,11 @@
 	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;

Index: chan_oss_old.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_oss_old.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- chan_oss_old.c	14 Sep 2005 20:46:49 -0000	1.2
+++ chan_oss_old.c	27 Oct 2005 02:19:37 -0000	1.3
@@ -770,11 +770,11 @@
 		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 @@
 #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 @@
 		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 @@
 		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)) {

Index: chan_phone.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_phone.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- chan_phone.c	24 Oct 2005 20:12:05 -0000	1.57
+++ chan_phone.c	27 Oct 2005 02:19:37 -0000	1.58
@@ -261,7 +261,7 @@
 		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 @@
 			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);

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.897
retrieving revision 1.898
diff -u -d -r1.897 -r1.898
--- chan_sip.c	26 Oct 2005 13:03:17 -0000	1.897
+++ chan_sip.c	27 Oct 2005 02:19:37 -0000	1.898
@@ -949,7 +949,7 @@
 {
 	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 @@
 	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 @@
 		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 @@
 		*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 @@
 	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 @@
 	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 @@
 	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 @@
 	}
 	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 @@
 	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 @@
 	
 	/* 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 @@
 	
 	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 @@
 	   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 @@
 	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 @@
 
 	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 @@
 	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 @@
 	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 @@
 /*! \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 @@
 			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 @@
 			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 @@
 {
 	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 @@
 
 	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 @@
 	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 @@
 		*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 @@
 
 			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) : "");

Index: chan_vpb.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_vpb.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- chan_vpb.c	24 Oct 2005 20:12:05 -0000	1.97
+++ chan_vpb.c	27 Oct 2005 02:19:37 -0000	1.98
@@ -778,10 +778,10 @@
 	}
 	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);
 		}

Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.535
retrieving revision 1.536
diff -u -d -r1.535 -r1.536
--- chan_zap.c	24 Oct 2005 20:12:05 -0000	1.535
+++ chan_zap.c	27 Oct 2005 02:19:37 -0000	1.536
@@ -9103,7 +9103,7 @@
 		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 @@
 	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 @@
 			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;




More information about the svn-commits mailing list