[asterisk-commits] rmudgett: branch 12 r397900 - /branches/12/main/cdr.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 28 17:55:28 CDT 2013


Author: rmudgett
Date: Wed Aug 28 17:55:27 2013
New Revision: 397900

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397900
Log:
Fixed problems with ast_cdr_serialize_variables().

* Fixed return value of ast_cdr_serialize_variables() on error.  It needs
to return 0 indicating no CDR variables found.

* Made ast_cdr_serialize_variables() check the return value of
cdr_object_format_property() and assert if nonzero.  A member of the
cdr_readonly_vars[] was not handled.

* Removed unused elements from cdr_readonly_vars[]: total_duration,
total_billsec, first_start, and first_answer.

Modified:
    branches/12/main/cdr.c

Modified: branches/12/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/cdr.c?view=diff&rev=397900&r1=397899&r2=397900
==============================================================================
--- branches/12/main/cdr.c (original)
+++ branches/12/main/cdr.c Wed Aug 28 17:55:27 2013
@@ -2862,11 +2862,29 @@
 }
 
 /* Read Only CDR variables */
-static const char * const cdr_readonly_vars[] = { "clid", "src", "dst", "dcontext",
-	"channel", "dstchannel", "lastapp", "lastdata", "start", "answer", "end", "duration",
-	"billsec", "disposition", "amaflags", "accountcode", "uniqueid", "linkedid",
-	"userfield", "sequence", "total_duration", "total_billsec", "first_start",
-	"first_answer", NULL };
+static const char * const cdr_readonly_vars[] = {
+	"clid",
+	"src",
+	"dst",
+	"dcontext",
+	"channel",
+	"dstchannel",
+	"lastapp",
+	"lastdata",
+	"start",
+	"answer",
+	"end",
+	"duration",
+	"billsec",
+	"disposition",
+	"amaflags",
+	"accountcode",
+	"uniqueid",
+	"linkedid",
+	"userfield",
+	"sequence",
+	NULL
+};
 
 int ast_cdr_setvar(const char *channel_name, const char *name, const char *value)
 {
@@ -3036,12 +3054,12 @@
 	int total = 0, x = 0, i;
 
 	if (!workspace) {
-		return 1;
+		return 0;
 	}
 
 	if (!cdr) {
 		ast_log(AST_LOG_ERROR, "Unable to find CDR for channel %s\n", channel_name);
-		return 1;
+		return 0;
 	}
 
 	ast_str_reset(*buf);
@@ -3067,7 +3085,11 @@
 		for (i = 0; cdr_readonly_vars[i]; i++) {
 			/* null out the workspace, because the cdr_get_tv() won't write anything if time is NULL, so you get old vals */
 			workspace[0] = 0;
-			cdr_object_format_property(it_cdr, cdr_readonly_vars[i], workspace, sizeof(workspace));
+			if (cdr_object_format_property(it_cdr, cdr_readonly_vars[i], workspace, sizeof(workspace))) {
+				/* Unhandled read-only CDR variable. */
+				ast_assert(0);
+				continue;
+			}
 
 			if (!ast_strlen_zero(workspace)
 				&& ast_str_append(buf, 0, "level %d: %s%c%s%c", x, cdr_readonly_vars[i], delim, workspace, sep) < 0) {




More information about the asterisk-commits mailing list