[asterisk-commits] tilghman: trunk r146802 - in /trunk: ./ apps/ channels/ funcs/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 6 16:09:06 CDT 2008


Author: tilghman
Date: Mon Oct  6 16:09:05 2008
New Revision: 146802

URL: http://svn.digium.com/view/asterisk?view=rev&rev=146802
Log:
Merged revisions 146799 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r146799 | tilghman | 2008-10-06 15:52:04 -0500 (Mon, 06 Oct 2008) | 8 lines
  
  Dialplan functions should not actually return 0, unless they have modified the
  workspace.  To signal an error (and no change to the workspace), -1 should be
  returned instead.
  (closes issue #13340)
   Reported by: kryptolus
   Patches: 
         20080827__bug13340__2.diff.txt uploaded by Corydon76 (license 14)
........

Modified:
    trunk/   (props changed)
    trunk/apps/app_speech_utils.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/funcs/func_callerid.c
    trunk/funcs/func_cdr.c
    trunk/funcs/func_curl.c
    trunk/funcs/func_groupcount.c
    trunk/funcs/func_math.c
    trunk/funcs/func_odbc.c
    trunk/funcs/func_timeout.c
    trunk/res/res_smdi.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_speech_utils.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_speech_utils.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/apps/app_speech_utils.c (original)
+++ trunk/apps/app_speech_utils.c Mon Oct  6 16:09:05 2008
@@ -202,6 +202,8 @@
 
 	if (result->text != NULL) {
 		ast_copy_string(buf, result->text, len);
+	} else {
+		buf[0] = '\0';
 	}
 
 	return 0;
@@ -230,6 +232,8 @@
 
 	if (result->grammar != NULL) {
 		ast_copy_string(buf, result->grammar, len);
+	} else {
+		buf[0] = '\0';
 	}
 
 	return 0;
@@ -330,6 +334,8 @@
 			results++;
 		snprintf(tmp, sizeof(tmp), "%d", results);
 		ast_copy_string(buf, tmp, len);
+	} else {
+		buf[0] = '\0';
 	}
 
 	return 0;

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Mon Oct  6 16:09:05 2008
@@ -11899,7 +11899,11 @@
 		}
 		if((codec = ast_codec_pref_index(&peer->prefs, atoi(codecnum)))) {
 			ast_copy_string(buf, ast_getformatname(codec), len);
-		}
+		} else {
+			buf[0] = '\0';
+		}
+	} else {
+		buf[0] = '\0';
 	}
 
 	peer_unref(peer);

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Oct  6 16:09:05 2008
@@ -14959,7 +14959,11 @@
 		codecnum = strsep(&codecnum, "]"); /* trim trailing ']' if any */
 		if((codec = ast_codec_pref_index(&peer->prefs, atoi(codecnum)))) {
 			ast_copy_string(buf, ast_getformatname(codec), len);
-		}
+		} else {
+			buf[0] = '\0';
+		}
+	} else {
+		buf[0] = '\0';
 	}
 
 	unref_peer(peer, "unref_peer from function_sippeer, just before return");

