[Asterisk-cvs] asterisk asterisk.c,1.80,1.81 config.c,1.17,1.18 enum.c,1.15,1.16 say.c,1.25,1.26 srv.c,1.7,1.8

markster at lists.digium.com markster at lists.digium.com
Tue May 4 10:46:28 CDT 2004


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

Modified Files:
	asterisk.c config.c enum.c say.c srv.c 
Log Message:
More strlen_zero checks (bug #1549)


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- asterisk.c	3 May 2004 00:54:15 -0000	1.80
+++ asterisk.c	4 May 2004 14:54:42 -0000	1.81
@@ -31,6 +31,7 @@
 #include <asterisk/rtp.h>
 #include <asterisk/app.h>
 #include <asterisk/lock.h>
+#include <asterisk/utils.h>
 #include <sys/resource.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -546,7 +547,7 @@
 	if (option_console || option_remote) {
 		if (getenv("HOME")) 
 			snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
-		if (strlen(filename))
+		if (!ast_strlen_zero(filename))
 			ast_el_write_history(filename);
 		if (el != NULL)
 			el_end(el);
@@ -640,7 +641,7 @@
 	printf(term_end());
 	fflush(stdout);
 	/* Called when readline data is available */
-	if (s && strlen(s))
+	if (s && !ast_strlen_zero(s))
 		ast_el_add_history(s);
 	/* Give the console access to the shell */
 	if (s) {
@@ -660,7 +661,7 @@
 {
 	int ret = 0;
 	/* Called when readline data is available */
-	if (s && strlen(s))
+	if (s && !ast_strlen_zero(s))
 		ast_el_add_history(s);
 	/* Give the console access to the shell */
 	if (s) {
@@ -1334,7 +1335,7 @@
 
 	el_set(el, EL_GETCFN, ast_el_read_char);
 
-	if (strlen(filename))
+	if (!ast_strlen_zero(filename))
 		ast_el_read_history(filename);
 
 	ast_cli_register(&quit);
@@ -1350,7 +1351,7 @@
 	for(;;) {
 		ebuf = (char *)el_gets(el, &num);
 
-		if (ebuf && strlen(ebuf)) {
+		if (ebuf && !ast_strlen_zero(ebuf)) {
 			if (ebuf[strlen(ebuf)-1] == '\n')
 				ebuf[strlen(ebuf)-1] = '\0';
 			if (!remoteconsolehandler(ebuf)) {
@@ -1555,7 +1556,7 @@
                 if (el_hist == NULL || el == NULL)
                         ast_el_initialize();
 
-                if (strlen(filename))
+                if (!ast_strlen_zero(filename))
                         ast_el_read_history(filename);
 	}
 

Index: config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/config.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- config.c	2 Mar 2004 07:57:05 -0000	1.17
+++ config.c	4 May 2004 14:54:42 -0000	1.18
@@ -20,6 +20,7 @@
 #include <asterisk/config.h>
 #include <asterisk/options.h>
 #include <asterisk/logger.h>
+#include <asterisk/utils.h>
 #include "asterisk.h"
 #include "astconf.h"
 
@@ -57,7 +58,7 @@
 {
 	char *start;
 	/* Strip off trailing whitespace, returns, etc */
-	while(strlen(buf) && (buf[strlen(buf)-1]<33))
+	while(!ast_strlen_zero(buf) && (buf[strlen(buf)-1]<33))
 		buf[strlen(buf)-1] = '\0';
 	start = buf;
 	/* Strip off leading whitespace, returns, etc */
@@ -469,7 +470,7 @@
 #endif			
 	}
 	cur = strip(buf);
-	if (strlen(cur)) {
+	if (!ast_strlen_zero(cur)) {
 		/* Actually parse the entry */
 		if (cur[0] == '[') {
 			/* A category header */
@@ -525,7 +526,7 @@
 					while((*c == '<') || (*c == '>') || (*c == '\"')) c++;
 					/* Get rid of leading mess */
 					cur = c;
-					while(strlen(cur)) {
+					while(!ast_strlen_zero(cur)) {
 						c = cur + strlen(cur) - 1;
 						if ((*c == '>') || (*c == '<') || (*c == '\"'))
 							*c = '\0';

Index: enum.c
===================================================================
RCS file: /usr/cvsroot/asterisk/enum.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- enum.c	3 Mar 2004 03:12:59 -0000	1.15
+++ enum.c	4 May 2004 14:54:42 -0000	1.16
@@ -32,6 +32,7 @@
 #include <asterisk/dns.h>
 #include <asterisk/channel.h>
 #include <asterisk/config.h>
+#include <asterisk/utils.h>
 
 #ifdef __APPLE__
 #undef T_NAPTR
@@ -237,7 +238,7 @@
 		return -1;
 	}
 
-	if (strlen(c->dst))
+	if (!ast_strlen_zero(c->dst))
 		return 1;
 
 	return 0;

Index: say.c
===================================================================
RCS file: /usr/cvsroot/asterisk/say.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- say.c	4 May 2004 14:33:27 -0000	1.25
+++ say.c	4 May 2004 14:54:42 -0000	1.26
@@ -23,6 +23,7 @@
 #include <asterisk/say.h>
 #include <asterisk/lock.h>
 #include <asterisk/localtime.h>
+#include <asterisk/utils.h>
 #include "asterisk.h"
 #include <stdio.h>
 
@@ -50,7 +51,7 @@
 					snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
 				}
 		}
-		if(strlen(fn)){ /* if length == 0, then skip this digit as it is invalid */
+		if(!ast_strlen_zero(fn)){ /* if length == 0, then skip this digit as it is invalid */
 			res = ast_streamfile(chan, fn, lang);
 			if (!res)
 				res = ast_waitstream(chan, ints);
@@ -121,7 +122,7 @@
  				if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A';		/* file names are all lower-case */
  				snprintf(fn, sizeof(fn), "letters/%c", ltr);
   		}
-		if(strlen(fn)){ /* if length == 0, then skip this digit as it is invalid */
+		if(!ast_strlen_zero(fn)) { /* if length == 0, then skip this digit as it is invalid */
 			res = ast_streamfile(chan, fn, lang);
 			if (!res) 
 				res = ast_waitstream(chan, ints);
@@ -192,7 +193,7 @@
 			case ('%'):
 				play=0;
 				/* check if we have 2 chars after the % */
-				if (strlen(fn2)>num+2)
+				if (strlen(fn2) > num+2)
 				{
 				    hex[0]=fn2[num+1];
 				    hex[1]=fn2[num+2];

Index: srv.c
===================================================================
RCS file: /usr/cvsroot/asterisk/srv.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- srv.c	3 Mar 2004 03:12:59 -0000	1.7
+++ srv.c	4 May 2004 14:54:42 -0000	1.8
@@ -27,6 +27,7 @@
 #include <asterisk/srv.h>
 #include <asterisk/dns.h>
 #include <asterisk/options.h>
+#include <asterisk/utils.h>
 
 #ifdef __APPLE__
 #undef T_SRV
@@ -84,7 +85,7 @@
 		return -1;
 	}
 
-	if (strlen(c->host))
+	if (!ast_strlen_zero(c->host))
 		return 1;
 
     return 0;




More information about the svn-commits mailing list