[asterisk-commits] trunk - r8362 in /trunk: app.c callerid.c channel.c pbx.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jan 20 17:42:27 MST 2006


Author: russell
Date: Fri Jan 20 18:42:25 2006
New Revision: 8362

URL: http://svn.digium.com/view/asterisk?rev=8362&view=rev
Log:
remove some useless checks after calls to ast_strdupa

Modified:
    trunk/app.c
    trunk/callerid.c
    trunk/channel.c
    trunk/pbx.c

Modified: trunk/app.c
URL: http://svn.digium.com/view/asterisk/trunk/app.c?rev=8362&r1=8361&r2=8362&view=diff
==============================================================================
--- trunk/app.c (original)
+++ trunk/app.c Fri Jan 20 18:42:25 2006
@@ -1358,12 +1358,11 @@
 	case AST_ACTION_BACKLIST:
 		res = 0;
 		c = ast_strdupa(option->adata);
-		if (c) {
-			while((n = strsep(&c, ";")))
-				if ((res = ast_streamfile(chan, n, chan->language)) || (res = ast_waitstream(chan, (option->action == AST_ACTION_BACKLIST) ? AST_DIGIT_ANY : "")))
-					break;
-			ast_stopstream(chan);
-		}
+		while ((n = strsep(&c, ";"))) {
+			if ((res = ast_streamfile(chan, n, chan->language)) || (res = ast_waitstream(chan, (option->action == AST_ACTION_BACKLIST) ? AST_DIGIT_ANY : "")))
+				break;
+		}
+		ast_stopstream(chan);
 		return res;
 	default:
 		ast_log(LOG_NOTICE, "Unknown dispatch function %d, ignoring!\n", option->action);

Modified: trunk/callerid.c
URL: http://svn.digium.com/view/asterisk/trunk/callerid.c?rev=8362&r1=8361&r2=8362&view=diff
==============================================================================
--- trunk/callerid.c (original)
+++ trunk/callerid.c Fri Jan 20 18:42:25 2006
@@ -995,12 +995,8 @@
 {
 	char *tmp;
 	char *l = NULL, *n = NULL;
+	
 	tmp = ast_strdupa(buf);
-	if (!tmp) {
-		name[0] = '\0';
-		num[0] = '\0';
-		return -1;
-	}
 	ast_callerid_parse(tmp, &n, &l);
 	if (n)
 		ast_copy_string(name, n, namelen);

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=8362&r1=8361&r2=8362&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Fri Jan 20 18:42:25 2006
@@ -3705,12 +3705,7 @@
 	int start=0, finish=0, x;
 	ast_group_t group = 0;
 
-	copy = ast_strdupa(s);
-	if (!copy) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return 0;
-	}
-	c = copy;
+	c = copy = ast_strdupa(s);
 	
 	while ((piece = strsep(&c, ","))) {
 		if (sscanf(piece, "%d-%d", &start, &finish) == 2) {

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=8362&r1=8361&r2=8362&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Fri Jan 20 18:42:25 2006
@@ -1220,10 +1220,6 @@
 	struct ast_custom_function *acfptr;
 
 	function = ast_strdupa(in);
-	if (!function) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return ret;
-	}
 	if ((args = strchr(function, '('))) {
 		*args = '\0';
 		args++;
@@ -1255,10 +1251,6 @@
 	struct ast_custom_function *acfptr;
 
 	function = ast_strdupa(in);
-	if (!function) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return;
-	}
 	if ((args = strchr(function, '('))) {
 		*args = '\0';
 		args++;
@@ -3349,7 +3341,7 @@
 	if (argc == 3) {
 		char *splitter = ast_strdupa(argv[2]);
 		/* is there a '@' character? */
-		if (splitter && strchr(argv[2], '@')) {
+		if (strchr(argv[2], '@')) {
 			/* yes, split into exten & context ... */
 			exten   = strsep(&splitter, "@");
 			context = splitter;
@@ -5146,10 +5138,6 @@
 	
 	if (!ast_strlen_zero(data)) {
 		args = ast_strdupa(data);
-		if (!args) {
-			ast_log(LOG_ERROR, "Out of memory!\n");
-			return -1;
-		}
 		ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
 	}
 
@@ -5187,7 +5175,7 @@
  */
 static int pbx_builtin_gotoiftime(struct ast_channel *chan, void *data)
 {
-	int res=0;
+	int res = 0;
 	char *s, *ts;
 	struct ast_timing timing;
 
@@ -5196,18 +5184,15 @@
 		return -1;
 	}
 
-	if ((s = ast_strdupa(data))) {
-		ts = s;
-
-		/* Separate the Goto path */
-		strsep(&ts,"?");
-
-		/* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
-		if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
-			res = pbx_builtin_goto(chan, (void *)ts);
-	} else {
-		ast_log(LOG_ERROR, "Memory Error!\n");
-	}
+	ts = s = ast_strdupa(data);
+
+	/* Separate the Goto path */
+	strsep(&ts,"?");
+
+	/* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
+	if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
+		res = pbx_builtin_goto(chan, (void *)ts);
+	
 	return res;
 }
 
@@ -5227,17 +5212,11 @@
 		return -1;
 	}
 
-	ptr1 = ast_strdupa(data);
-
-	if (!ptr1) {
-		ast_log(LOG_ERROR, "Out of Memory!\n");
-		return -1;	
-	}
-
-	ptr2 = ptr1;
+	ptr2 = ptr1 = ast_strdupa(data);
+
 	/* Separate the Application data ptr1 is the time spec ptr2 is the app|data */
 	strsep(&ptr2,"?");
-	if(!ast_build_timing(&timing, ptr1)) {
+	if (!ast_build_timing(&timing, ptr1)) {
 		ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", ptr1, usage);
 		res = -1;
 	}
@@ -6004,8 +5983,7 @@
 		ast_log(LOG_WARNING, "Goto requires an argument (optional context|optional extension|priority)\n");
 		return -1;
 	}
-	s = ast_strdupa(goto_string);
-	stringp=s;
+	stringp = s = ast_strdupa(goto_string);
 	context = strsep(&stringp, "|");
 	exten = strsep(&stringp, "|");
 	if (!exten) {



More information about the asterisk-commits mailing list