Modified: trunk/funcs/func_callerid.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_callerid.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/funcs/func_callerid.c (original)
+++ trunk/funcs/func_callerid.c Mon Oct  6 16:09:05 2008
@@ -51,6 +51,7 @@
 static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
 			 char *buf, size_t len)
 {
+	int res = -1;
 	char *opt = data;
 
 	if (!chan)
@@ -64,10 +65,13 @@
 
 		if (!strncasecmp("all", data, 3)) {
 			snprintf(buf, len, "\"%s\" <%s>", name, num);
+			res = 0;
 		} else if (!strncasecmp("name", data, 4)) {
 			ast_copy_string(buf, name, len);
+			res = 0;
 		} else if (!strncasecmp("num", data, 3)) {
 			ast_copy_string(buf, num, len);
+			res = 0;
 		} else {
 			ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
 		}
@@ -78,32 +82,40 @@
 			snprintf(buf, len, "\"%s\" <%s>",
 				 S_OR(chan->cid.cid_name, ""),
 				 S_OR(chan->cid.cid_num, ""));
+			res = 0;
 		} else if (!strncasecmp("name", data, 4)) {
 			if (chan->cid.cid_name) {
 				ast_copy_string(buf, chan->cid.cid_name, len);
+				res = 0;
 			}
 		} else if (!strncasecmp("num", data, 3)) {
 			if (chan->cid.cid_num) {
 				ast_copy_string(buf, chan->cid.cid_num, len);
+				res = 0;
 			}
 		} else if (!strncasecmp("ani", data, 3)) {
 			if (!strncasecmp(data + 3, "2", 1)) {
 				snprintf(buf, len, "%d", chan->cid.cid_ani2);
 			} else if (chan->cid.cid_ani) {
 				ast_copy_string(buf, chan->cid.cid_ani, len);
+				res = 0;
 			}
 		} else if (!strncasecmp("dnid", data, 4)) {
 			if (chan->cid.cid_dnid) {
 				ast_copy_string(buf, chan->cid.cid_dnid, len);
+				res = 0;
 			}
 		} else if (!strncasecmp("rdnis", data, 5)) {
 			if (chan->cid.cid_rdnis) {
 				ast_copy_string(buf, chan->cid.cid_rdnis, len);
+				res = 0;
 			}
 		} else if (!strncasecmp("pres", data, 4)) {
 			ast_copy_string(buf, ast_named_caller_presentation(chan->cid.cid_pres), len);
+			res = 0;
 		} else if (!strncasecmp("ton", data, 3)) {
 			snprintf(buf, len, "%d", chan->cid.cid_ton);
+			res = 0;
 		} else {
 			ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
 		}
@@ -111,7 +123,7 @@
 		ast_channel_unlock(chan);
 	}
 
-	return 0;
+	return res;
 }
 
 static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,

Modified: trunk/funcs/func_cdr.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_cdr.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/funcs/func_cdr.c (original)
+++ trunk/funcs/func_cdr.c Mon Oct  6 16:09:05 2008
@@ -84,7 +84,7 @@
 		       ast_test_flag(&flags, OPT_RECURSIVE),
 			   ast_test_flag(&flags, OPT_UNPARSED));
 
-	return 0;
+	return ret ? 0 : -1;
 }
 
 static int cdr_write(struct ast_channel *chan, const char *cmd, char *parse,

Modified: trunk/funcs/func_curl.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_curl.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/funcs/func_curl.c (original)
+++ trunk/funcs/func_curl.c Mon Oct  6 16:09:05 2008
@@ -397,6 +397,7 @@
 static int acf_curl_exec(struct ast_channel *chan, const char *cmd, char *info, char *buf, size_t len)
 {
 	struct ast_str *str = ast_str_create(16);
+	int ret = -1;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(url);
 		AST_APP_ARG(postdata);
@@ -494,13 +495,14 @@
 		} else {
 			ast_copy_string(buf, str->str, len);
 		}
+		ret = 0;
 	}
 	ast_free(str);
 
 	if (chan)
 		ast_autoservice_stop(chan);
 	
-	return 0;
+	return ret;
 }
 
 struct ast_custom_function acf_curl = {

Modified: trunk/funcs/func_groupcount.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_groupcount.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/funcs/func_groupcount.c (original)
+++ trunk/funcs/func_groupcount.c Mon Oct  6 16:09:05 2008
@@ -34,6 +34,7 @@
 static int group_count_function_read(struct ast_channel *chan, const char *cmd,
 				     char *data, char *buf, size_t len)
 {
+	int ret = -1;
 	int count = -1;
 	char group[80] = "", category[80] = "";
 
@@ -59,12 +60,14 @@
 		ast_app_group_list_unlock();
 	}
 
-	if ((count = ast_app_group_get_count(group, category)) == -1)
+	if ((count = ast_app_group_get_count(group, category)) == -1) {
 		ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name);
-	else
+	} else {
 		snprintf(buf, len, "%d", count);
-
-	return 0;
+		ret = 0;
+	}
+
+	return ret;
 }
 
 static struct ast_custom_function group_count_function = {
@@ -91,9 +94,10 @@
 	if (!ast_strlen_zero(group)) {
 		count = ast_app_group_match_get_count(group, category);
 		snprintf(buf, len, "%d", count);
-	}
-
-	return 0;
+		return 0;
+	}
+
+	return -1;
 }
 
 static struct ast_custom_function group_match_count_function = {
@@ -111,6 +115,7 @@
 static int group_function_read(struct ast_channel *chan, const char *cmd,
 			       char *data, char *buf, size_t len)
 {
+	int ret = -1;
 	struct ast_group_info *gi = NULL;
 	
 	ast_app_group_list_rdlock();
@@ -124,12 +129,14 @@
 			break;
 	}
 	
-	if (gi)
+	if (gi) {
 		ast_copy_string(buf, gi->group, len);
+		ret = 0;
+	}
 	
 	ast_app_group_list_unlock();
 	
-	return 0;
+	return ret;
 }
 
 static int group_function_write(struct ast_channel *chan, const char *cmd,

Modified: trunk/funcs/func_math.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_math.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/funcs/func_math.c (original)
+++ trunk/funcs/func_math.c Mon Oct  6 16:09:05 2008
@@ -82,14 +82,14 @@
 	);
 
 	if (ast_strlen_zero(parse)) {
-		ast_log(LOG_WARNING, "Syntax: Math(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
+		ast_log(LOG_WARNING, "Syntax: MATH(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
 		return -1;
 	}
 
 	AST_STANDARD_APP_ARGS(args, parse);
 
 	if (args.argc < 1) {
-		ast_log(LOG_WARNING, "Syntax: Math(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
+		ast_log(LOG_WARNING, "Syntax: MATH(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
 		return -1;
 	}
 

Modified: trunk/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_odbc.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/funcs/func_odbc.c (original)
+++ trunk/funcs/func_odbc.c Mon Oct  6 16:09:05 2008
@@ -367,6 +367,7 @@
 		if (res == SQL_NO_DATA) {
 			ast_verb(4, "Found no rows [%s]\n", sql->str);
 			res1 = 0;
+			buf[0] = '\0';
 			ast_copy_string(rowcount, "0", sizeof(rowcount));
 		} else {
 			ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql->str);
@@ -517,6 +518,8 @@
 		}
 		odbc_store->data = resultset;
 		ast_channel_datastore_add(chan, odbc_store);
+	} else {
+		buf[0] = '\0';
 	}
 	SQLCloseCursor(stmt);
 	SQLFreeHandle(SQL_HANDLE_STMT, stmt);

Modified: trunk/funcs/func_timeout.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_timeout.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/funcs/func_timeout.c (original)
+++ trunk/funcs/func_timeout.c Mon Oct  6 16:09:05 2008
@@ -74,7 +74,7 @@
 
 	default:
 		ast_log(LOG_ERROR, "Unknown timeout type specified.\n");
-		break;
+		return -1;
 	}
 
 	return 0;

Modified: trunk/res/res_smdi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_smdi.c?view=diff&rev=146802&r1=146801&r2=146802
==============================================================================
--- trunk/res/res_smdi.c (original)
+++ trunk/res/res_smdi.c Mon Oct  6 16:09:05 2008
@@ -1260,7 +1260,7 @@
 return_error:
 	ast_module_user_remove(u);
 
-	return 0;
+	return res;
 }
 
 static struct ast_custom_function smdi_msg_retrieve_function = {




More information about the asterisk-commits mailing list